Commit Graph

67 Commits

Author SHA1 Message Date
KOBAYASHI Shuji 6626fbc500 Refine assert_float
Avoid arithmetic operations when `exp` and/or `act` are infinity or NaN.
2019-04-12 22:27:07 +09:00
KOBAYASHI Shuji 9b024dcf7a Fix warning: '*' interpreted as argument prefix 2019-03-31 14:52:18 +09:00
KOBAYASHI Shuji 4e9c90ed47 Add pass and flunk to test/assert.rb 2019-03-30 13:19:31 +09:00
KOBAYASHI Shuji 0b6696cc28 Fix dealing with infinity and NaN in test/assert.rb:assert_float
`assert_float` is always passed when expected value and/or actual value are
infinity or NaN. This behavior seems unintentional.

Before this patch:

    assert_float(Float::INFINITY, 1.0)  #=> pass
    assert_float(-Float::INFINITY, 1)   #=> pass
    assert_float(1, 1/0)                #=> pass
    assert_float(1, -1/0)               #=> pass
    assert_float(1.0, Float::NAN)       #=> pass
    assert_float(Float::NAN, 1)         #=> pass

After this patch:

    assert_float(Float::INFINITY, 1.0)  #=> fail: Expected 1.0 to be Infinity.
    assert_float(-Float::INFINITY, 1)   #=> fail: Expected 1 to be -Infinity.
    assert_float(1, 1/0)                #=> fail: Expected Infinity to be 1.
    assert_float(1, -1/0)               #=> fail: Expected -Infinity to be 1.
    assert_float(1.0, Float::NAN)       #=> fail: Expected NaN to be 1.0.
    assert_float(Float::NAN, 1)         #=> fail: Expected 1 to be NaN.
2019-03-26 22:12:09 +09:00
KOBAYASHI Shuji df4b081392 Refactor t_print for test 2019-03-23 19:27:21 +09:00
KOBAYASHI Shuji 2b72baccf3 Remove redundant content in assertion failure message and diff
Based on minitest RubyGem.

Example of before this patch:

    - Assertion[1] Failed: Expected 1 to be 2
       Expected: 2
         Actual: 1
    - Assertion[2] Failed: Expected [1, 3] to include 2
       Collection: [1, 3]
           Object: 2

Example of after this patch:

    - Assertion[1]
       Expected: 2
         Actual: 1
    - Assertion[2]
       Expected [1, 3] to include 2.
2019-03-21 20:53:52 +09:00
KOBAYASHI Shuji c3122c887a Do not raise an exception when bintest fail
- An exception do not raise when mrbtest fail.
- There are no useful informations in exception message and backtrace.
2019-03-13 22:04:14 +09:00
KOBAYASHI Shuji 968e3b9400 Set GEMNAME on bintest 2019-03-07 22:16:47 +09:00
KOBAYASHI Shuji 650ca7da17 Count skip tests 2019-03-05 19:53:25 +09:00
KOBAYASHI Shuji ee537eceee GEMNAME is undefined in bintest
ref: https://github.com/mruby/mruby/pull/4296#discussion_r261868710
2019-03-04 00:18:54 +09:00
KOBAYASHI Shuji c6b8106924 Simplify MRubyTestSkip in test/assert.rb 2019-03-03 18:58:11 +09:00
KOBAYASHI Shuji fdb7f9dad3 Remove unneeded => in test skip/error messages 2019-02-26 21:32:34 +09:00
KOBAYASHI Shuji 5c40203930 Refine mrbgem name in assertion failure/skip message for core test 2019-02-24 19:21:40 +09:00
Yukihiro "Matz" Matsumoto 769b56c3ae Merge pull request #4290 from shuujii/refactor-exception-handling-in-assert
Refactor exception handling in `assert`
2019-02-21 22:37:09 +09:00
KOBAYASHI Shuji ad789944db Refactor exception handling in assert 2019-02-21 17:44:45 +09:00
KOBAYASHI Shuji 244abdae09 assert_true/assert_false should pass when actual is only true/false
For the following reasons:

- Previous behavior is confusable because it's different from test/unit rubygem's `assert_true`
- Tests may pass unintentionally in an inappropriate way; ref #4285 #4287
2019-02-20 18:49:38 +09:00
KOBAYASHI Shuji 6cdac5efb6 Lazy message/diff creation for assertion in test/assert.rb
Include the following changes too:

