Merge pull request #1221 from rwaldron/thejoshwolfe-type-coercion

type coercion harness utilities + features flags + linting
This commit is contained in:
Leo Balter 2017-09-11 14:54:08 -04:00 committed by GitHub
commit b8ca6099cf
845 changed files with 1300 additions and 278 deletions

View File

@ -51,6 +51,7 @@ regexp-unicode-property-escapes
# Shared Memory and atomics
# https://github.com/tc39/ecmascript_sharedmem
Atomics
SharedArrayBuffer
# Standard language features
@ -80,6 +81,7 @@ DataView.prototype.setUint8
default-arg
default-parameters
destructuring-binding
for-of
Float64Array
generators
Int8Array

View File

@ -88,8 +88,8 @@ assert.throws = function (expectedErrorConstructor, func, message) {
};
assert.throws.early = function(err, code) {
let wrappedCode = `function wrapperFn() { ${code} }`;
let wrappedCode = 'function wrapperFn() { ' + code + ' }';
let ieval = eval;
assert.throws(err, function() { Function(wrappedCode); }, `Function: ${code}`);
assert.throws(err, function() { Function(wrappedCode); }, 'Function: ' + code);
};

View File

@ -20,5 +20,5 @@ function compareArray(a, b) {
assert.compareArray = function(actual, expected, message) {
assert(compareArray(actual, expected),
`Expected [${actual.join(", ")}] and [${expected.join(", ")}] to have the same contents. ${message}`);
'Expected [' + actual.join(', ') + '] and [' + expected.join(', ') + '] to have the same contents. ' + message);
};

3
harness/features.yml Normal file
View File

@ -0,0 +1,3 @@
typeCoercion.js: [Symbol.toPrimitive, BigInt]
testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, arrow-function, let, for-of]
testTypedArray.js: [TypedArray]

View File

@ -20,7 +20,7 @@ function verifyProperty(obj, name, desc, options) {
assert.sameValue(
originalDesc,
undefined,
`obj['${nameStr}'] descriptor should be undefined`
"obj['" + nameStr + "'] descriptor should be undefined"
);
// desc and originalDesc are both undefined, problem solved;
@ -29,47 +29,47 @@ function verifyProperty(obj, name, desc, options) {
assert(
Object.prototype.hasOwnProperty.call(obj, name),
`obj should have an own property ${nameStr}`
"obj should have an own property " + nameStr
);
assert.notSameValue(
desc,
null,
`The desc argument should be an object or undefined, null`
"The desc argument should be an object or undefined, null"
);
assert.sameValue(
typeof desc,
"object",
`The desc argument should be an object or undefined, ${String(desc)}`
"The desc argument should be an object or undefined, " + String(desc)
);
var failures = [];
if (Object.prototype.hasOwnProperty.call(desc, 'value')) {
if (desc.value !== originalDesc.value) {
failures.push(`descriptor value should be ${desc.value}`);
failures.push("descriptor value should be " + desc.value);
}
}
if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) {
if (desc.enumerable !== originalDesc.enumerable ||
desc.enumerable !== isEnumerable(obj, name)) {
failures.push(`descriptor should ${desc.enumerable ? '' : 'not '}be enumerable`);
failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable');
}
}
if (Object.prototype.hasOwnProperty.call(desc, 'writable')) {
if (desc.writable !== originalDesc.writable ||
desc.writable !== isWritable(obj, name)) {
failures.push(`descriptor should ${desc.writable ? '' : 'not '}be writable`);
failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable');
}
}
if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) {
if (desc.configurable !== originalDesc.configurable ||
desc.configurable !== isConfigurable(obj, name)) {
failures.push(`descriptor should ${desc.configurable ? '' : 'not '}be configurable`);
failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable');
}
}

285
harness/typeCoercion.js Normal file
View File

