diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-30 11:05:31 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-30 11:05:31 +0000 |
commit | 1d08109c23ecf687bfe2c924d6e0098593bdf94c (patch) | |
tree | b1fdcb438818ce93d1003131e8851670b87efcf7 | |
parent | 3dbaf1ebf86d9dcedb1cfd76738cd1ac13ba0046 (diff) |
merges r21188 from trunk into ruby_1_9_1.
Imported minitest 1.3.1 r4506.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | lib/minitest/unit.rb | 4 | ||||
-rw-r--r-- | test/minitest/test_mini_test.rb | 50 |
3 files changed, 60 insertions, 5 deletions
@@ -1,3 +1,8 @@ +Tue Dec 30 18:23:10 2008 Ryan Davis <[email protected]> + + * lib/minitest/*.rb: Imported minitest 1.3.1 r4506. + * test/minitest/*.rb: ditto. + Tue Dec 30 17:59:59 2008 Martin Duerst <[email protected]> * transcode.c: Minor fixes and tweaks in documentation. @@ -165,7 +170,7 @@ Sun Dec 28 10:28:04 2008 Yusuke Endoh <[email protected]> * thread.c (mutex_unlock, rb_mutex_unlock, rb_mutex_unlock_all): mutex_unlock receives a thread. -Sun Dec 28 05:44:44 2008 Ryan Davis <[email protected]> +Sun Dec 28 05:44:44 2008 Ryan Davis <[email protected]> * lib/minitest/*.rb: Imported minitest 1.3.1 r4505. * test/minitest/*.rb: ditto. @@ -3610,7 +3615,7 @@ Fri Oct 10 17:26:50 2008 NARUSE, Yui <[email protected]> * ext/json/ext/parser/parser.c (JSON_parse_string): associate encoding. -Fri Oct 10 10:18:21 2008 Ryan Davis <[email protected]> +Fri Oct 10 10:18:21 2008 Ryan Davis <[email protected]> * lib/test/*: reverted back to test/unit. * test/test/*: ditto @@ -13006,7 +13011,7 @@ Tue Jun 17 20:32:37 2008 Nobuyoshi Nakada <[email protected]> miniruby, and tests, debug, etc have no meaning when cross-compiling. -Tue Jun 17 18:39:11 2008 Ryan Davis <[email protected]> +Tue Jun 17 18:39:11 2008 Ryan Davis <[email protected]> * common.mk: fixed dependencies on miniruby. diff --git a/lib/minitest/unit.rb b/lib/minitest/unit.rb index e2fc134bdd..5f2fa5c99e 100644 --- a/lib/minitest/unit.rb +++ b/lib/minitest/unit.rb @@ -119,7 +119,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 @@ -283,7 +283,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 diff --git a/test/minitest/test_mini_test.rb b/test/minitest/test_mini_test.rb index e539ee05c8..046ae66d88 100644 --- a/test/minitest/test_mini_test.rb +++ b/test/minitest/test_mini_test.rb @@ -535,6 +535,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 @@ -866,6 +887,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 |