From: Ian Price <ianprice90@googlemail.com>
To: bug-guile@gnu.org
Subject: ASSERT should return a value
Date: Wed, 6 Apr 2011 15:11:12 +0100 [thread overview]
Message-ID: <BANLkTi=RqdOKVp0g0OZxYRKWGGX3_qgp0g@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
Hello Guilers,
Over on Racket Users, Marco Maggi points out that ASSERT should return
the value of the expression if it is true[0][1]. I have attached a
simple patch to fix this behaviour in guile.
Regards,
Ian
0. http://lists.racket-lang.org/users/archive/2011-April/045046.html
1. http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.14
[-- Attachment #2: 0001-fix-assert-to-return-true-value.patch --]
[-- Type: application/octet-stream, Size: 1660 bytes --]
From d7d754b23c801fb5399cb3a93c307ac5f4a7e414 Mon Sep 17 00:00:00 2001
From: Ian Price <ianprice90@googlemail.com>
Date: Wed, 6 Apr 2011 13:51:44 +0100
Subject: [PATCH] fix assert to return true value.
* module/rnrs/base.scm (assert): returns value instead of void.
* test-suite/tests/r6rs-base.test ("assert"): add test cases.
---
module/rnrs/base.scm | 2 +-
test-suite/tests/r6rs-base.test | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/module/rnrs/base.scm b/module/rnrs/base.scm
index 2f5a218..fb6716c 100644
--- a/module/rnrs/base.scm
+++ b/module/rnrs/base.scm
@@ -169,7 +169,7 @@
(define-syntax assert
(syntax-rules ()
((_ expression)
- (if (not expression)
+ (or expression
(raise (condition
(make-assertion-violation)
(make-message-condition
diff --git a/test-suite/tests/r6rs-base.test b/test-suite/tests/r6rs-base.test
index 1509b04..0a05b63 100644
--- a/test-suite/tests/r6rs-base.test
+++ b/test-suite/tests/r6rs-base.test
@@ -19,6 +19,8 @@
(define-module (test-suite test-r6rs-base)
:use-module ((rnrs base) :version (6))
+ :use-module ((rnrs conditions) :version (6))
+ :use-module ((rnrs exceptions) :version (6))
:use-module (test-suite lib))
(with-test-prefix "boolean=?"
@@ -172,3 +174,9 @@
(pass-if (not (integer-valued? +0.01i)))
(pass-if (not (integer-valued? -inf.0i))))
+(with-test-prefix "assert"
+ (pass-if "assert returns value" (= 1 (assert 1)))
+ (pass-if "assertion-violation"
+ (guard (condition ((assertion-violation? condition) #t))
+ (assert #f)
+ #f)))
--
1.7.3.4
next reply other threads:[~2011-04-06 14:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 14:11 Ian Price [this message]
2011-04-11 16:01 ` ASSERT should return a value Andy Wingo
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='BANLkTi=RqdOKVp0g0OZxYRKWGGX3_qgp0g@mail.gmail.com' \
--to=ianprice90@googlemail.com \
--cc=bug-guile@gnu.org \
/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).