Fixed (assert|refute)_match's argument order.
[git-p4: depot-paths = "//src/minitest/dev/": change = 4506]
This commit is contained in:
parent
0a8bf10185
commit
8b6586b9d3
15
History.txt
15
History.txt
|
@ -4,19 +4,20 @@
|
|||
|
||||
* Added miniunit/autorun.rb as replacement for test/unit.rb's autorun.
|
||||
|
||||
* 11 bug fixes:
|
||||
* 12 bug fixes:
|
||||
|
||||
* Fixed indentation of capture_io for ruby 1.9 warning.
|
||||
* assert_match escapes if passed string for pattern.
|
||||
* Removed disable_autorun method, added autorun.rb instead.
|
||||
* Fixed (assert|refute)_match's argument order.
|
||||
* Fixed assert_in_delta (should be >=, not >).
|
||||
* Fixed assert_raises to match Modules.
|
||||
* Fixed capture_io to not dup IOs.
|
||||
* Fixed indentation of capture_io for ruby 1.9 warning.
|
||||
* Fixed location to deal better with custom assertions and load paths. (Yuki)
|
||||
* Fixed skip's backtrace.
|
||||
* Made describe private. For some reason I thought that an attribute of Kernel.
|
||||
* instance_of? is different from ===, use instance_of.
|
||||
* Got arg order wrong in *_match in tests, message wrong as a result.
|
||||
* location now deals bitter with custom assertions and load paths. (Yuki)
|
||||
* Made describe private. For some reason I thought that an attribute of Kernel.
|
||||
* Removed disable_autorun method, added autorun.rb instead.
|
||||
* assert_match escapes if passed string for pattern.
|
||||
* instance_of? is different from ===, use instance_of.
|
||||
|
||||
=== 1.3.0 / 2008-10-09
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ module MiniTest
|
|||
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
|
||||
assert_respond_to act, :"=~"
|
||||
exp = /#{Regexp.escape(exp)}/ if String === exp && String === act
|
||||
assert act =~ exp, msg
|
||||
assert exp =~ act, msg
|
||||
end
|
||||
|
||||
def assert_nil obj, msg = nil
|
||||
|
@ -277,7 +277,7 @@ module MiniTest
|
|||
msg = message(msg) { "Expected #{mu_pp(exp)} to not match #{mu_pp(act)}" }
|
||||
assert_respond_to act, :"=~"
|
||||
exp = /#{Regexp.escape(exp)}/ if String === exp && String === act
|
||||
refute act =~ exp, msg
|
||||
refute exp =~ act, msg
|
||||
end
|
||||
|
||||
def refute_nil obj, msg = nil
|
||||
|
|
|
@ -529,6 +529,27 @@ class TestMiniTestTestCase < MiniTest::Unit::TestCase
|
|||
@tc.assert_match(/\w+/, "blah blah blah")
|
||||
end
|
||||
|
||||
def test_assert_match_object
|
||||
@assertion_count = 2
|
||||
|
||||
pattern = Object.new
|
||||
def pattern.=~(other) true end
|
||||
|
||||
@tc.assert_match pattern, 5
|
||||
end
|
||||
|
||||
def test_assert_match_object_triggered
|
||||
@assertion_count = 2
|
||||
|
||||
pattern = Object.new
|
||||
def pattern.=~(other) false end
|
||||
def pattern.inspect; "<<Object>>" end
|
||||
|
||||
util_assert_triggered 'Expected <<Object>> to match 5.' do
|
||||
@tc.assert_match pattern, 5
|
||||
end
|
||||
end
|
||||
|
||||
def test_assert_match_triggered
|
||||
@assertion_count = 2
|
||||
util_assert_triggered 'Expected /\d+/ to match "blah blah blah".' do
|
||||
|
@ -860,6 +881,35 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|||
@tc.refute_match(/\d+/, "blah blah blah")
|
||||
end
|
||||
|
||||
def test_refute_match_object
|
||||
@assertion_count = 2
|
||||
@tc.refute_match Object.new, 5 # default #=~ returns false
|
||||
end
|
||||
|
||||
def test_assert_object_triggered
|
||||
@assertion_count = 2
|
||||
|
||||
pattern = Object.new
|
||||
def pattern.=~(other) false end
|
||||
def pattern.inspect; "<<Object>>" end
|
||||
|
||||
util_assert_triggered 'Expected <<Object>> to match 5.' do
|
||||
@tc.assert_match pattern, 5
|
||||
end
|
||||
end
|
||||
|
||||
def test_refute_match_object_triggered
|
||||
@assertion_count = 2
|
||||
|
||||
pattern = Object.new
|
||||
def pattern.=~(other) true end
|
||||
def pattern.inspect; "<<Object>>" end
|
||||
|
||||
util_assert_triggered 'Expected <<Object>> to not match 5.' do
|
||||
@tc.refute_match pattern, 5
|
||||
end
|
||||
end
|
||||
|
||||
def test_refute_match_triggered
|
||||
@assertion_count = 2
|
||||
util_assert_triggered 'Expected /\w+/ to not match "blah blah blah".' do
|
||||
|
|
Loading…
Reference in New Issue