Module: Minitest::Assertions
- Defined in:
- lib/minitest/gcstats.rb
Instance Method Summary collapse
-
#assert_allocations(op_or_exp, exp = nil, msg = nil) ⇒ Object
Assert that the number of object allocations during block execution is what you think it is.
Instance Method Details
#assert_allocations(op_or_exp, exp = nil, msg = nil) ⇒ Object
Assert that the number of object allocations during block execution is what you think it is. Uses assert_operator so op should be something like :== or :<=. Defaults to :==.
assert_allocations 3 do ... end
is equivalent to:
assert_allocations :==, 3 do ... end
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/minitest/gcstats.rb', line 60 def assert_allocations op_or_exp, exp = nil, msg = nil m0 = Minitest::GCStats.current yield m1 = Minitest::GCStats.current op = op_or_exp op, exp, msg = :==, op, exp if Integer === op act = m1 - m0 msg ||= "Object allocations" assert_operator act, op, exp, msg end |