From unknown Tue Jun 17 01:43:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75041: [PATCH] doc/srfi-64: Fix typos and add examples. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: arne_bab@web.de, bug-guile@gnu.org Resent-Date: Mon, 23 Dec 2024 05:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 75041 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 75041@debbugs.gnu.org Cc: Arne Babenhauserheide , Maxim Cournoyer , arne_bab@web.de X-Debbugs-Original-To: bug-guile@gnu.org X-Debbugs-Original-Xcc: arne_bab@web.de Received: via spool by submit@debbugs.gnu.org id=B.173492998023686 (code B ref -1); Mon, 23 Dec 2024 05:00:02 +0000 Received: (at submit) by debbugs.gnu.org; 23 Dec 2024 04:59:40 +0000 Received: from localhost ([127.0.0.1]:52843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPaXc-00069x-42 for submit@debbugs.gnu.org; Sun, 22 Dec 2024 23:59:40 -0500 Received: from lists.gnu.org ([209.51.188.17]:38754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPaXZ-00069n-P1 for submit@debbugs.gnu.org; Sun, 22 Dec 2024 23:59:38 -0500 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 1tPaXZ-0006TB-Ir for bug-guile@gnu.org; Sun, 22 Dec 2024 23:59:37 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPaXX-0006N3-2u for bug-guile@gnu.org; Sun, 22 Dec 2024 23:59:36 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-728e1799d95so4252221b3a.2 for ; Sun, 22 Dec 2024 20:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734929973; x=1735534773; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b0DsOgHwhQJE8gKN2RMg2ORqhVvgzj/Dpy9vK86bFFc=; b=GgNUzpQDNl/wH2PQSn1Nf79bDmg9KRXN/q38IetIV4jNXOej8LVzCOd1Q4d/4K8Ff8 ejZnHult9Ka/iTkP2hRLQD02ZmVh5yxliZgGGkHs3HUUXw6Bo6GlpZBKvo94huHaS+Hg Ar+P33VnKcE6HxAiKWhJXDfijD1b+lHtWkfpGJ44Y4C7rcy2iz0g/afZYA2RpBZBBd9q TfFsc4AIzakSf+1VPv02NVbNIlwBo7N7zfzm/LOvckW3Qmc6eURN2FkAOLl9RUd7l+Iw pFpEvYwJ3+wrmyc9PlxlEf93CCSaKjJnulE1KRQQ3ykcOEbb3JImW/0omXnxd+rxIll/ VxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734929973; x=1735534773; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b0DsOgHwhQJE8gKN2RMg2ORqhVvgzj/Dpy9vK86bFFc=; b=QkPuozzY/yLkMV2TcjLFqpOmw73SWHPnszWoUFFnjII3TQFNcW6eFl1clG/4gcZLaN rJ86/p8J4PAT6sZyMt620no5auqpFMe1jwgJWwVRIPe4PR/ordutEf3oV1FPEtzAbGud gXkEnPwc1OCfZ+iGjeb4tlDPLAciZVwlltSMUK++yAwBXM7WStY9t3gltKegj58uwIJP 0IYHNRpl9Ph0C44bDLIFzQpkcya0hDyV97iWEPautedl2kHF8OoLBRoTjg/DhXMI/WwJ L47h/iHemzzbBH6HOJ8OLwmAj2j1Omw/kRojAsEFTis40haQR3TtPGaO+C7anlEbXc9a LhCw== X-Gm-Message-State: AOJu0YwvjcgSVAmibO1FJlKe5wgbSM0X1jU43Z42DpSRFHY9HaAl4CYt MKiJJMl7WcnO0KWMnNE21RjbzSuQLjXK1lPwFUFwE3xs+OGG04uo8LDZvw== X-Gm-Gg: ASbGncsjoJNWZRUBpb8BCPzobunR6LJBEkszFOo8y7oGJQsX+u2bmttDpETWycIRYl0 lZrsnSo+1k5x6TiQXRDx/4TQOLmLHXndu8yZ4gE0mcyNBo7wUum7z0cHOEWoZoMmO0vmbkLtP3I 70JCYGMc5zdO1Ek5yYIc53kL0ObW9a0qgD822aBvc6VisDiR7F8h4vIMJU2jL+QR1BpvAn8ghoE +KBrI7Y8JTAAlUXJMTFQ16F72L/Yjk3GCHEW6VhB31+3EOy/8EyjZZdmmEZuRDqv1Kg9fCheX4= X-Google-Smtp-Source: AGHT+IE4MSz/zVDmQ1WwGjAeAtxFlqeWg4oczgom4W1pZxnV5e/jOgbBtovaELb2R+87q5cYCa5rdA== X-Received: by 2002:a05:6a00:44cc:b0:725:df1a:275 with SMTP id d2e1a72fcca58-72abdeb7016mr18367942b3a.23.1734929972906; Sun, 22 Dec 2024 20:59:32 -0800 (PST) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b2b3e83dsm5437059a12.32.2024.12.22.20.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 20:59:32 -0800 (PST) From: Maxim Cournoyer Date: Mon, 23 Dec 2024 13:59:14 +0900 Message-ID: <20241223045914.16142-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=maxim.cournoyer@gmail.com; helo=mail-pf1-x42d.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, 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-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * doc/ref/srfi-modules.texi (SRFI-64 Writing Basic Test Suites): Fix typo. Add default test runner example. Add test-approximate and test-error examples. Document valid error types in Guile for test-error. (SRFI-64 Conditonal Test Suites and Other Advanced Features): Fix typo. Suggested-by: Arne Babenhauserheide --- doc/ref/srfi-modules.texi | 83 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index d77bc1c90..537ec9059 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -5387,13 +5387,31 @@ is also easy to add new tests, without having to name individual tests (though that is optional). Test cases are executed in the context of a @dfn{test runner}, which is -a object that accumulates and reports test results. This specification +an object that accumulates and reports test results. This specification defines how to create and use custom test runners, but implementations should also provide a default test runner. It is suggested (but not required) that loading the above file in a top-level environment will cause the tests to be executed using an implementation-specified default test runner, and @code{test-end} will cause a summary to be displayed in -an implementation-specified manner. +an implementation-specified manner. The SRFI 64 implementation used in +Guile provides such a default test runner; running the above snippet at +the REPL prints: + +@example +*** Entering test group: vec-test *** +$1 = #t +* PASS: +$2 = ((pass . 1)) +* PASS: +$3 = ((pass . 2)) +* PASS: +$4 = ((pass . 3)) +*** Leaving test group: vec-test *** +*** Test suite finished. *** +*** # of expected passes : 3 +@end example + +It also returns the @code{} object. @subsubheading Simple test-cases @@ -5455,6 +5473,14 @@ once): (and (>= test-expr (- expected error)) (<= test-expr (+ expected error)))) @end lisp + +Here's an example: +@lisp +(test-approximate "is 22/7 within 1% of π?" + 3.1415926535 + 22/7 + 1/100) +@end lisp @end deffn @subsubheading Tests for catching errors @@ -5492,8 +5518,59 @@ classes: An implementation that cannot catch exceptions should skip @code{test-error} forms. + +@cindex test-error error types +@cindex error types, test-error, srfi-64 +The SRFI-64 implementation in Guile supports specifying @var{error-type} +as either: +@iterate +@item +@code{#f}, meaning the test is @emph{not} expected to produce an error +@item +@code{#t}, meaning the test is expected to produce an error, of any type +@item +A native exception type, as created via @code{make-exception-type} or +@code{make-condition-type} from SRFI-35 +@item +A predicate, which will be applied to the exception caught +to determine whether is it of the right type +@item +A symbol, for the exception kind of legacy +@code{make-exception-from-throw} style exceptions. @end deffn +Below are some examples valid in Guile: + +@lisp +(test-error "expect old-style exception kind" + 'numerical-overflow + (/ 1 0)) +@end lisp + +@lisp +(use-modules (ice-9 exceptions)) ;for standard exception types + +(test-error "expect a native exception type" + &warning + (raise-exception (make-warning))) + +(test-error "expect a native exception, using predicate" + warning? + (raise-exception (make-warning))) +@end lisp + +@lisp +(use-modules (srfi srfi-35)) + +(test-error "expect a serious SRFI 35 condition type" + &serious + (raise-exception (condition (&serious)))) + +(test-error "expect a serious SRFI 35 condition type, using predicate" + serious-condition? + (raise-exception (condition (&serious)))) +@end lisp + @subsubheading Testing syntax Testing syntax is tricky, especially if we want to check that invalid @@ -5617,7 +5694,7 @@ or specifying that some tests are @emph{expected} to fail. @subsubheading Test specifiers Sometimes we want to only run certain tests, or we know that certain -tests are expected to fail. A @dfn{test specifier} is one-argument +tests are expected to fail. A @dfn{test specifier} is a one-argument function that takes a test-runner and returns a boolean. The specifier may be run before a test is performed, and the result may control whether the test is executed. For convenience, a specifier may also be base-commit: f6359a4715d023761454f1bf945633ce4cca98fc -- 2.46.0 From unknown Tue Jun 17 01:43:52 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Maxim Cournoyer Subject: bug#75041: closed (Re: [PATCH] doc/srfi-64: Fix typos and add examples.) Message-ID: References: <6B79F5D5-DB37-4254-B6E6-54DCE1B2E40E@sarc.name> <20241223045914.16142-1-maxim.cournoyer@gmail.com> X-Gnu-PR-Message: they-closed 75041 X-Gnu-PR-Package: guile X-Gnu-PR-Keywords: patch Reply-To: 75041@debbugs.gnu.org Date: Fri, 24 Jan 2025 18:30:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1737743402-4405-1" This is a multi-part message in MIME format... ------------=_1737743402-4405-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #75041: [PATCH] doc/srfi-64: Fix typos and add examples. which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 75041@debbugs.gnu.org. --=20 75041: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75041 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1737743402-4405-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 75041-done) by debbugs.gnu.org; 24 Jan 2025 18:29:35 +0000 Received: from localhost ([127.0.0.1]:47015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tbOQw-00017p-Ff for submit@debbugs.gnu.org; Fri, 24 Jan 2025 13:29:34 -0500 Received: from h5.fbrelay.privateemail.com ([162.0.218.228]:43325) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tbOQt-00017Y-NM for 75041-done@debbugs.gnu.org; Fri, 24 Jan 2025 13:29:32 -0500 Received: from MTA-10-4.privateemail.com (mta-10.privateemail.com [198.54.118.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by h5.fbrelay.privateemail.com (Postfix) with ESMTPSA id 4YfmYb6RNcz2xjk for <75041-done@debbugs.gnu.org>; Fri, 24 Jan 2025 18:29:23 +0000 (UTC) Received: from mta-10.privateemail.com (localhost [127.0.0.1]) by mta-10.privateemail.com (Postfix) with ESMTP id 4YfmYW2yZyz3hhY8 for <75041-done@debbugs.gnu.org>; Fri, 24 Jan 2025 13:29:19 -0500 (EST) Received: from [192.168.1.16] (unknown [51.154.167.214]) by mta-10.privateemail.com (Postfix) with ESMTPA for <75041-done@debbugs.gnu.org>; Fri, 24 Jan 2025 13:29:18 -0500 (EST) From: lloda Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: [PATCH] doc/srfi-64: Fix typos and add examples. Message-Id: <6B79F5D5-DB37-4254-B6E6-54DCE1B2E40E@sarc.name> Date: Fri, 24 Jan 2025 19:29:17 +0100 To: 75041-done@debbugs.gnu.org X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 75041-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Applied in f109baebc005952a58726ee80b56bc5ef291af92. Thanks ------------=_1737743402-4405-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 23 Dec 2024 04:59:40 +0000 Received: from localhost ([127.0.0.1]:52843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPaXc-00069x-42 for submit@debbugs.gnu.org; Sun, 22 Dec 2024 23:59:40 -0500 Received: from lists.gnu.org ([209.51.188.17]:38754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tPaXZ-00069n-P1 for submit@debbugs.gnu.org; Sun, 22 Dec 2024 23:59:38 -0500 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 1tPaXZ-0006TB-Ir for bug-guile@gnu.org; Sun, 22 Dec 2024 23:59:37 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPaXX-0006N3-2u for bug-guile@gnu.org; Sun, 22 Dec 2024 23:59:36 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-728e1799d95so4252221b3a.2 for ; Sun, 22 Dec 2024 20:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734929973; x=1735534773; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b0DsOgHwhQJE8gKN2RMg2ORqhVvgzj/Dpy9vK86bFFc=; b=GgNUzpQDNl/wH2PQSn1Nf79bDmg9KRXN/q38IetIV4jNXOej8LVzCOd1Q4d/4K8Ff8 ejZnHult9Ka/iTkP2hRLQD02ZmVh5yxliZgGGkHs3HUUXw6Bo6GlpZBKvo94huHaS+Hg Ar+P33VnKcE6HxAiKWhJXDfijD1b+lHtWkfpGJ44Y4C7rcy2iz0g/afZYA2RpBZBBd9q TfFsc4AIzakSf+1VPv02NVbNIlwBo7N7zfzm/LOvckW3Qmc6eURN2FkAOLl9RUd7l+Iw pFpEvYwJ3+wrmyc9PlxlEf93CCSaKjJnulE1KRQQ3ykcOEbb3JImW/0omXnxd+rxIll/ VxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734929973; x=1735534773; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b0DsOgHwhQJE8gKN2RMg2ORqhVvgzj/Dpy9vK86bFFc=; b=QkPuozzY/yLkMV2TcjLFqpOmw73SWHPnszWoUFFnjII3TQFNcW6eFl1clG/4gcZLaN rJ86/p8J4PAT6sZyMt620no5auqpFMe1jwgJWwVRIPe4PR/ordutEf3oV1FPEtzAbGud gXkEnPwc1OCfZ+iGjeb4tlDPLAciZVwlltSMUK++yAwBXM7WStY9t3gltKegj58uwIJP 0IYHNRpl9Ph0C44bDLIFzQpkcya0hDyV97iWEPautedl2kHF8OoLBRoTjg/DhXMI/WwJ L47h/iHemzzbBH6HOJ8OLwmAj2j1Omw/kRojAsEFTis40haQR3TtPGaO+C7anlEbXc9a LhCw== X-Gm-Message-State: AOJu0YwvjcgSVAmibO1FJlKe5wgbSM0X1jU43Z42DpSRFHY9HaAl4CYt MKiJJMl7WcnO0KWMnNE21RjbzSuQLjXK1lPwFUFwE3xs+OGG04uo8LDZvw== X-Gm-Gg: ASbGncsjoJNWZRUBpb8BCPzobunR6LJBEkszFOo8y7oGJQsX+u2bmttDpETWycIRYl0 lZrsnSo+1k5x6TiQXRDx/4TQOLmLHXndu8yZ4gE0mcyNBo7wUum7z0cHOEWoZoMmO0vmbkLtP3I 70JCYGMc5zdO1Ek5yYIc53kL0ObW9a0qgD822aBvc6VisDiR7F8h4vIMJU2jL+QR1BpvAn8ghoE +KBrI7Y8JTAAlUXJMTFQ16F72L/Yjk3GCHEW6VhB31+3EOy/8EyjZZdmmEZuRDqv1Kg9fCheX4= X-Google-Smtp-Source: AGHT+IE4MSz/zVDmQ1WwGjAeAtxFlqeWg4oczgom4W1pZxnV5e/jOgbBtovaELb2R+87q5cYCa5rdA== X-Received: by 2002:a05:6a00:44cc:b0:725:df1a:275 with SMTP id d2e1a72fcca58-72abdeb7016mr18367942b3a.23.1734929972906; Sun, 22 Dec 2024 20:59:32 -0800 (PST) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-842b2b3e83dsm5437059a12.32.2024.12.22.20.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 20:59:32 -0800 (PST) From: Maxim Cournoyer To: bug-guile@gnu.org Subject: [PATCH] doc/srfi-64: Fix typos and add examples. Date: Mon, 23 Dec 2024 13:59:14 +0900 Message-ID: <20241223045914.16142-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Debbugs-CC: ludo@gnu.org X-Debbugs-CC: arne_bab@web.de Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=maxim.cournoyer@gmail.com; helo=mail-pf1-x42d.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, 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-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Arne Babenhauserheide , Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) * doc/ref/srfi-modules.texi (SRFI-64 Writing Basic Test Suites): Fix typo. Add default test runner example. Add test-approximate and test-error examples. Document valid error types in Guile for test-error. (SRFI-64 Conditonal Test Suites and Other Advanced Features): Fix typo. Suggested-by: Arne Babenhauserheide --- doc/ref/srfi-modules.texi | 83 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi index d77bc1c90..537ec9059 100644 --- a/doc/ref/srfi-modules.texi +++ b/doc/ref/srfi-modules.texi @@ -5387,13 +5387,31 @@ is also easy to add new tests, without having to name individual tests (though that is optional). Test cases are executed in the context of a @dfn{test runner}, which is -a object that accumulates and reports test results. This specification +an object that accumulates and reports test results. This specification defines how to create and use custom test runners, but implementations should also provide a default test runner. It is suggested (but not required) that loading the above file in a top-level environment will cause the tests to be executed using an implementation-specified default test runner, and @code{test-end} will cause a summary to be displayed in -an implementation-specified manner. +an implementation-specified manner. The SRFI 64 implementation used in +Guile provides such a default test runner; running the above snippet at +the REPL prints: + +@example +*** Entering test group: vec-test *** +$1 = #t +* PASS: +$2 = ((pass . 1)) +* PASS: +$3 = ((pass . 2)) +* PASS: +$4 = ((pass . 3)) +*** Leaving test group: vec-test *** +*** Test suite finished. *** +*** # of expected passes : 3 +@end example + +It also returns the @code{} object. @subsubheading Simple test-cases @@ -5455,6 +5473,14 @@ once): (and (>= test-expr (- expected error)) (<= test-expr (+ expected error)))) @end lisp + +Here's an example: +@lisp +(test-approximate "is 22/7 within 1% of π?" + 3.1415926535 + 22/7 + 1/100) +@end lisp @end deffn @subsubheading Tests for catching errors @@ -5492,8 +5518,59 @@ classes: An implementation that cannot catch exceptions should skip @code{test-error} forms. + +@cindex test-error error types +@cindex error types, test-error, srfi-64 +The SRFI-64 implementation in Guile supports specifying @var{error-type} +as either: +@iterate +@item +@code{#f}, meaning the test is @emph{not} expected to produce an error +@item +@code{#t}, meaning the test is expected to produce an error, of any type +@item +A native exception type, as created via @code{make-exception-type} or +@code{make-condition-type} from SRFI-35 +@item +A predicate, which will be applied to the exception caught +to determine whether is it of the right type +@item +A symbol, for the exception kind of legacy +@code{make-exception-from-throw} style exceptions. @end deffn +Below are some examples valid in Guile: + +@lisp +(test-error "expect old-style exception kind" + 'numerical-overflow + (/ 1 0)) +@end lisp + +@lisp +(use-modules (ice-9 exceptions)) ;for standard exception types + +(test-error "expect a native exception type" + &warning + (raise-exception (make-warning))) + +(test-error "expect a native exception, using predicate" + warning? + (raise-exception (make-warning))) +@end lisp + +@lisp +(use-modules (srfi srfi-35)) + +(test-error "expect a serious SRFI 35 condition type" + &serious + (raise-exception (condition (&serious)))) + +(test-error "expect a serious SRFI 35 condition type, using predicate" + serious-condition? + (raise-exception (condition (&serious)))) +@end lisp + @subsubheading Testing syntax Testing syntax is tricky, especially if we want to check that invalid @@ -5617,7 +5694,7 @@ or specifying that some tests are @emph{expected} to fail. @subsubheading Test specifiers Sometimes we want to only run certain tests, or we know that certain -tests are expected to fail. A @dfn{test specifier} is one-argument +tests are expected to fail. A @dfn{test specifier} is a one-argument function that takes a test-runner and returns a boolean. The specifier may be run before a test is performed, and the result may control whether the test is executed. For convenience, a specifier may also be base-commit: f6359a4715d023761454f1bf945633ce4cca98fc -- 2.46.0 ------------=_1737743402-4405-1-- From unknown Tue Jun 17 01:43:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#75041: closed (Re: [PATCH] doc/srfi-64: Fix typos and add examples.) Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 25 Jan 2025 01:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75041 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: lloda Cc: 75041@debbugs.gnu.org Received: via spool by 75041-submit@debbugs.gnu.org id=B75041.173776785218301 (code B ref 75041); Sat, 25 Jan 2025 01:18:02 +0000 Received: (at 75041) by debbugs.gnu.org; 25 Jan 2025 01:17:32 +0000 Received: from localhost ([127.0.0.1]:47826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tbUnk-0004l6-B1 for submit@debbugs.gnu.org; Fri, 24 Jan 2025 20:17:32 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]:49543) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1tbUnh-0004kr-Lj for 75041@debbugs.gnu.org; Fri, 24 Jan 2025 20:17:30 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-46c8474d8daso22256471cf.3 for <75041@debbugs.gnu.org>; Fri, 24 Jan 2025 17:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737767843; x=1738372643; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:cc:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=qvtCi1NS/90DPl/07eXIjsH6sfYua/zGNosL5bQosHw=; b=Zljii0uahUcQ8ASDmGg4Z9hoZ2fcBgJoNMr0plG4Jwytn8XfMRBy+LBopJ8XD3o94e bwkuR4HWQ5OVO+1mUath8EpWlIWnMv4tdCyEtCTfI6Dtyua45tRisf+2fvmn9ogw2OP9 lbTyIn/u2sKFHNgC/1qVgwjC6Bfap1AyAkk3wlMDWnz81oM29XPEcVn384d4sWrjmylf 69qp0t1EzreTDABsNsfyriTyfIklv0XeKJrEwo3GCWIuwDHH/7oCFmudxlYDEcHFga7M yhfcuGxunw7sCjTRWG3jRH2SNJTe2qri59gy5teZitF51fKn4kXaiIKe8AGlgOLY5WKh AKyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737767843; x=1738372643; h=mime-version:user-agent:message-id:date:cc:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qvtCi1NS/90DPl/07eXIjsH6sfYua/zGNosL5bQosHw=; b=XiRo6a4E40TroJRo5MqYLNkW5EfVzDPfvrOEQVbWzDBFclpuCRzwWaHyFbM1e3ssQH u23P/2JNYo3vN0t6vGS882y36kPdBX5KjcRo0+/4lnYjF5QFaDU6GJXCpsr2Ch4S2cF+ J44ZmGdRXfKTv8IIdy/k21KOUmNOlYv9wXfNPAQehwnO3Lc2xrpY3O7GWeq1G8teRnAx rKmwGFHffTvSkvj4/HfGPRrL2Cywq1ayAUg+wcpQ8vVO4FbEB76PhCKIht8948WwSODL FHtQWlu/0qdeB288ggE9stzw+zrLK0qnvNUTqiafRHqGv7PYKdRsJhikDo6ff7fQ2ADd GLcQ== X-Gm-Message-State: AOJu0YwV8BzbUqsCYxJZBjuQdMirdqptCk4atU4HW9yRas5Ip0cyWXpl M+oiExPzid/A6ThAH9z1rCvOrXpl21MKND/51Je+XKKjFR/1ADNZydg5qesa X-Gm-Gg: ASbGncs780fi040jOSh2agssO/83B4y0K7MgpUO9PS780mfRVd6X6BaDjxIu7re0Zax WwLYXISW/nF6kBlkn1dr6CJwIJGDkrJQnC4XIAKEJAUsjVpruZ+KbSaFP72AaKUOOJyYTwIie4N zyhHx+sEHLBzvcC8w+MDyPVnwqQy6y/CV+s6EthzVSMleW4sYmOYMy72vRbTiY8l9saGMT/zppa hUGpMEyATxtHLAmTDLLklfVdcLfVKQDo0mgj0XB2AVVnW94/AspCH/ns2cIWPAfVDV/m0YStQEn CZZoxCXINujpRMrwjhBR3HSi+g== X-Google-Smtp-Source: AGHT+IFpZyVQSU8Tf1+YJEKWRkIzXhQA+pClG4EujFeTNtivScx20dBisQBFj8DeN6cxqno68l39ww== X-Received: by 2002:a05:622a:343:b0:467:5f32:3204 with SMTP id d75a77b69052e-46e12b963cdmr412649301cf.45.1737767842631; Fri, 24 Jan 2025 17:17:22 -0800 (PST) Received: from terra (vps-6234970c.vps.ovh.ca. [51.222.13.224]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e6687e713sm15824681cf.26.2025.01.24.17.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 17:17:21 -0800 (PST) From: Maxim Cournoyer In-Reply-To: (GNU bug Tracking System's message of "Fri, 24 Jan 2025 18:30:02 +0000") References: <6B79F5D5-DB37-4254-B6E6-54DCE1B2E40E@sarc.name> <20241223045914.16142-1-maxim.cournoyer@gmail.com> Date: Sat, 25 Jan 2025 10:17:09 +0900 Message-ID: <87zfjfg0a2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, [...] > From: lloda > Subject: Re: [PATCH] doc/srfi-64: Fix typos and add examples. > To: 75041-done@debbugs.gnu.org > Date: Fri, 24 Jan 2025 19:29:17 +0100 (6 hours, 47 minutes, 1 second ago) > > > Applied in f109baebc005952a58726ee80b56bc5ef291af92. Excellent, thank you! -- Maxim