summaryrefslogtreecommitdiffhomepage
path: root/test/assert.rb
AgeCommit message (Collapse)Author
2020-06-08only use GEMNAME if defined in assert.rbMark Delk
Check if the constant GEMNAME is defined before use in `assert.rb`. This is added to prevent an undefined constant error when using `assert.rb` in other environments - for example, testing CRuby.
2020-05-29Print exception backtrace if possible without `-v` in testKOBAYASHI Shuji
Backtrace is useful for debugging.
2019-09-05add assert_not_nil methodtakumakume
2019-07-30Merge pull request #4606 from shuujii/refine-message-to-skip-in-nested-assertYukihiro "Matz" Matsumoto
Refine message to `skip` in nested `assert`
2019-07-30Refine message to `skip` in nested `assert`KOBAYASHI Shuji
- I think "Info" is used only to `skip`, so change to "Skip". - Changed the default value of `assert` and specify the argument explicitly at the caller of `assert` because it is unnatural "Assertion failed" is output even though the assertion doesn't fail. == Example: def assert_foo(exp, act) assert do assert_equal exp[0], act[0] assert_equal exp[1], act[1] end end def assert_bar(exp, act) assert do skip end end def assert_baz(exp, act) assert do assert_equal exp, act assert_bar exp, act end end assert 'test#skip_in_nested_assert' do assert_baz 1, 1 end === Before this patch: ?.. Info: test#skip_in_nested_assert (core) - Assertion[1] Info: Assertion failed (core) - Assertion[1-2] Skip: Assertion failed (core) Total: 3 OK: 2 KO: 0 Crash: 0 Warning: 0 Skip: 1 === After this patch: ??? Skip: test#skip_in_nested_assert (core) - Assertion[1] Skip: assert (core) - Assertion[1-2] Skip: assert (core) Total: 3 OK: 0 KO: 0 Crash: 0 Warning: 0 Skip: 3
2019-07-29Fix "Warn if assertion is missing inside `assert`"; ref ff43b2b9KOBAYASHI Shuji
2019-07-29Fixed a conflict between #4407 and #4540Yukihiro "Matz" Matsumoto
2019-07-29Merge pull request #4407 from ↵Yukihiro "Matz" Matsumoto
shuujii/add-assert_raise_with_message-and-assert_raise_with_message_pattern Add `assert_raise_with_message` and `assert_raise_with_message_pattern`
2019-07-29Resolved conflicts in #4320Yukihiro "Matz" Matsumoto
2019-06-29Nested `assert` for mrbtestdearblue
When nesting `assert` used in test, it is indented and displayed. Assertion numbers are concatenated by `"-"` at this time. The purpose is to match the apparent numbers when failing with `assert_mruby` which is defined by `mrbgems/mruby-bin-mruby/bintest/mruby.rb` for example. Child assertions "skip" and "info" are reported as parent assertions "info" and `$ok_test += 1`. The child assertions "ko" and "crash" are reported as the parent assertion "ko" and `$ko_test += 1`. When child assertions are mixed, "ko" takes precedence. Incompatibility: - `$mrbtest_assert_idx` takes `nil` or an integer array object. So far it was `nil` or an integer. - `$asserts` points to the top of the internal stack in the `assert`. - `$mrbtest_assert` points to the top of the internal stack in `assert`.
2019-05-27Use `$undefined.equal?(obj2)` instead of `obj2 == $undefined` in `assert.rb`KOBAYASHI Shuji
In case `obj2.==` is broken.
2019-04-29Refine the default values of `flunk`KOBAYASHI Shuji
The default message for the second argument should be set to the first argument because only one argument is normally specified.
2019-04-26Add `assert_raise_with_message` and `assert_raise_with_message_pattern`KOBAYASHI Shuji
2019-04-22Merge pull request #4356 from shuujii/add-assert_match-and-assert_not_matchYukihiro "Matz" Matsumoto
Add `assert_match` and `assert_not_match`
2019-04-22Add `assert_predicate` and `assert_operator`KOBAYASHI Shuji
2019-04-14Add `assert_match` and `assert_not_match`KOBAYASHI Shuji
2019-04-12Refine `assert_float`KOBAYASHI Shuji
Avoid arithmetic operations when `exp` and/or `act` are infinity or NaN.
2019-03-31Fix warning: '*' interpreted as argument prefixKOBAYASHI Shuji
2019-03-30Add `pass` and `flunk` to `test/assert.rb`KOBAYASHI Shuji
2019-03-26Fix dealing with infinity and NaN in `test/assert.rb:assert_float`KOBAYASHI Shuji
`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-23Refactor `t_print` for testKOBAYASHI Shuji
2019-03-21Remove redundant content in assertion failure message and diffKOBAYASHI Shuji
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-13Do not raise an exception when bintest failKOBAYASHI Shuji
- An exception do not raise when mrbtest fail. - There are no useful informations in exception message and backtrace.
2019-03-07Set `GEMNAME` on bintestKOBAYASHI Shuji
2019-03-05Count skip testsKOBAYASHI Shuji
2019-03-04`GEMNAME` is undefined in bintestKOBAYASHI Shuji
ref: https://github.com/mruby/mruby/pull/4296#discussion_r261868710
2019-03-03Simplify `MRubyTestSkip` in `test/assert.rb`KOBAYASHI Shuji
2019-02-26Remove unneeded `=>` in test skip/error messagesKOBAYASHI Shuji
2019-02-24Refine mrbgem name in assertion failure/skip message for core testKOBAYASHI Shuji
2019-02-21Merge pull request #4290 from shuujii/refactor-exception-handling-in-assertYukihiro "Matz" Matsumoto
Refactor exception handling in `assert`
2019-02-21Refactor exception handling in `assert`KOBAYASHI Shuji
2019-02-20`assert_true`/`assert_false` should pass when actual is only `true`/`false`KOBAYASHI Shuji
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-14Lazy message/diff creation for assertion in `test/assert.rb`KOBAYASHI Shuji
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-09Always through `assert_true` for assertion methods in `test/assert.rb`KOBAYASHI Shuji
2019-01-05Add `assert_same` and `assert_not_same`KOBAYASHI Shuji
2018-12-21Fix undefined variable is usingdearblue
2017-12-09Use same format between Fail and Skipbamchoh
We can see gem name in skip message by this fix
2017-08-30Allowed to pass multiple exceptions to assert_raiseChristopher Aue
2017-08-29Refactored #assert_raise and #assert_nothing_raisedChristopher Aue
2017-07-11fixed printing failed assertionsChristopher Aue
2017-06-22Silence rubocop warnings.Yukihiro "Matz" Matsumoto
2017-06-21use `unless` instead of `if not`.Yukihiro "Matz" Matsumoto
2017-01-07Pass when assert returns a false valueRyo Okubo
2016-11-24Fixed float tolerance in tests when MRB_USE_FLOAT is setTomasz Dąbrowski
2016-11-10test/assert.rb should not use putsTomasz Dąbrowski
2015-12-31__t_printstr__ may not be available for testsYukihiro "Matz" Matsumoto
2015-12-30simpler t_printYukihiro "Matz" Matsumoto
2015-01-03Round execution timeDaniel Bovensiepen
2014-07-19Print backtrace of crashed test in verbose mode.take_cheeze
2014-04-30remove trailing spacesNobuyoshi Nakada