From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions. Date: Tue, 17 Dec 2024 14:11:16 +0900 Message-ID: References: <43ad0b39-03cf-b648-3bc9-8c4a064519a8@disroot.org> <8e113f49-c1dc-313b-e65a-24a73c5b887a@disroot.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000058bb7806297054c6" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33461"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-devel@gnu.org, Ricardo Wurmus , Tomas Volf <~@wolfsden.cz>, Maxime Devos , mikael@djurfeldt.com To: Adam Faiz Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Dec 17 06:12:11 2024 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tNPsQ-0008UL-Gi for guile-devel@m.gmane-mx.org; Tue, 17 Dec 2024 06:12:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNPrq-0005Pk-Qk; Tue, 17 Dec 2024 00:11:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNPrp-0005Pc-WE for guile-devel@gnu.org; Tue, 17 Dec 2024 00:11:34 -0500 Original-Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNPrm-0003om-Sf for guile-devel@gnu.org; Tue, 17 Dec 2024 00:11:33 -0500 Original-Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2f1459b6f84so3314329a91.0 for ; Mon, 16 Dec 2024 21:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734412288; x=1735017088; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mNfR8xBaU9u7vcStib6dwN9eyEjjTaNv0MQg8xu4Dt4=; b=M3KHqWCEWQ70REBcuZUBspwtel8CPTBbWf9UIEMmTAyemBz4KhFyQdVwGxZoTPQc13 jGW6CSXvWUo1J/5xcl5pmyf2yqZ/ReruzXrFu8pue55W2jJDuymqZcCyvnnobiJqgmfz qNWjHBMRubzP2Y8m1kkEJaWte+UNmVao8nQm84z/eFeGaCbW1nel7suxrZpbUiBG6Qkh T5z1tMrergAHdo6crfBbe/DROEWvhrWF/uNnNIZRGZqEcf3lHU9EOp8o46SqN2qmII3b GnguCuGP3HPuKcbjdpLZYHa0zkl0gfFtPPQz+FNmVA+WmcBGv+X9idBxTKMrbtRIc0lA UvQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734412288; x=1735017088; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mNfR8xBaU9u7vcStib6dwN9eyEjjTaNv0MQg8xu4Dt4=; b=QhTlDHVFi4hyB6PuohSqkPGW7dljX2srCPdq++HYRINw8kOu34pqeU1royy0/ZyHuo bqGvco7Qo9uy8dd5g33oTJUr7yj+kq6ySpokKcwAIhRMQxRZvmNej8tetfKDdtj/jQzP ddRep86xWkTkOT/9dhjvZybGuMA1RZmzMYeWMxZswhOkXxRhLIU7BJMhg5PjKjynPnqk 0f73tCRuQnC2H9jdwCxdmNcRX8y2xGgdG5r0v3eBT1ne5sBf0B+8rQWBlPByQ2bzrklU aaCNP93WwPBhlX9nGEB+Idue/Alslr6N8LhH4Odc7T1by8nguINV5e0qFJESGtZGl2NO w8eA== X-Gm-Message-State: AOJu0YzPf3UBU/WDaYxFrtwHdhjziPcIQ2JPe/a/ILVw5G+rfeiHoBey XG9DieimgFi++ZPaXpS8RQBwA4pxx04RAoMW4gkjRzC82Pq311fKr2weWYGuXQT8bmjqcypXDaG FtqNR86ggRfuk1M7IWxBc3C1fYwfW6g== X-Gm-Gg: ASbGnct1SYPDeq95k1qEfD4bhtKDQSo/n1JPKlSk15KWYhAZOsqLMSIF8AwQR2dC1ml d+8vX6yzOiM/lCzcNZX0mkxq/ZsN94iIC63oD X-Google-Smtp-Source: AGHT+IGgiMKiEPSMeYq7ONbZ0yJ6cr2BOL1KQo30zSd1zg7B7wKuQ70V3NVhZ+SMO2jH9rGG52bPMThToDDg81itdXA= X-Received: by 2002:a17:90b:3c4e:b0:2ee:863e:9ff6 with SMTP id 98e67ed59e1d1-2f28fb6e842mr23648376a91.16.1734412288436; Mon, 16 Dec 2024 21:11:28 -0800 (PST) In-Reply-To: <8e113f49-c1dc-313b-e65a-24a73c5b887a@disroot.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=nalaginrut@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22836 Archived-At: --00000000000058bb7806297054c6 Content-Type: text/plain; charset="UTF-8" The preferred activity in your design is more like for-each family, say, handle the result inside the proc without return result. So maybe it should be named as for-each-*-in-file, which is more understandable in the first glance. Best regards. On Tue, Dec 17, 2024, 13:31 Adam Faiz wrote: > From 258d20a9665e6f845a167258c33374a00e734885 Mon Sep 17 00:00:00 2001 > From: AwesomeAdam54321 > 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 > --00000000000058bb7806297054c6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

The preferred activity in your design is more like for-each = family, say, handle the result inside the proc without return result. So ma= ybe it should be named as for-each-*-in-file, which is more understandable = in the first glance.

Best regards.

On Tue, Dec 17, 2024, 13:31 Adam Faiz <adam.faiz@disroot.org> wrote:
From 258d20a9665e6f845a167258c33374a00e734885 Mon Sep 17 00:0= 0: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
=C2=A0functions.

* test-suite/tests/ports.test: Add test cases for
`for-delimited-in-port` and `for-line-in-file`.
---
=C2=A0test-suite/tests/ports.test | 22 ++++++++++++++++++++++
=C2=A01 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 @@
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(not (string-index (%search-load-p= ath (basename (test-file)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #\\))))))

+(let ((lst '())
+=C2=A0 =C2=A0 =C2=A0 (lines '())
+=C2=A0 =C2=A0 =C2=A0 (string "line1\nline2\nline3")
+=C2=A0 =C2=A0 =C2=A0 (filename (test-file)))
+=C2=A0 (call-with-input-string
+=C2=A0 =C2=A0 =C2=A0 "A\0B\0C"
+=C2=A0 =C2=A0 (lambda (port)
+=C2=A0 =C2=A0 =C2=A0 (pass-if "for-delimited-in-port returns true upo= n completion"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (for-delimited-in-port port
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (entry)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(set! lst (cons entry lst))) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#:delims "\0")
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 (equal? lst '("C" "B" = "A")))))
+=C2=A0 (let ((port (open-output-file filename)))
+=C2=A0 =C2=A0 (display string port)
+=C2=A0 =C2=A0 (close-port port))
+=C2=A0 (pass-if "for-line-in-file returns true upon completion"<= br> +=C2=A0 =C2=A0 (for-line-in-file filename
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 (lambda (line)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (set! lines (cons line lines))))
+=C2=A0 =C2=A0 (equal? lines '("line3" "line2" &quo= t;line1"))))
+
=C2=A0(delete-file (test-file))

=C2=A0;;; Local Variables:
--
2.46.0
--00000000000058bb7806297054c6--