summaryrefslogtreecommitdiffhomepage
path: root/test/assert.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-06-16 04:42:58 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2013-06-16 04:42:58 -0700
commitd60362b38bad741a03f03c9a25b6694286c44211 (patch)
treedecde0f21c76dbb5a686d9874dc27886215b55c5 /test/assert.rb
parent8dcbf5e4ac09b23b02ca76d727a91136c3a7b3cd (diff)
parent1a6731fbdeb2642d95aeeddc2e8bee5a288d5f2e (diff)
downloadmruby-d60362b38bad741a03f03c9a25b6694286c44211.tar.gz
mruby-d60362b38bad741a03f03c9a25b6694286c44211.zip
Merge pull request #1284 from Bovi-Li/improve-test-2
Improve Test Infrastructure (Part 2)
Diffstat (limited to 'test/assert.rb')
-rw-r--r--test/assert.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/assert.rb b/test/assert.rb
index 6d727e889..dc282925f 100644
--- a/test/assert.rb
+++ b/test/assert.rb
@@ -99,13 +99,25 @@ def assert_false(ret, msg = nil, diff = nil)
!ret
end
-def assert_equal(exp, act, msg = nil)
+def assert_equal(arg1, arg2 = nil, arg3 = nil)
+ if block_given?
+ exp, act, msg = yield, arg1, arg2
+ else
+ exp, act, msg = arg1, arg2, arg3
+ end
+
msg = "Expected to be equal" unless msg
diff = assertion_diff(exp, act)
assert_true(exp == act, msg, diff)
end
-def assert_not_equal(exp, act, msg = nil)
+def assert_not_equal(arg1, arg2 = nil, arg3 = nil)
+ if block_given?
+ exp, act, msg = yield, arg1, arg2
+ else
+ exp, act, msg = arg1, arg2, arg3
+ end
+
msg = "Expected to be not equal" unless msg
diff = assertion_diff(exp, act)
assert_false(exp == act, msg, diff)
@@ -170,6 +182,14 @@ def assert_kind_of(cls, obj, msg = nil)
end
##
+# Fails unless +exp+ is equal to +act+ in terms of a Float
+def assert_float(exp, act, msg = nil)
+ msg = "Float #{exp} expected to be equal to float #{act}" unless msg
+ diff = assertion_diff(exp, act)
+ assert_true check_float(exp, act), msg, diff
+end
+
+##
# Report the test result and print all assertions
# which were reported broken.
def report()