Module: MiniTest::Unit::Unordered
- Included in:
- TestCase
- Defined in:
- lib/minitest/unordered.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Method Summary collapse
-
#assert_equal_unordered(a, b, msg = nil) ⇒ Object
Fails unless
acontains the same contents asb, regardless of order.
Instance Method Details
#assert_equal_unordered(a, b, msg = nil) ⇒ Object
Fails unless a contains the same contents as b, regardless of order.
assert_equal_unordered %w[a a b c], %w[a b c a] # pass
NOTE: This uses Hash#== to determine collection equivalence, as such, do not expect it to behave the same as assert_equal.
assert_equal [1], [1.0] # pass
assert_equal({ 1 => true }, { 1.0 => true }) # fail
assert_equal_unordered [1], [1.0] # fail
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/minitest/unordered.rb', line 20 def assert_equal_unordered a, b, msg = nil msg = (msg) { "Expected #{mu_pp a} to be equivalent to #{mu_pp b}" } assert_kind_of Enumerable, a assert_kind_of Enumerable, b c = Hash.new { |h,k| h[k] = 0 }; a.each do |e| c[e] += 1 end d = Hash.new { |h,k| h[k] = 0 }; b.each do |e| d[e] += 1 end assert c == d, msg end |