From: Brian Candler Date: 2010-09-01T18:07:04+09:00 Subject: Re: why no assert_not? Martin DeMello wrote: > Test::Unit could use a built-in antonym of assert, that succeeds if > its argument is either false or nil. Hmm, I would have thought "assert not ..." would work, but there is something odd in the parsing of 'not' as an argument: $ ruby -v ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] $ irb --simple-prompt >> not 1 => false >> not 3 < 4 => false >> puts(3 < 4) true => nil >> puts(not 3 < 4) SyntaxError: compile error (irb):4: syntax error, unexpected kNOT, expecting ')' puts(not 3 < 4) ^ (irb):4: syntax error, unexpected ')', expecting $end from (irb):4 from :0 >> puts((not 3 < 4)) false In the past I've just done assert !(...) But I think the issue is moot, because writing custom asserts is a perfectly standard thing to do. That is, just write def assert_not(bool, *rest) assert(!bool, *rest) end -- Posted via http://www.ruby-forum.com/.