unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Adam Faiz <adam.faiz@disroot.org>
To: guile-devel@gnu.org
Cc: Ricardo Wurmus <rekado@elephly.net>, Tomas Volf <~@wolfsden.cz>,
	Maxime Devos <maximedevos@telenet.be>,
	Nala Ginrut <nalaginrut@gmail.com>,
	mikael@djurfeldt.com
Subject: [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions.
Date: Tue, 17 Dec 2024 12:31:23 +0800	[thread overview]
Message-ID: <8e113f49-c1dc-313b-e65a-24a73c5b887a@disroot.org> (raw)
In-Reply-To: <43ad0b39-03cf-b648-3bc9-8c4a064519a8@disroot.org>

From 258d20a9665e6f845a167258c33374a00e734885 Mon Sep 17 00:00:00 2001
From: AwesomeAdam54321 <adam.faiz@disroot.org>
Date: Tue, 17 Dec 2024 12:20:52 +0800
Subject: [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related
 functions.

* test-suite/tests/ports.test: Add test cases for
`for-delimited-in-port` and `for-line-in-file`.
---
 test-suite/tests/ports.test | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index bec5e356c..15d515f1f 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -2089,6 +2089,28 @@
           (not (string-index (%search-load-path (basename (test-file)))
                              #\\))))))
 
+(let ((lst '())
+      (lines '())
+      (string "line1\nline2\nline3")
+      (filename (test-file)))
+  (call-with-input-string
+      "A\0B\0C"
+    (lambda (port)
+      (pass-if "for-delimited-in-port returns true upon completion"
+        (for-delimited-in-port port
+                               (lambda (entry)
+                                 (set! lst (cons entry lst)))
+                               #:delims "\0")
+        (equal? lst '("C" "B" "A")))))
+  (let ((port (open-output-file filename)))
+    (display string port)
+    (close-port port))
+  (pass-if "for-line-in-file returns true upon completion"
+    (for-line-in-file filename
+                      (lambda (line)
+                        (set! lines (cons line lines))))
+    (equal? lines '("line3" "line2" "line1"))))
+
 (delete-file (test-file))
 
 ;;; Local Variables:
-- 
2.46.0



  reply	other threads:[~2024-12-17  4:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 15:21 [PATCH 1/2] rdelim: Add new procedure `for-rdelim-in-port` Adam Faiz
2024-12-16 15:24 ` [PATCH 2/2] doc: Add documentation for `for-rdelim-in-port` and, related procedures Adam Faiz
2024-12-17  4:31   ` Adam Faiz [this message]
2024-12-17  5:11     ` [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions Nala Ginrut
2024-12-17  7:21       ` Mikael Djurfeldt
2024-12-17 16:43         ` Mikael Djurfeldt
2024-12-16 16:46 ` [PATCH 1/2] rdelim: Add new procedure `for-rdelim-in-port` 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=8e113f49-c1dc-313b-e65a-24a73c5b887a@disroot.org \
    --to=adam.faiz@disroot.org \
    --cc=guile-devel@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=mikael@djurfeldt.com \
    --cc=nalaginrut@gmail.com \
    --cc=rekado@elephly.net \
    --cc=~@wolfsden.cz \
    /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).