mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-01 09:31:20 +08:00
add be_close matcher + TOLERANCE constant
This commit is contained in:
@@ -181,6 +181,17 @@ class Object
|
||||
end
|
||||
end
|
||||
|
||||
TOLERANCE = 0.00003
|
||||
def be_close(expected, tolerance)
|
||||
lambda do |obj, res|
|
||||
if ((obj - expected).abs < tolerance) != res
|
||||
puts "Expectation failed (expected `#{obj}' to be within #{expected} of tolerance #{tolerance}')"
|
||||
$expectations_failures += 1
|
||||
end
|
||||
$expectations_total += 1
|
||||
end
|
||||
end
|
||||
|
||||
def mock(obj)
|
||||
# XXX we probably should be smarter here.
|
||||
obj
|
||||
|
||||
Reference in New Issue
Block a user