[REBOL] Re: Assertions and DbC
From: santilli:gabriele:gmai:l at: 23-Oct-2007 17:38
2007/10/2, Brian Tiffin <btiffin-rogers.com>:
> >> assert [equal? 12]
> ** User Error: equal? 12 - assertion failed
> ** Near: assert [equal? 12]
What happens here is:
equal? 12 throw make error! ...
ie. you are comparing 12 with the result of THROW (which never
returns). That's why you don't get a complaint by EQUAL? (it never
gets all its arguments).
From the way you use it, it seems to me it may be better as:
assert: func [[catch] expr [block!]] [
unless all expr [
throw make error! join mold/only expr " - assertion failed"
(With that you can also write things like assert [a = 1 b = 2].)