mirror of https://github.com/tc39/test262.git
Some cleanup follow ups (#2351)
This commit is contained in:
parent
1056d8fde9
commit
0fd3cf4d24
|
@ -5,8 +5,6 @@ description: |
|
||||||
Collection of assertion functions used throughout test262
|
Collection of assertion functions used throughout test262
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference lib="esnext" />
|
|
||||||
/// <reference path="./types.d.ts" />
|
|
||||||
|
|
||||||
function assert(mustBeTrue, message) {
|
function assert(mustBeTrue, message) {
|
||||||
if (mustBeTrue === true) {
|
if (mustBeTrue === true) {
|
||||||
|
@ -95,10 +93,10 @@ assert.throws = function (expectedErrorConstructor, func, message) {
|
||||||
$ERROR(message);
|
$ERROR(message);
|
||||||
};
|
};
|
||||||
|
|
||||||
assert._formatValue = function(value, seen) {
|
assert._formatValue = (value, seen) => {
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case 'string':
|
case 'string':
|
||||||
return typeof JSON !== "undefined" ? JSON.stringify(value) : '"' + value + '"';
|
return typeof JSON !== "undefined" ? JSON.stringify(value) : `"${value}"`;
|
||||||
case 'number':
|
case 'number':
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
case 'symbol':
|
case 'symbol':
|
||||||
|
@ -107,10 +105,10 @@ assert._formatValue = function(value, seen) {
|
||||||
case 'undefined':
|
case 'undefined':
|
||||||
return 'undefined';
|
return 'undefined';
|
||||||
case 'function':
|
case 'function':
|
||||||
return '[Function' + (value.name ? ': ' + value.name : '') + ']';
|
return `[Function${value.name ? `: ${value.name}` : ''}]`;
|
||||||
case 'object':
|
case 'object':
|
||||||
if (value === null) return 'null';
|
if (value === null) return 'null';
|
||||||
if (value instanceof Date) return 'Date "' + value.toISOString() + '"';
|
if (value instanceof Date) return `Date "${value.toISOString()}"`;
|
||||||
if (value instanceof RegExp) return value.toString();
|
if (value instanceof RegExp) return value.toString();
|
||||||
if (!seen) {
|
if (!seen) {
|
||||||
seen = {
|
seen = {
|
||||||
|
@ -119,29 +117,29 @@ assert._formatValue = function(value, seen) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var usage = seen.map.get(value);
|
let usage = seen.map.get(value);
|
||||||
if (usage) {
|
if (usage) {
|
||||||
usage.used = true;
|
usage.used = true;
|
||||||
return '[Ref: #' + usage.id + ']';
|
return `[Ref: #${usage.id}]`;
|
||||||
}
|
}
|
||||||
|
|
||||||
usage = { id: ++seen.counter, used: false };
|
usage = { id: ++seen.counter, used: false };
|
||||||
seen.map.set(value, usage);
|
seen.map.set(value, usage);
|
||||||
|
|
||||||
if (typeof Set !== "undefined" && value instanceof Set) {
|
if (typeof Set !== "undefined" && value instanceof Set) {
|
||||||
return 'Set {' + Array.from(value).map(function (value) { return assert._formatValue(value, seen); }).join(', ') + '}' + (usage.used ? ' as #' + usage.id : '');
|
return `Set {${Array.from(value).map(value => assert._formatValue(value, seen)).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`;
|
||||||
}
|
}
|
||||||
if (typeof Map !== "undefined" && value instanceof Map) {
|
if (typeof Map !== "undefined" && value instanceof Map) {
|
||||||
return 'Map {' + Array.from(value).map(function (pair) { return assert._formatValue(pair[0], seen) + ' => ' + assert._formatValue(pair[1], seen) + '}'; }).join(', ') + '}' + (usage.used ? ' as #' + usage.id : '');
|
return `Map {${Array.from(value).map(pair => `${assert._formatValue(pair[0], seen)} => ${assert._formatValue(pair[1], seen)}}`).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`;
|
||||||
}
|
}
|
||||||
if (Array.isArray ? Array.isArray(value) : value instanceof Array) {
|
if (Array.isArray ? Array.isArray(value) : value instanceof Array) {
|
||||||
return '[' + value.map(function (value) { return assert._formatValue(value, seen); }).join(', ') + ']' + (usage.used ? ' as #' + usage.id : '');
|
return `[${value.map(value => assert._formatValue(value, seen)).join(', ')}]${usage.used ? ` as #${usage.id}` : ''}`;
|
||||||
}
|
}
|
||||||
var tag = Symbol.toStringTag in value ? value[Symbol.toStringTag] : 'Object';
|
let tag = Symbol.toStringTag in value ? value[Symbol.toStringTag] : 'Object';
|
||||||
if (tag === 'Object' && Object.getPrototypeOf(value) === null) {
|
if (tag === 'Object' && Object.getPrototypeOf(value) === null) {
|
||||||
tag = '[Object: null prototype]';
|
tag = '[Object: null prototype]';
|
||||||
}
|
}
|
||||||
return (tag ? tag + ' ' : '') + '{ ' + Object.keys(value).map(function (key) { return key.toString() + ': ' + assert._formatValue(value[key], seen); }).join(', ') + ' }' + (usage.used ? ' as #' + usage.id : '');
|
return `${tag ? `${tag} ` : ''}{ ${Object.keys(value).map(key => `${key.toString()}: ${assert._formatValue(value[key], seen)}`).join(', ')} }${usage.used ? ` as #${usage.id}` : ''}`;
|
||||||
default:
|
default:
|
||||||
return typeof value;
|
return typeof value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ description: |
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/// <reference path="./assert.js" />
|
|
||||||
|
|
||||||
function isSameValue(a, b) {
|
function isSameValue(a, b) {
|
||||||
if (a === 0 && b === 0) return 1 / a === 1 / b;
|
if (a === 0 && b === 0) return 1 / a === 1 / b;
|
||||||
|
|
|
@ -6,7 +6,6 @@ description: |
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/// <reference path="./assert.js" />
|
|
||||||
|
|
||||||
var deepEqual = (function () {
|
var deepEqual = (function () {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,6 @@ description: |
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/// <reference path="./assert.js" />
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {object} obj
|
* @param {object} obj
|
||||||
|
|
|
@ -11,8 +11,6 @@ info: |
|
||||||
5. Return CreateArrayFromList(« _match_.[[StartIndex]], _match_.[[EndIndex]] »).
|
5. Return CreateArrayFromList(« _match_.[[StartIndex]], _match_.[[EndIndex]] »).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
|
|
||||||
let input = "abcd";
|
let input = "abcd";
|
||||||
let match = /b(c)/.exec(input);
|
let match = /b(c)/.exec(input);
|
||||||
|
|
|
@ -22,8 +22,6 @@ info: |
|
||||||
...
|
...
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
|
|
||||||
let input = "abcd";
|
let input = "abcd";
|
||||||
let match = /b(c)/.exec(input);
|
let match = /b(c)/.exec(input);
|
||||||
|
|
|
@ -27,10 +27,6 @@ info: |
|
||||||
34. Let _indicesArray_ be MakeIndicesArray( _S_, _indices_, _groupNames_).
|
34. Let _indicesArray_ be MakeIndicesArray( _S_, _indices_, _groupNames_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
/// <reference path="../../../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual([[1, 2], [1, 2]], "bab".match(/(a)/).indices);
|
assert.deepEqual([[1, 2], [1, 2]], "bab".match(/(a)/).indices);
|
||||||
assert.deepEqual([[0, 3], [1, 2]], "bab".match(/.(a)./).indices);
|
assert.deepEqual([[0, 3], [1, 2]], "bab".match(/.(a)./).indices);
|
||||||
|
|
|
@ -12,8 +12,6 @@ info: |
|
||||||
d. Perform ! CreateDataProperty(_A_, ! ToString(_n_), _matchIndicesArray_).
|
d. Perform ! CreateDataProperty(_A_, ! ToString(_n_), _matchIndicesArray_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
|
|
||||||
let input = "abcd";
|
let input = "abcd";
|
||||||
let match = /b(c)/.exec(input);
|
let match = /b(c)/.exec(input);
|
||||||
|
|
|
@ -36,10 +36,6 @@ info: |
|
||||||
5. Return _eUTF_.
|
5. Return _eUTF_.
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
/// <reference path="../../../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual([[1, 2], [1, 2]], "bab".match(/(a)/u).indices);
|
assert.deepEqual([[1, 2], [1, 2]], "bab".match(/(a)/u).indices);
|
||||||
assert.deepEqual([[0, 3], [1, 2]], "bab".match(/.(a)./u).indices);
|
assert.deepEqual([[0, 3], [1, 2]], "bab".match(/.(a)./u).indices);
|
||||||
|
|
|
@ -8,8 +8,6 @@ esid: sec-makeindicesarray
|
||||||
features: [regexp-match-indices]
|
features: [regexp-match-indices]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
|
|
||||||
assert.compareArray([1, 2], /(?<π>a)/u.exec("bab").indices.groups.π);
|
assert.compareArray([1, 2], /(?<π>a)/u.exec("bab").indices.groups.π);
|
||||||
assert.compareArray([1, 2], /(?<\u{03C0}>a)/u.exec("bab").indices.groups.π);
|
assert.compareArray([1, 2], /(?<\u{03C0}>a)/u.exec("bab").indices.groups.π);
|
||||||
|
|
|
@ -21,7 +21,6 @@ info: |
|
||||||
...
|
...
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
|
|
||||||
let input = "abd";
|
let input = "abd";
|
||||||
let match = /b(c)?/.exec(input);
|
let match = /b(c)?/.exec(input);
|
||||||
|
|
|
@ -10,7 +10,6 @@ info: |
|
||||||
6. Set _A_ to ! ArrayCreate(_n_).
|
6. Set _A_ to ! ArrayCreate(_n_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
|
|
||||||
let match = /a/.exec("a");
|
let match = /a/.exec("a");
|
||||||
let indices = match.indices;
|
let indices = match.indices;
|
||||||
|
|
|
@ -15,8 +15,6 @@ info: |
|
||||||
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
|
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
|
|
||||||
const re = /./;
|
const re = /./;
|
||||||
const indices = re.exec("a").indices;
|
const indices = re.exec("a").indices;
|
||||||
|
|
|
@ -13,8 +13,6 @@ info: |
|
||||||
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
|
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
|
|
||||||
const re = /(?<a>a).|(?<x>x)/;
|
const re = /(?<a>a).|(?<x>x)/;
|
||||||
const result = re.exec("ab").indices;
|
const result = re.exec("ab").indices;
|
||||||
|
|
|
@ -15,9 +15,6 @@ info: |
|
||||||
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
|
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
|
|
||||||
// `groups` is created with Define, not Set.
|
// `groups` is created with Define, not Set.
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
|
@ -13,9 +13,6 @@ info: |
|
||||||
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
|
i. Perform ! CreateDataProperty(_groups_, _groupNames_[_i_], _matchIndicesArray_).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/compareArray.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
|
|
||||||
// Properties created on result.groups in textual order.
|
// Properties created on result.groups in textual order.
|
||||||
let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/u.exec("abcd").indices.groups);
|
let groupNames = Object.getOwnPropertyNames(/(?<fst>.)|(?<snd>.)/u.exec("abcd").indices.groups);
|
||||||
|
|
|
@ -12,8 +12,6 @@ info: |
|
||||||
35. Perform ! DefinePropertyOrThrow(_A_, `"indices"`, PropertyDescriptor { [[Value]]: _indicesArray_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }).
|
35. Perform ! DefinePropertyOrThrow(_A_, `"indices"`, PropertyDescriptor { [[Value]]: _indicesArray_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }).
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../../../harness/assert.js" />
|
|
||||||
/// <reference path="../../../../harness/propertyHelper.js" />
|
|
||||||
|
|
||||||
// `indices` is created with Define, not Set.
|
// `indices` is created with Define, not Set.
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual([], []);
|
assert.deepEqual([], []);
|
||||||
assert.deepEqual([1, "a", true], [1, "a", true]);
|
assert.deepEqual([1, "a", true], [1, "a", true]);
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
var a = { x: 1 };
|
var a = { x: 1 };
|
||||||
var b = { x: 1 };
|
var b = { x: 1 };
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual({ a: { x: 1 }, b: [true] }, { a: { x: 1 }, b: [true] });
|
assert.deepEqual({ a: { x: 1 }, b: [true] }, { a: { x: 1 }, b: [true] });
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual(new Set(), new Set());
|
assert.deepEqual(new Set(), new Set());
|
||||||
assert.deepEqual(new Set([1, "a", true]), new Set([1, "a", true]));
|
assert.deepEqual(new Set([1, "a", true]), new Set([1, "a", true]));
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
assert.deepEqual({}, {});
|
assert.deepEqual({}, {});
|
||||||
assert.deepEqual({ a: 1, b: true }, { a: 1, b: true });
|
assert.deepEqual({ a: 1, b: true }, { a: 1, b: true });
|
||||||
|
|
|
@ -7,8 +7,6 @@ description: >
|
||||||
includes: [deepEqual.js]
|
includes: [deepEqual.js]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
/// <reference path="../../harness/assert.js" />
|
|
||||||
/// <reference path="../../harness/deepEqual.js" />
|
|
||||||
|
|
||||||
var s1 = Symbol();
|
var s1 = Symbol();
|
||||||
var s2 = Symbol();
|
var s2 = Symbol();
|
||||||
|
|
Loading…
Reference in New Issue