mirror of https://github.com/tc39/test262.git
fix: ensure that assert.compareArray doesn't iterate and evaluate actual and expected more than once, unless absolutely necessary.
This commit is contained in:
parent
1feafce8ce
commit
a81a2a2b1f
|
@ -35,8 +35,11 @@ assert.compareArray = function(actual, expected, message) {
|
|||
assert(actual != null, `First argument shouldn't be nullish. ${message}`);
|
||||
assert(expected != null, `Second argument shouldn't be nullish. ${message}`);
|
||||
var format = compareArray.format;
|
||||
assert(
|
||||
compareArray(actual, expected),
|
||||
`Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`
|
||||
);
|
||||
var result = compareArray(actual, expected);
|
||||
|
||||
// The following prevents actual and expected from being iterated and evaluated
|
||||
// more than once unless absolutely necessary.
|
||||
if (!result) {
|
||||
assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue