summaryrefslogtreecommitdiff
path: root/test/minitest/test_mini_test.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-30 09:26:27 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-30 09:26:27 +0000
commit70365e5debc95ca98d5564f196a1b49323758d82 (patch)
tree561662713b62b9c1f7530a1096a4b34c4c5274aa /test/minitest/test_mini_test.rb
parentbf6c750c350b021578c3c446407315c404d6652b (diff)
Imported minitest 1.3.1 r4506.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/minitest/test_mini_test.rb')
-rw-r--r--test/minitest/test_mini_test.rb50
1 files changed, 50 insertions, 0 deletions
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