module Minitest::Assertions
Public Instance Methods
assert_allocations(op_or_exp, exp = nil, msg = nil) { || ... }
click to toggle source
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
# 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