@ -0,0 +1,285 @@
// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
Functions to help generate test cases for testing type coercion abstract
operations like ToNumber.
---*/
function testCoercibleToIntegerZero(test) {
testCoercibleToNumberZero(test);
testCoercibleToIntegerFromInteger(0, test);
// NaN -> +0
testCoercibleToNumberNan(test);
// When toString() returns a string that parses to NaN:
test({});
test([]);
}
function testCoercibleToIntegerOne(test) {
testCoercibleToNumberOne(test);
testCoercibleToIntegerFromInteger(1, test);
// When toString() returns "1"
test([1]);
test(["1"]);
}
function testCoercibleToNumberZero(test) {
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
}
testPrimitiveValue(null);
testPrimitiveValue(false);
testPrimitiveValue(0);
testPrimitiveValue("0");
}
function testCoercibleToNumberNan(test) {
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
}
testPrimitiveValue(undefined);
testPrimitiveValue(NaN);
testPrimitiveValue("");
testPrimitiveValue("foo");
testPrimitiveValue("true");
}
function testCoercibleToNumberOne(test) {
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
}
testPrimitiveValue(true);
testPrimitiveValue(1);
testPrimitiveValue("1");
}
function testCoercibleToIntegerFromInteger(nominalInteger, test) {
assert(Number.isInteger(nominalInteger));
function testPrimitiveValue(value) {
test(value);
// ToPrimitive
testPrimitiveWrappers(value, "number", test);
// Non-primitive values that coerce to the nominal integer:
// toString() returns a string that parsers to a primitive value.
test([value]);
}
function testPrimitiveNumber(number) {
testPrimitiveValue(number);
// ToNumber: String -> Number
testPrimitiveValue(number.toString());
}
testPrimitiveNumber(nominalInteger);
// ToInteger: floor(abs(number))
if (nominalInteger >= 0) {
testPrimitiveNumber(nominalInteger + 0.9);
}
if (nominalInteger <= 0) {
testPrimitiveNumber(nominalInteger - 0.9);
}
}
function testPrimitiveWrappers(primitiveValue, hint, test) {
if (primitiveValue != null) {
// null and undefined result in {} rather than a proper wrapper,
// so skip this case for those values.
test(Object(primitiveValue));
}
testCoercibleToPrimitiveWithMethod(hint, function() {
return primitiveValue;
}, test);
}
function testCoercibleToPrimitiveWithMethod(hint, method, test) {
var methodNames;
if (hint === "number") {
methodNames = ["valueOf", "toString"];
} else if (hint === "string") {
methodNames = ["toString", "valueOf"];
} else {
throw new Test262Error();
}
// precedence order
test({
[Symbol.toPrimitive]: method,
[methodNames[0]]: function() { throw new Test262Error(); },
[methodNames[1]]: function() { throw new Test262Error(); },
});
test({
[methodNames[0]]: method,
[methodNames[1]]: function() { throw new Test262Error(); },
});
if (hint === "number") {
// The default valueOf returns an object, which is unsuitable.
// The default toString returns a String, which is suitable.
// Therefore this test only works for valueOf falling back to toString.
test({
// this is toString:
[methodNames[1]]: method,
});
}
// GetMethod: if func is undefined or null, return undefined.
test({
[Symbol.toPrimitive]: undefined,
[methodNames[0]]: method,
[methodNames[1]]: method,
});
test({
[Symbol.toPrimitive]: null,
[methodNames[0]]: method,
[methodNames[1]]: method,
});
// if methodNames[0] is not callable, fallback to methodNames[1]
test({
[methodNames[0]]: null,
[methodNames[1]]: method,
});
test({
[methodNames[0]]: 1,
[methodNames[1]]: method,
});
test({
[methodNames[0]]: {},
[methodNames[1]]: method,
});
// if methodNames[0] returns an object, fallback to methodNames[1]
test({
[methodNames[0]]: function() { return {}; },
[methodNames[1]]: method,
});
test({
[methodNames[0]]: function() { return Object(1); },
[methodNames[1]]: method,
});
}
function testNotCoercibleToInteger(test) {
// ToInteger only throws from ToNumber.
return testNotCoercibleToNumber(test);
}
function testNotCoercibleToNumber(test) {
function testPrimitiveValue(value) {
test(TypeError, value);
// ToPrimitive
testPrimitiveWrappers(value, "number", function(value) {
test(TypeError, value);
});
}
// ToNumber: Symbol -> TypeError
testPrimitiveValue(Symbol("1"));
if (typeof BigInt !== "undefined") {
// ToNumber: BigInt -> TypeError
testPrimitiveValue(BigInt(0));
}
// ToPrimitive
testNotCoercibleToPrimitive("number", test);
}
function testNotCoercibleToPrimitive(hint, test) {
function MyError() {}
// ToPrimitive: input[@@toPrimitive] is not callable (and non-null)
test(TypeError, {[Symbol.toPrimitive]: 1});
test(TypeError, {[Symbol.toPrimitive]: {}});
// ToPrimitive: input[@@toPrimitive] returns object
test(TypeError, {[Symbol.toPrimitive]: function() { return Object(1); }});
test(TypeError, {[Symbol.toPrimitive]: function() { return {}; }});
// ToPrimitive: input[@@toPrimitive] throws
test(MyError, {[Symbol.toPrimitive]: function() { throw new MyError(); }});
// OrdinaryToPrimitive: method throws
testCoercibleToPrimitiveWithMethod(hint, function() {
throw new MyError();
}, function(value) {
test(MyError, value);
});
// OrdinaryToPrimitive: both methods are unsuitable
function testUnsuitableMethod(method) {
test(TypeError, {valueOf:method, toString:method});
}
// not callable:
testUnsuitableMethod(null);
testUnsuitableMethod(1);
testUnsuitableMethod({});
// returns object:
testUnsuitableMethod(function() { return Object(1); });
testUnsuitableMethod(function() { return {}; });
}
function testCoercibleToString(test) {
function testPrimitiveValue(value, expectedString) {
test(value, expectedString);
// ToPrimitive
testPrimitiveWrappers(value, "string", function(value) {
test(value, expectedString);
});
}
testPrimitiveValue(undefined, "undefined");
testPrimitiveValue(null, "null");
testPrimitiveValue(true, "true");
testPrimitiveValue(false, "false");
testPrimitiveValue(0, "0");
testPrimitiveValue(-0, "0");
testPrimitiveValue(Infinity, "Infinity");
testPrimitiveValue(-Infinity, "-Infinity");
testPrimitiveValue(123.456, "123.456");
testPrimitiveValue(-123.456, "-123.456");
testPrimitiveValue("", "");
testPrimitiveValue("foo", "foo");
if (typeof BigInt !== "undefined") {
// BigInt -> TypeError
testPrimitiveValue(BigInt(0), "0");
}
// toString of a few objects
test([], "");
test(["foo", "bar"], "foo,bar");
test({}, "[object Object]");
}
function testNotCoercibleToString(test) {
function testPrimitiveValue(value) {
test(TypeError, value);
// ToPrimitive
testPrimitiveWrappers(value, "string", function(value) {
test(TypeError, value);
});
}
// Symbol -> TypeError
testPrimitiveValue(Symbol("1"));
// ToPrimitive
testNotCoercibleToPrimitive("string", test);
}

