mirror of https://github.com/tc39/test262.git
Format symbols
This commit is contained in:
parent
c674362d1a
commit
127c896cf2
|
@ -26,6 +26,10 @@ function compareArray(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.compareArray = function(actual, expected, message) {
|
assert.compareArray = function(actual, expected, message) {
|
||||||
|
function formatArray(array) {
|
||||||
|
return '[' + array.map(String).join(', ') + ']';
|
||||||
|
}
|
||||||
|
|
||||||
assert(compareArray(actual, expected),
|
assert(compareArray(actual, expected),
|
||||||
'Expected [' + actual.join(', ') + '] and [' + expected.join(', ') + '] to have the same contents. ' + message);
|
'Expected ' + formatArray(actual) + ' and ' + formatArray(expected) + ' to have the same contents. ' + message);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
description: >
|
||||||
|
compareArray correctly formats Symbols in error message.
|
||||||
|
includes: [compareArray.js]
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var threw = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
assert.compareArray([Symbol()], [Symbol('desc')]);
|
||||||
|
} catch (err) {
|
||||||
|
threw = true;
|
||||||
|
|
||||||
|
assert.sameValue(err.constructor, Test262Error);
|
||||||
|
assert(err.message.indexOf('[Symbol()]') !== -1);
|
||||||
|
assert(err.message.indexOf('[Symbol(desc)]') !== -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(threw);
|
Loading…
Reference in New Issue