From: Nala Ginrut <nalaginrut@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: [PATCH] add new read-delimited option to return #f while terminating delimiter can't be found.
Date: Thu, 17 Jan 2013 17:07:59 +0800 [thread overview]
Message-ID: <1358413679.2720.10.camel@Renee-desktop.suse> (raw)
In-Reply-To: <87ip6xf2io.fsf@pobox.com>
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
On Wed, 2013-01-16 at 18:42 +0100, Andy Wingo wrote:
> On Wed 07 Mar 2012 17:32, Nala Ginrut <nalaginrut@gmail.com> writes:
>
> > (call-with-input-string "asdf" (lambda (port) (read-delimited "@" port
> > 'fail))))
>
> LGTM; just missing a test case. I would tighten up the documentation,
> too: make sure each sentence is actually a sentence. (It's a common
> mistake, even for native speakers.)
>
Attached the patch for rdelim test case. Please review it.
Thanks!
> Cheers,
>
> Andy
[-- Attachment #2: 0001-test-case-tests-rdelim.test-Add-test-case-for-fail-i.patch --]
[-- Type: text/x-patch, Size: 2015 bytes --]
From 47d484faac2d98dde0658467d45e848727bc1929 Mon Sep 17 00:00:00 2001
From: Nala Ginrut <nalaginrut@gmail.com>
Date: Thu, 17 Jan 2013 17:04:21 +0800
Subject: [PATCH 2/2] * test-case/tests/rdelim.test: Add test case for 'fail
in read-delimited.
---
test-suite/tests/rdelim.test | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/test-suite/tests/rdelim.test b/test-suite/tests/rdelim.test
index e61fc92..6c6e323 100644
--- a/test-suite/tests/rdelim.test
+++ b/test-suite/tests/rdelim.test
@@ -113,6 +113,16 @@
(read-delimited ",.;" (open-input-string "hello, world!")
'concat)))
+ (pass-if "delimiter fail, fail"
+ (equal? #f
+ (read-delimited "@" (open-input-string "asdf")
+ 'fail)))
+
+ (pass-if "delimiter hit, fail"
+ (equal? "hello"
+ (read-delimited "," (open-input-string "hello, world")
+ 'fail)))
+
(pass-if "delimiter hit, peek"
(let ((p (open-input-string "hello, world!")))
(and (string=? "hello" (read-delimited ",.;" p 'peek))
@@ -161,6 +171,11 @@
(string=? (substring s 0 5) "hello")
(char=? #\, (peek-char p)))))
+ (pass-if "delimiter hit, fail"
+ (let ((s (make-string 123))
+ (p (open-input-string "asdf")))
+ (not (read-delimited! "@" s p 'fail))))
+
(pass-if "string too small"
(let ((s (make-string 7)))
(and (= 7 (read-delimited! "}{" s
@@ -183,6 +198,12 @@
'split))
(string=? s "hello, "))))
+ (pass-if "string too small, fail"
+ (let ((s (make-string 7)))
+ (not (read-delimited! "@" s
+ (open-input-string "asdf")
+ 'fail))))
+
(pass-if "eof"
(eof-object? (read-delimited! ":" (make-string 7)
(open-input-string ""))))
--
1.7.10.4
next prev parent reply other threads:[~2013-01-17 9:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 16:32 [PATCH] add new read-delimited option to return #f while terminating delimiter can't be found Nala Ginrut
2013-01-16 17:42 ` Andy Wingo
2013-01-17 9:07 ` Nala Ginrut [this message]
2013-01-22 12:44 ` Andy Wingo
2013-01-22 16:41 ` Nala Ginrut
2013-01-23 10:00 ` Andy Wingo
2013-01-23 10:24 ` Nala Ginrut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358413679.2720.10.camel@Renee-desktop.suse \
--to=nalaginrut@gmail.com \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).