- Extract part of logic with block to a method
- Use `var ||= ...` instead of `var = ... unless var`
- Unify using parentheses for `t_print`
- Change methods order
2019-02-14 09:04:42 +09:00
KOBAYASHI Shuji e60f5f5cee Always through assert_true for assertion methods in test/assert.rb 2019-02-09 21:48:12 +09:00
KOBAYASHI Shuji 6f395a58d2 Add assert_same and assert_not_same 2019-01-05 20:41:09 +09:00
dearblue 9377da9775 Fix undefined variable is using 2018-12-21 23:44:38 +09:00
bamchoh 81dc383291 Use same format between Fail and Skip
We can see gem name in skip message by this fix
2017-12-09 02:12:37 +09:00
Christopher Aue bf32265743 Allowed to pass multiple exceptions to assert_raise 2017-08-30 11:03:51 +02:00
Christopher Aue 4b0b8f7e1a Refactored #assert_raise and #assert_nothing_raised 2017-08-29 23:25:53 +02:00
Christopher Aue 495a2e605d fixed printing failed assertions 2017-07-11 12:53:48 +02:00
Yukihiro "Matz" Matsumoto af0bef6dd8 Silence rubocop warnings. 2017-06-22 00:27:17 +09:00
Yukihiro "Matz" Matsumoto 057be5ffb5 use unless instead of if not. 2017-06-21 11:13:33 +09:00
Ryo Okubo f085baae06 Pass when assert returns a false value 2017-01-07 17:57:14 +09:00
Tomasz Dąbrowski a8b8abbd82 Fixed float tolerance in tests when MRB_USE_FLOAT is set 2016-11-24 12:48:41 +01:00
Tomasz Dąbrowski 617050450e test/assert.rb should not use puts 2016-11-10 13:17:59 +01:00
Yukihiro "Matz" Matsumoto 1d7d7062fc __t_printstr__ may not be available for tests 2015-12-31 00:55:07 +09:00
Yukihiro "Matz" Matsumoto 4fdec33ff4 simpler t_print 2015-12-30 14:25:05 +09:00
Daniel Bovensiepen a3111f144c Round execution time 2015-01-03 17:53:32 +08:00
take_cheeze a24729044a Print backtrace of crashed test in verbose mode. 2014-07-19 22:33:13 +09:00
Nobuyoshi Nakada ab67c57f65 remove trailing spaces 2014-04-30 09:50:14 +09:00
ksss 15eabcdbc4 Show error class name when raise Error 2014-03-31 08:14:14 +09:00
Yukihiro "Matz" Matsumoto 1b422befb1 revert 813ba5 since #1949 fixed 2014-03-26 17:53:22 +09:00
take_cheeze 813ba50bfb Don't use ensure to fix crash of mruby-eval test. 2014-03-26 12:59:56 +09:00
Yukihiro "Matz" Matsumoto 4592862b0d remove unnecessary operator method call; ref #1927 2014-03-24 09:17:09 +09:00
take_cheeze db5d78e229 Count crashed tests in total tests count. 2014-03-24 03:22:17 +09:00
Jun Hiroe d27dcbe9d2 Refactor assert_true 2014-03-16 23:26:29 +09:00
ksss 23680cb447 add assertion method `assert_nothing_raised' 2014-03-11 00:13:36 +09:00
fleuria 0a4010728a make test/assert.rb cruby compatible 2013-11-16 14:22:15 +08:00
Daniel Bovensiepen d5eab236e7 Fix assignment of block as actual value and not expected 2013-08-01 11:32:46 +08:00
Daniel Bovensiepen d8c8893e94 Implement assert_float and add block mode to assert_equal and assert_not_equal 2013-06-15 02:10:05 +08:00
Daniel Bovensiepen 5915874e01 Add assert_not_include to test environment 2013-06-09 05:16:10 +08:00
Daniel Bovensiepen 2d696b26b6 Add assert_not_equal 2013-06-09 04:48:53 +08:00
Ryan Scott 0d4227ac04 Implemented ObjectSpace.count_objects to count the number of allocated objects for each type 2013-05-12 18:42:21 +10:00
Daniel Bovensiepen 520b0f73bf Implement fallback print method for testing environment in case mruby-print GEM wasn't included. 2013-05-08 21:17:08 +08:00
Akira Yumiyama c86d76141c bugfix: assert_raise 2013-03-02 19:38:43 +09:00
Daniel Bovensiepen 81f96cb9af Move Math::TOLERANCE to mruby-math 2013-02-28 15:20:46 +00:00