Assert_false

Hi,

Does anyone know why assert_false is not inlcuded in Test:Unit, but for
e.g. assertFalse( ) is a method in JUnit?

aidy

The same reason there’s no assert_true? It’s redundant, IMO.

assert truth
assert !truth
assert (not truth)

etc.

Jason

On Wed, Sep 27, 2006 at 12:09:24AM +0900, Jason R. wrote:

assert !truth
assert (not truth)

Yet Ruby has both ‘if’ and ‘unless’ keywords.

I think it wuld be nice if the inverted version of the Assertions
methods were named ‘deny’, e.g. deny_nil vs. assert_not_nil. :wink:

ta,
dave

aidy wrote:

Hi,

Does anyone know why assert_false is not inlcuded in Test:Unit, but for
e.g. assertFalse( ) is a method in JUnit?

Hi aidy,

Have a look at the source of /1.8/test/unit/assertions.rb and search for the text: “Example
Custom Assertion”.

Regards,
Jordan

refute(test, msg = nil)
Fails if test is a true value

works for many asserts: refute_equal, refute_match, etc.

http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest/Assertions.html#method-i-refute

‘deny’ is close. Ruby uses the word ‘refute’.

refute(test, msg = nil) click to toggle source
Fails if test is a true value

http://ruby-doc.org/stdlib-2.0.0/libdoc/minitest/rdoc/MiniTest/Assertions.html#method-i-refute

David H. wrote in post #144978:

On Wed, Sep 27, 2006 at 12:09:24AM +0900, Jason R. wrote:

assert !truth
assert (not truth)

Yet Ruby has both ‘if’ and ‘unless’ keywords.

I think it wuld be nice if the inverted version of the Assertions
methods were named ‘deny’, e.g. deny_nil vs. assert_not_nil. :wink:

ta,
dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs