mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 23:14:47 +02:00
Create an assert.compareArray
This is a convenience function which tries to make tests easier to read and write.
This commit is contained in:
parent
bfc9020d51
commit
8cb7f59395
@ -13,3 +13,17 @@ function compareArray(a, b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert.compareArray = function(actual, expected, message) {
|
||||||
|
if (compareArray(actual, expected)) return;
|
||||||
|
|
||||||
|
|
||||||
|
if (message === undefined) {
|
||||||
|
message = '';
|
||||||
|
} else {
|
||||||
|
message += ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
message += 'Expected SameValue(«' + String(actual) + '», «' + String(expected) + '») to be true';
|
||||||
|
|
||||||
|
$ERROR(`${message}${message === undefined ? '' : ' '}Expected the arrays [${actual}] to have the same contents as [${expected}]`);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user