From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mikael Djurfeldt Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH] test-suite: Add tests for `for-rdelim-in-port`-related functions. Date: Tue, 17 Dec 2024 08:21:37 +0100 Message-ID: References: <43ad0b39-03cf-b648-3bc9-8c4a064519a8@disroot.org> <8e113f49-c1dc-313b-e65a-24a73c5b887a@disroot.org> Reply-To: mikael@djurfeldt.com Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000081f808062972268f" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26409"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Faiz , guile-devel , Ricardo Wurmus , Tomas Volf <~@wolfsden.cz>, Maxime Devos To: Nala Ginrut Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Dec 17 08:22:21 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 1tNRuO-0006hX-T2 for guile-devel@m.gmane-mx.org; Tue, 17 Dec 2024 08:22:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNRu2-00077E-Ux; Tue, 17 Dec 2024 02:21:58 -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 1tNRu1-00076p-Em for guile-devel@gnu.org; Tue, 17 Dec 2024 02:21:57 -0500 Original-Received: from mail-ua1-f52.google.com ([209.85.222.52]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNRtw-0002hR-0k for guile-devel@gnu.org; Tue, 17 Dec 2024 02:21:57 -0500 Original-Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-85c15e283bfso867389241.2 for ; Mon, 16 Dec 2024 23:21:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734420109; x=1735024909; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=frk9/FEK6WQf9TjuWhMn5s3C29HxoinHgwrYQYXi3Os=; b=Lh3ZMiEMp6wXZmm3TQXvPm5xJd591FbHLPxjfQ6AsPCerpzEY0uZv1Jy65Ijp2vZyQ VBhqsCTwztWf1ZV86pbT2TtotE1un5DyvNuhfVod5c/pN6DdwAMTjV2gGVDcmei4SO1E Zq6LfK73zATgGEYr1erFDsB2BZAlP6LEzCYNRRSFkXVXSZEyVcvJeXXzKOsttfBEAHCi xcCXmWPew0J0xfzwIp8y3BaLQajvGZZ92NqkFFx/6vH3JlX/a1oJbGwyPKvNQSWJRi/A o5Uef0gfFRPHaKPVtXNdV91Olbskl/e/l8TyFgu0vXQOOwbBMHFP/Co6DE0FqzOLtQRY JxCw== X-Forwarded-Encrypted: i=1; AJvYcCUcTQMSIoDasgmjtbVM28dNfwMJwtH1UkmRGp95MTCJAPYdwcc8fGovQjOEH8eefvqdY/SeVTZx16CrAg==@gnu.org X-Gm-Message-State: AOJu0Yy4CaSYUnBNEx27fJBTwv383X9ZBi5apqNqjSdg6EMF5U14Iadi G1ves6jGWCcwbrIRfwexDCxC97AbDycUasIMNNU42DmfwZIoHoEzd1ewySuZKbVUkS/Ihds3qTb w9tO8XD2eiH9dS/Ka5KIieG2B+8E= X-Gm-Gg: ASbGncvISqB5rL1m2nXFUBrccX8LBv8ml5Bo9IQLkJDvDDaR+mDtuwj097vIvYwRdNn /wOgZzZjnGOwYRTXuXYPEN01HKca0sdcGk4e704w= X-Google-Smtp-Source: AGHT+IFmA/dhlpiIoFL3DQRCLoUg/M/j34ZfM50d9puoz2p8K5jNaYTCHh41lZZPtr/dIvyT82gELn6q/bGvxrqWSec= X-Received: by 2002:a05:6102:5488:b0:4b0:49ba:8278 with SMTP id ada2fe7eead31-4b25de50e3dmr14847973137.25.1734420109324; Mon, 16 Dec 2024 23:21:49 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.222.52; envelope-from=mdjurfeldt@gmail.com; helo=mail-ua1-f52.google.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.13, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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:22837 Archived-At: --00000000000081f808062972268f Content-Type: text/plain; charset="UTF-8" Do others think this as well? To me, the shorter names which Adam selected seem more palatable. Otherwise they get a bit long. Den tis 17 dec. 2024 06:11Nala Ginrut skrev: > 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 >> > --00000000000081f808062972268f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Do others think this as well? To me, the shorter names wh= ich Adam selected seem more palatable. Otherwise they get a bit long.
=
Den tis 17 dec. 2024 06:11Nala Ginrut <nalaginrut@gmail.com> skrev:

The preferred activity in your desig= n is more like for-each family, say, handle the result inside the proc with= out 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 <adam.faiz@disroot.org> wrote:
From 258d20a9665e6f845a167258c33374a00e734885 Mo= n 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
=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
--00000000000081f808062972268f--