Skip to content

Commit

Permalink
Infra: make assert_array_equals more useful
Browse files Browse the repository at this point in the history
Fixes part of #7179.
  • Loading branch information
annevk authored and jgraham committed Jan 9, 2020
1 parent 0b7d1a4 commit af915c8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions resources/testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,19 +1184,21 @@ policies and contribution forms [3].
{actual:actual});
assert(actual.length === expected.length,
"assert_array_equals", description,
"lengths differ, expected ${expected} got ${actual}",
{expected:expected.length, actual:actual.length});
"lengths differ, expected array ${expected} got ${actual}",
{expected:expected, actual:actual});

for (var i = 0; i < actual.length; i++) {
assert(actual.hasOwnProperty(i) === expected.hasOwnProperty(i),
"assert_array_equals", description,
"property ${i}, property expected to be ${expected} but was ${actual}",
"expected property ${i} to be ${expected} but was ${actual} (expected array ${arrayExpected} got ${arrayActual})",
{i:i, expected:expected.hasOwnProperty(i) ? "present" : "missing",
actual:actual.hasOwnProperty(i) ? "present" : "missing"});
actual:actual.hasOwnProperty(i) ? "present" : "missing", arrayExpected:expected,
arrayActual:actual});
assert(same_value(expected[i], actual[i]),
"assert_array_equals", description,
"property ${i}, expected ${expected} but got ${actual}",
{i:i, expected:expected[i], actual:actual[i]});
"expected property ${i} to be ${expected} but got ${actual} (expected array ${arrayExpected} got ${arrayActual})",
{i:i, expected:expected[i], actual:actual[i], arrayExpected:expected,
arrayActual:actual});
}
}
expose(assert_array_equals, "assert_array_equals");
Expand Down

0 comments on commit af915c8

Please sign in to comment.