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
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/minitest/gcstats.rb', line 50 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 |