View File

@ -10,6 +10,7 @@ info: >
8. If _a_ has a [[TypedArrayName]] internal slot, then
a. If IsDetachedBuffer(_a_.[[ViewedArrayBuffer]]) is *true*, throw a *TypeError* exception.
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(TA => {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.add
description: >
Test range checking of Atomics.add on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.add
description: Test Atomics.add on arrays that allow atomic operations.
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.add
description: >
Test Atomics.add on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.add
description: >
Test Atomics.add on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.add
description: >
Test Atomics.add on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.and
description: >
Test range checking of Atomics.and on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.and
description: Test Atomics.and on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.and
description: >
Test Atomics.and on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.and
description: >
Test Atomics.and on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.and
description: >
Test Atomics.and on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.compareexchange
description: >
Test range checking of Atomics.compareExchange on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.compareexchange
description: Test Atomics.compareExchange on arrays that allow atomic operations.
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.exchange
description: >
Test range checking of Atomics.exchange on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.exchange
description: Test Atomics.exchange on arrays that allow atomic operations.
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.exchange
description: >
Test Atomics.exchange on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.exchange
description: >
Test Atomics.exchange on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.exchange
description: >
Test Atomics.exchange on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.load
description: >
Test range checking of Atomics.load on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.load
description: Test Atomics.load on arrays that allow atomic operations.
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.load
description: >
Test Atomics.load on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.load
description: >
Test Atomics.load on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.load
description: >
Test Atomics.load on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.or
description: >
Test range checking of Atomics.or on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.or
description: Test Atomics.or on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.or
description: >
Test Atomics.or on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.or
description: >
Test Atomics.or on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.or
description: >
Test Atomics.or on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.store
description: >
Test range checking of Atomics.store on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.store
description: Test Atomics.store on arrays that allow atomic operations.
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.store
description: >
Test Atomics.store on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.store
description: >
Test Atomics.store on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.store
description: >
Test Atomics.store on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.sub
description: >
Test range checking of Atomics.sub on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.sub
description: Test Atomics.sub on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.sub
description: >
Test Atomics.sub on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.sub
description: >
Test Atomics.sub on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.sub
description: >
Test Atomics.sub on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test range checking of Atomics.wait on arrays that allow atomic operations
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test Atomics.wait on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test Atomics.wait on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wait
description: >
Test Atomics.wait on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wake
description: >
Test range checking of Atomics.wake on arrays that allow atomic operations
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -7,6 +7,7 @@ description: >
Test Atomics.wait on arrays that allow atomic operations,
in an Agent that is allowed to wait. There is only the one Agent.
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wake
description: >
Test Atomics.wake on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wake
description: >
Test Atomics.wake on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.wake
description: >
Test Atomics.wake on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.xor
description: >
Test range checking of Atomics.xor on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(4);

View File

@ -5,6 +5,7 @@
esid: sec-atomics.xor
description: Test Atomics.xor on arrays that allow atomic operations
includes: [testAtomics.js, testTypedArray.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, TypedArray, for-of]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.xor
description: >
Test Atomics.xor on view values other than TypedArrays
includes: [testAtomics.js]
features: [SharedArrayBuffer, ArrayBuffer, DataView, Atomics, arrow-function, let, for-of]
---*/
testWithAtomicsNonViewValues(function(view) {

View File

@ -6,6 +6,7 @@ esid: sec-atomics.xor
description: >
Test Atomics.xor on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var ab = new ArrayBuffer(16);

View File

@ -6,6 +6,7 @@ esid: sec-atomics.xor
description: >
Test Atomics.xor on shared non-integer TypedArrays
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var sab = new SharedArrayBuffer(1024);

View File

@ -0,0 +1,29 @@
// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.indexof
description: String.prototype.indexOf type coercion for position parameter
info: >
String.prototype.indexOf ( searchString [ , position ] )
4. Let pos be ? ToInteger(position).
includes: [typeCoercion.js]
features: [BigInt, Symbol.toPrimitive]
---*/
testCoercibleToIntegerZero(function(zero) {
assert.sameValue("aaaa".indexOf("aa", zero), 0);
});
testCoercibleToIntegerOne(function(one) {
assert.sameValue("aaaa".indexOf("aa", one), 1);
});
testCoercibleToIntegerFromInteger(2, function(two) {
assert.sameValue("aaaa".indexOf("aa", two), 2);
});
testNotCoercibleToInteger(function(error, value) {
assert.throws(error, function() { "".indexOf("", value); });
});

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.indexof
description: String.prototype.indexOf type coercion for searchString parameter
info: >
String.prototype.indexOf ( searchString [ , position ] )
3. Let searchStr be ? ToString(searchString).
includes: [typeCoercion.js]
features: [Symbol.toPrimitive, BigInt]
---*/
testCoercibleToString(function(value, expectedString) {
if (expectedString.length === 0) {
assert.sameValue(("x_x_x").indexOf(value), 0);
} else {
assert.sameValue(expectedString.indexOf("\x00"), -1, "sanity check");
assert.sameValue(("\x00\x00" + expectedString + "\x00\x00").indexOf(value), 2);
}
});
testNotCoercibleToString(function(error, value) {
assert.throws(error, function() { "".indexOf(value); });
});

View File

@ -9,8 +9,8 @@ info: >
%TypedArray%[@@species] is an accessor property whose set accessor function
is undefined.
features: [Symbol.species]
includes: [testTypedArray.js]
features: [Symbol.species, TypedArray]
---*/
var desc = Object.getOwnPropertyDescriptor(TypedArray, Symbol.species);

View File

@ -8,8 +8,8 @@ info: >
22.2.2.4 get %TypedArray% [ @@species ]
1. Return the this value.
features: [Symbol.species]
includes: [testTypedArray.js]
features: [Symbol.species, TypedArray]
---*/
var value = {};

View File

@ -10,6 +10,7 @@ info: >
7. Let len be ? ToLength(? Get(arrayLike, "length")).
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var arrayLike = {};

View File

@ -10,6 +10,7 @@ info: >
7. Let len be ? ToLength(? Get(arrayLike, "length")).
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var arrayLike = { length: {} };

View File

@ -11,6 +11,7 @@ info: >
2. If IsConstructor(C) is false, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var from = TypedArray.from;

View File

@ -16,6 +16,7 @@ info: >
1. Let newTypedArray be ? Construct(constructor, argumentList).
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
assert.throws(TypeError, function() {

View File

@ -14,8 +14,8 @@ info: >
1. Let usingIterator be ? GetMethod(items, @@iterator).
...
features: [Symbol.iterator]
includes: [testTypedArray.js]
features: [Symbol.iterator, TypedArray]
---*/
var iter = {};

View File

@ -16,8 +16,8 @@ info: >
2. If usingIterator is not undefined, then
a. Let iterator be ? GetIterator(items, usingIterator).
...
features: [Symbol.iterator]
includes: [testTypedArray.js]
features: [Symbol.iterator, TypedArray]
---*/
var iter = {};

View File

@ -11,8 +11,8 @@ info: >
d. Repeat, while next is not false
i. Let next be ? IteratorStep(iterator).
...
features: [Symbol.iterator]
includes: [testTypedArray.js]
features: [Symbol.iterator, TypedArray]
---*/
var iter = {};

View File

@ -13,8 +13,8 @@ info: >
ii. If next is not false, then
1. Let nextValue be ? IteratorValue(next).
...
features: [Symbol.iterator]
includes: [testTypedArray.js]
features: [Symbol.iterator, TypedArray]
---*/
var iter = {};

View File

@ -11,7 +11,7 @@ info: >
a. If IsCallable(mapfn) is false, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [Symbol, Symbol.iterator]
features: [Symbol, Symbol.iterator, TypedArray]
---*/
var getIterator = 0;

View File

@ -11,6 +11,7 @@ info: >
2. If IsConstructor(C) is false, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var from = TypedArray.from;

View File

@ -12,6 +12,7 @@ info: >
Note: ES2016 replaces all the references for the %TypedArray% constructor to a
single chapter covering all arguments cases.
includes: [testTypedArray.js]
features: [TypedArray]
---*/
assert.throws(TypeError, function() {

View File

@ -12,6 +12,7 @@ info: >
4. If IsConstructor(C) is false, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var of = TypedArray.of;

View File

@ -16,6 +16,7 @@ info: >
1. Let newTypedArray be ? Construct(constructor, argumentList).
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
assert.throws(TypeError, function() {

View File

@ -12,6 +12,7 @@ info: >
4. If IsConstructor(C) is false, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var m = { m() {} }.m;

View File

@ -11,7 +11,7 @@ info: >
5. Assert: name is a String value.
6. Return name.
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [Symbol.toStringTag]
features: [Symbol.toStringTag, TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -11,8 +11,8 @@ info: >
...
3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
...
features: [Symbol.toStringTag]
includes: [testTypedArray.js]
features: [Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -9,8 +9,8 @@ info: >
1. Let O be the this value.
2. If Type(O) is not Object, return undefined.
...
features: [Symbol.toStringTag]
includes: [testTypedArray.js]
features: [Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -12,7 +12,7 @@ info: >
5. Assert: name is a String value.
6. Return name.
includes: [testTypedArray.js]
features: [Symbol.toStringTag]
features: [Symbol.toStringTag, TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -12,7 +12,7 @@ info: >
3. If O does not have a [[TypedArrayName]] internal slot, return undefined.
...
includes: [testTypedArray.js]
features: [Symbol.toStringTag, DataView]
features: [Symbol.toStringTag, DataView, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -10,7 +10,7 @@ info: >
2. If Type(O) is not Object, return undefined.
...
includes: [testTypedArray.js]
features: [Symbol, Symbol.toStringTag]
features: [Symbol, Symbol.toStringTag, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -10,6 +10,7 @@ info: >
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. Return buffer.
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -13,6 +13,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -12,6 +12,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -11,6 +11,7 @@ info: >
4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot.
5. Return buffer.
includes: [testTypedArray.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -15,7 +15,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [DataView]
features: [DataView, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -10,7 +10,7 @@ info: >
2. If Type(O) is not Object, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [Symbol]
features: [Symbol, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -11,6 +11,7 @@ info: >
5. If IsDetachedBuffer(buffer) is true, return 0.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -13,6 +13,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -12,6 +12,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -11,6 +11,7 @@ info: >
6. Let size be the value of O's [[ByteLength]] internal slot.
7. Return size.
includes: [testTypedArray.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -15,7 +15,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [DataView]
features: [DataView, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -10,7 +10,7 @@ info: >
2. If Type(O) is not Object, throw a TypeError exception.
...
includes: [testTypedArray.js]
features: [Symbol]
features: [Symbol, TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -11,6 +11,7 @@ info: >
5. If IsDetachedBuffer(buffer) is true, return 0.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {

View File

@ -13,6 +13,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

View File

@ -12,6 +12,7 @@ info: >
exception.
...
includes: [testTypedArray.js]
features: [TypedArray]
---*/
var TypedArrayPrototype = TypedArray.prototype;

Some files were not shown because too many files have changed in this diff Show More