unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* ASSERT should return a value
@ 2011-04-06 14:11 Ian Price
  2011-04-11 16:01 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Price @ 2011-04-06 14:11 UTC (permalink / raw)
  To: bug-guile

[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: ASSERT should return a value
  2011-04-06 14:11 ASSERT should return a value Ian Price
@ 2011-04-11 16:01 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2011-04-11 16:01 UTC (permalink / raw)
  To: Ian Price; +Cc: bug-guile

On Wed 06 Apr 2011 16:11, Ian Price <ianprice90@googlemail.com> writes:

> 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.

Thanks; applied.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-11 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06 14:11 ASSERT should return a value Ian Price
2011-04-11 16:01 ` Andy Wingo

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).