Bug 1648757 - Part 3: Update test262 June 2020. r=yulia

Differential Revision: https://phabricator.services.mozilla.com/D81358
This commit is contained in:
André Bargull 2020-06-29 10:02:52 +00:00
Родитель 24c6595fd2
Коммит 612dc507cb
1109 изменённых файлов: 17417 добавлений и 3068 удалений

Просмотреть файл

@ -1,5 +1,8 @@
commit 4a8e49b3ca7f9f74a4cafe6621ff9ba548ccc353
Author: Alexey Shvayka <shvaikalesh@gmail.com>
Date: Sat Apr 11 01:41:59 2020 +0300
commit b5650d23a55d32f95a3d59b55b53b8e613aa545f
Author: André Bargull <andre.bargull@gmail.com>
Date: Thu Jun 25 08:35:46 2020 -0700
Add test for \0 in Unicode patterns (#2569)
Don't call $DONE twice in S25.4.4_A2.1_T3.js (#2679)
Reverts the change from 040eb5393a6c3e854a7ab5e86b54f3dac841162e to avoid
calling $DONE twice in the test file.

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.from
description: >
[[IsHTMLDDA]] object as @@iterator method gets called.
info: |
Array.from ( items [ , mapfn [ , thisArg ] ] )
[...]
4. Let usingIterator be ? GetMethod(items, @@iterator).
5. If usingIterator is not undefined, then
[...]
c. Let iteratorRecord be ? GetIterator(items, sync, usingIterator).
GetIterator ( obj [ , hint [ , method ] ] )
[...]
4. Let iterator be ? Call(method, obj).
5. If Type(iterator) is not Object, throw a TypeError exception.
features: [Symbol.iterator, IsHTMLDDA]
---*/
var items = {};
items[Symbol.iterator] = $262.IsHTMLDDA;
assert.throws(TypeError, function() {
Array.from(items);
});
reportCompare(0, 0);

Просмотреть файл

@ -4,24 +4,21 @@
/*---
esid: sec-createdynamicfunction
description: >
Function parses the body text before forming the sourceText with the proper line feed.
Function body is wrapped with new lines before being parsed
info: |
The HTMLCloseComment requires a preceding line terminator.
Runtime Semantics: CreateDynamicFunction(constructor, newTarget, kind, args)
...
16. Set bodyText to ? ToString(bodyText).
17. Let parameters be the result of parsing P, interpreted as UTF-16 encoded Unicode text as
Set bodyText to ? ToString(bodyText).
Let parameters be the result of parsing P, interpreted as UTF-16 encoded Unicode text as
described in 6.1.4, using parameterGoal as the goal symbol. Throw a SyntaxError exception if the
parse fails.
18. Let body be the result of parsing bodyText, interpreted as UTF-16 encoded Unicode text as
Let body be the result of parsing bodyText, interpreted as UTF-16 encoded Unicode text as
described in 6.1.4, using goal as the goal symbol. Throw a SyntaxError exception if the parse
fails.
...
41. Let sourceText be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED),
") {", 0x000A (LINE FEED), bodyText, 0x000A (LINE FEED), and "}".
---*/
assert.throws(SyntaxError, () => Function("-->"));
Function("-->");
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,33 @@
// GENERATED, DO NOT EDIT
// file: proxyTrapsHelper.js
// Copyright (C) 2016 Jordan Harband. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
Used to assert the correctness of object behavior in the presence
and context of Proxy objects.
defines: [allowProxyTraps]
---*/
function allowProxyTraps(overrides) {
function throwTest262Error(msg) {
return function () { throw new Test262Error(msg); };
}
if (!overrides) { overrides = {}; }
return {
getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'),
setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'),
isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'),
preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'),
getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'),
has: overrides.has || throwTest262Error('[[HasProperty]] trap called'),
get: overrides.get || throwTest262Error('[[Get]] trap called'),
set: overrides.set || throwTest262Error('[[Set]] trap called'),
deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'),
defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'),
enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'),
ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'),
apply: overrides.apply || throwTest262Error('[[Call]] trap called'),
construct: overrides.construct || throwTest262Error('[[Construct]] trap called')
};
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,25 @@
// |reftest| skip -- regexp-match-indices is not supported
// Copyright 2019 Ron Buckton. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: The groups object of indices is created with CreateDataProperty
includes: [compareArray.js]
esid: sec-makeindicesarray
features: [regexp-named-groups, regexp-match-indices]
info: |
MakeIndicesArray ( S, indices, groupNames )
8. If _groupNames_ is not *undefined*, then
a. Let _groups_ be ! ObjectCreate(*null*).
9. Else,
a. Let _groups_ be *undefined*.
10. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
---*/
// The `__proto__` property on the groups object is not special,
// and does not affect the [[Prototype]] of the resulting groups object.
let {groups} = /(?<__proto__>.)/.exec("a").indices;
assert.compareArray([0, 1], groups.__proto__);
assert.sameValue(null, Object.getPrototypeOf(groups));
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,23 @@
// Copyright 2017 Aleksey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Properties of the groups object are created with CreateDataProperty
esid: sec-regexpbuiltinexec
features: [regexp-named-groups]
info: |
Runtime Semantics: RegExpBuiltinExec ( R, S )
24. If _R_ contains any |GroupName|, then
a. Let _groups_ be ObjectCreate(*null*).
25. Else,
a. Let _groups_ be *undefined*.
26. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
---*/
// The `__proto__` property on the groups object is not special,
// and does not affect the [[Prototype]] of the resulting groups object.
let {groups} = /(?<__proto__>.)/.exec("a");
assert.sameValue("a", groups.__proto__);
assert.sameValue(null, Object.getPrototypeOf(groups));
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.match
description: >
[[IsHTMLDDA]] object as @@match method gets called.
info: |
String.prototype.match ( regexp )
[...]
2. If regexp is neither undefined nor null, then
a. Let matcher be ? GetMethod(regexp, @@match).
b. If matcher is not undefined, then
i. Return ? Call(matcher, regexp, « O »).
features: [Symbol.match, IsHTMLDDA]
---*/
var regexp = $262.IsHTMLDDA;
var matcherGets = 0;
Object.defineProperty(regexp, Symbol.match, {
get: function() {
matcherGets += 1;
return regexp;
},
configurable: true,
});
assert.sameValue("".match(regexp), null);
assert.sameValue(matcherGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.matchall
description: >
[[IsHTMLDDA]] object as @@matchAll method gets called.
info: |
String.prototype.matchAll ( regexp )
[...]
2. If regexp is neither undefined nor null, then
[...]
c. Let matcher be ? GetMethod(regexp, @@matchAll).
d. If matcher is not undefined, then
i. Return ? Call(matcher, regexp, « O »).
features: [Symbol.matchAll, String.prototype.matchAll, IsHTMLDDA]
---*/
var regexp = $262.IsHTMLDDA;
var matcherGets = 0;
Object.defineProperty(regexp, Symbol.matchAll, {
get: function() {
matcherGets += 1;
return regexp;
},
configurable: true,
});
assert.sameValue("".matchAll(regexp), null);
assert.sameValue(matcherGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.replace
description: >
[[IsHTMLDDA]] object as @@replace method gets called.
info: |
String.prototype.replace ( searchValue, replaceValue )
[...]
2. If searchValue is neither undefined nor null, then
a. Let replacer be ? GetMethod(searchValue, @@replace).
b. If replacer is not undefined, then
i. Return ? Call(replacer, searchValue, « O, replaceValue »).
features: [Symbol.replace, IsHTMLDDA]
---*/
var searchValue = $262.IsHTMLDDA;
var replacerGets = 0;
Object.defineProperty(searchValue, Symbol.replace, {
get: function() {
replacerGets += 1;
return searchValue;
},
configurable: true,
});
assert.sameValue("".replace(searchValue), null);
assert.sameValue(replacerGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,32 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.replaceall
description: >
[[IsHTMLDDA]] object as @@replace method gets called.
info: |
String.prototype.replaceAll ( searchValue, replaceValue )
[...]
2. If searchValue is neither undefined nor null, then
[...]
c. Let replacer be ? GetMethod(searchValue, @@replace).
d. If replacer is not undefined, then
i. Return ? Call(replacer, searchValue, « O, replaceValue »).
features: [Symbol.replace, String.prototype.replaceAll, IsHTMLDDA]
---*/
var searchValue = $262.IsHTMLDDA;
var replacerGets = 0;
Object.defineProperty(searchValue, Symbol.replace, {
get: function() {
replacerGets += 1;
return searchValue;
},
configurable: true,
});
assert.sameValue("".replaceAll(searchValue), null);
assert.sameValue(replacerGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.search
description: >
[[IsHTMLDDA]] object as @@search method gets called.
info: |
String.prototype.search ( regexp )
[...]
2. If regexp is neither undefined nor null, then
a. Let searcher be ? GetMethod(regexp, @@search).
b. If searcher is not undefined, then
i. Return ? Call(searcher, regexp, « O »).
features: [Symbol.search, IsHTMLDDA]
---*/
var regexp = $262.IsHTMLDDA;
var searcherGets = 0;
Object.defineProperty(regexp, Symbol.search, {
get: function() {
searcherGets += 1;
return regexp;
},
configurable: true,
});
assert.sameValue("".search(regexp), null);
assert.sameValue(searcherGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,31 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.split
description: >
[[IsHTMLDDA]] object as @@split method gets called.
info: |
String.prototype.split ( separator, limit )
[...]
2. If separator is neither undefined nor null, then
a. Let splitter be ? GetMethod(separator, @@split).
b. If splitter is not undefined, then
i. Return ? Call(splitter, separator, « O, limit »).
features: [Symbol.split, IsHTMLDDA]
---*/
var separator = $262.IsHTMLDDA;
var splitterGets = 0;
Object.defineProperty(separator, Symbol.split, {
get: function() {
splitterGets += 1;
return separator;
},
configurable: true,
});
assert.sameValue("".split(separator), null);
assert.sameValue(splitterGets, 1);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.from
description: >
[[IsHTMLDDA]] object as @@iterator method gets called.
info: |
%TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
[...]
5. Let usingIterator be ? GetMethod(items, @@iterator).
6. If usingIterator is not undefined, then
a. Let values be ? IterableToList(source, usingIterator).
IterableToList ( items, method )
1. Let iteratorRecord be ? GetIterator(items, sync, method).
GetIterator ( obj [ , hint [ , method ] ] )
[...]
4. Let iterator be ? Call(method, obj).
5. If Type(iterator) is not Object, throw a TypeError exception.
includes: [testTypedArray.js]
features: [Symbol.iterator, TypedArray, IsHTMLDDA]
---*/
var items = {};
items[Symbol.iterator] = $262.IsHTMLDDA;
testWithTypedArrayConstructors(function(TypedArray) {
assert.throws(TypeError, function() {
TypedArray.from(items);
});
});
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,124 @@
// GENERATED, DO NOT EDIT
// file: testTypedArray.js
// Copyright (C) 2015 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
Collection of functions used to assert the correctness of TypedArray objects.
defines:
- typedArrayConstructors
- floatArrayConstructors
- intArrayConstructors
- TypedArray
- testWithTypedArrayConstructors
- testWithAtomicsFriendlyTypedArrayConstructors
- testWithNonAtomicsFriendlyTypedArrayConstructors
- testTypedArrayConversions
---*/
/**
* Array containing every typed array constructor.
*/
var typedArrayConstructors = [
Float64Array,
Float32Array,
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
Uint8ClampedArray
];
var floatArrayConstructors = typedArrayConstructors.slice(0, 2);
var intArrayConstructors = typedArrayConstructors.slice(2, 7);
/**
* The %TypedArray% intrinsic constructor function.
*/
var TypedArray = Object.getPrototypeOf(Int8Array);
/**
* Callback for testing a typed array constructor.
*
* @callback typedArrayConstructorCallback
* @param {Function} Constructor the constructor object to test with.
*/
/**
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithTypedArrayConstructors(f, selected) {
var constructors = selected || typedArrayConstructors;
for (var i = 0; i < constructors.length; ++i) {
var constructor = constructors[i];
try {
f(constructor);
} catch (e) {
e.message += " (Testing with " + constructor.name + ".)";
throw e;
}
}
}
/**
* Calls the provided function for every non-"Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Float64Array,
Float32Array,
Uint8ClampedArray
]);
}
/**
* Calls the provided function for every "Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
]);
}
/**
* Helper for conversion operations on TypedArrays, the expected values
* properties are indexed in order to match the respective value for each
* TypedArray constructor
* @param {Function} fn - the function to call for each constructor and value.
* will be called with the constructor, value, expected
* value, and a initial value that can be used to avoid
* a false positive with an equivalent expected value.
*/
function testTypedArrayConversions(byteConversionValues, fn) {
var values = byteConversionValues.values;
var expected = byteConversionValues.expected;
testWithTypedArrayConstructors(function(TA) {
var name = TA.name.slice(0, -5);
return values.forEach(function(value, index) {
var exp = expected[name][index];
var initial = 0;
if (exp === 0) {
initial = 1;
}
fn(TA, value, exp, initial);
});
});
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,46 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
description: >
Destructuring initializer is not evaluated when value is an object
with [[IsHTMLDDA]] internal slot.
info: |
BindingPattern : ArrayBindingPattern
1. Let iteratorRecord be ? GetIterator(value).
2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments
iteratorRecord and environment.
3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
4. Return result.
Runtime Semantics: IteratorBindingInitialization
SingleNameBinding : BindingIdentifier Initializer[opt]
[...]
5. If Initializer is present and v is undefined, then
[...]
6. If environment is undefined, return ? PutValue(lhs, v).
features: [destructuring-binding, IsHTMLDDA]
---*/
var IsHTMLDDA = $262.IsHTMLDDA;
var initCount = 0;
var counter = function() {
initCount += 1;
};
var x;
([x = counter()] = [IsHTMLDDA]);
assert.sameValue(x, IsHTMLDDA);
assert.sameValue(initCount, 0);
var base = {};
([base.y = counter()] = [IsHTMLDDA]);
assert.sameValue(base.y, IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
description: >
Destructuring initializer is not evaluated when value is an object
with [[IsHTMLDDA]] internal slot.
info: |
BindingPattern : ObjectBindingPattern
1. Perform ? RequireObjectCoercible(value).
2. Return the result of performing BindingInitialization for
ObjectBindingPattern using value and environment as arguments.
Runtime Semantics: KeyedBindingInitialization
SingleNameBinding : BindingIdentifier Initializer[opt]
[...]
4. If Initializer is present and v is undefined, then
[...]
5. If environment is undefined, return ? PutValue(lhs, v).
features: [destructuring-binding, IsHTMLDDA]
---*/
var initCount = 0;
var counter = function() {
initCount += 1;
};
var x, IsHTMLDDA = $262.IsHTMLDDA;
({x = counter()} = {x: IsHTMLDDA});
assert.sameValue(x, IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,50 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-generator-function-definitions-runtime-semantics-evaluation
description: >
If <iterator>.throw is an object emulating `undefined` (e.g. `document.all`
in browsers), it shouldn't be treated as if it were actually `undefined` by
the yield* operator.
info: |
YieldExpression : yield * AssignmentExpression
[...]
7. Repeat,
[...]
b. Else if received.[[Type]] is throw, then
i. Let throw be ? GetMethod(iterator, "throw").
ii. If throw is not undefined, then
1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »).
[...]
4. If Type(innerResult) is not Object, throw a TypeError exception.
features: [generators, IsHTMLDDA]
---*/
var IsHTMLDDA = $262.IsHTMLDDA;
var returnCalls = 0;
var inner = {
[Symbol.iterator]() { return this; },
next() { return {done: false}; },
throw: IsHTMLDDA,
return() {
returnCalls += 1;
return {done: true};
},
};
var outer = (function* () { yield* inner; })();
outer.next();
assert.throws(TypeError, function() {
// `IsHTMLDDA` is called here with `iter` as `this` and `emptyString` as the
// sole argument, and it's specified to return `null` under these conditions.
// As `iter`'s iteration isn't ending because of a throw, the iteration
// protocol will then throw a `TypeError` because `null` isn't an object.
var emptyString = "";
outer.throw(emptyString);
});
assert.sameValue(returnCalls, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-semantics-classdefinitionevaluation
description: >
[[IsHTMLDDA]] object as superclass: `null` check uses strict equality.
IsConstructor check is performed before "prototype" lookup.
info: |
ClassDefinitionEvaluation
[...]
5. Else,
[...]
d. Let superclass be ? GetValue(superclassRef).
e. If superclass is null, then
[...]
f. Else if IsConstructor(superclass) is false, throw a TypeError exception.
features: [class, IsHTMLDDA]
---*/
var superclass = $262.IsHTMLDDA;
var prototypeGets = 0;
Object.defineProperty(superclass, "prototype", {
get: function() {
prototypeGets += 1;
},
});
assert.throws(TypeError, function() {
class C extends superclass {}
});
assert.sameValue(prototypeGets, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,39 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
description: >
Destructuring initializer is not evaluated when value is an object
with [[IsHTMLDDA]] internal slot.
info: |
BindingPattern : ArrayBindingPattern
1. Let iteratorRecord be ? GetIterator(value).
2. Let result be IteratorBindingInitialization of ArrayBindingPattern with arguments
iteratorRecord and environment.
3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
4. Return result.
Runtime Semantics: IteratorBindingInitialization
SingleNameBinding : BindingIdentifier Initializer[opt]
[...]
5. If Initializer is present and v is undefined, then
[...]
6. If environment is undefined, return ? PutValue(lhs, v).
features: [destructuring-binding, IsHTMLDDA]
---*/
let initCount = 0;
const counter = function() {
initCount += 1;
};
const IsHTMLDDA = $262.IsHTMLDDA;
const [x = counter()] = [IsHTMLDDA];
assert.sameValue(x, IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,37 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
description: >
Destructuring initializer is not evaluated when value is an object
with [[IsHTMLDDA]] internal slot.
info: |
BindingPattern : ObjectBindingPattern
1. Perform ? RequireObjectCoercible(value).
2. Return the result of performing BindingInitialization for
ObjectBindingPattern using value and environment as arguments.
Runtime Semantics: KeyedBindingInitialization
SingleNameBinding : BindingIdentifier Initializer[opt]
[...]
4. If Initializer is present and v is undefined, then
[...]
5. If environment is undefined, return ? PutValue(lhs, v).
features: [destructuring-binding, IsHTMLDDA]
---*/
let initCount = 0;
const counter = function() {
initCount += 1;
};
const IsHTMLDDA = $262.IsHTMLDDA;
const {x = counter()} = {x: IsHTMLDDA};
assert.sameValue(x, IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -0,0 +1,74 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject
description: >
Initializer is not evaluated when argument is an object with
[[IsHTMLDDA]] internal slot.
info: |
FunctionDeclaration :
function BindingIdentifier ( FormalParameters ) { FunctionBody }
[...]
3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody,
scope, strict).
[...]
[[Call]] ( thisArgument, argumentsList)
[...]
7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
[...]
OrdinaryCallEvaluateBody ( F, argumentsList )
1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
[...]
FunctionDeclarationInstantiation(func, argumentsList)
[...]
23. Let iteratorRecord be Record {[[iterator]]:
CreateListIterator(argumentsList), [[done]]: false}.
24. If hasDuplicates is true, then
[...]
25. Else,
b. Let formalStatus be IteratorBindingInitialization for formals with
iteratorRecord and env as arguments.
[...]
Runtime Semantics: IteratorBindingInitialization
FormalsList : FormalsList , FormalParameter
[...]
23. Let iteratorRecord be Record {[[Iterator]]:
CreateListIterator(argumentsList), [[Done]]: false}.
24. If hasDuplicates is true, then
[...]
25. Else,
a. Perform ? IteratorBindingInitialization for formals with
iteratorRecord and env as arguments.
[...]
features: [default-parameters, IsHTMLDDA]
---*/
let initCount = 0;
const counter = function() {
initCount += 1;
};
const arrow = (x = counter()) => x;
const IsHTMLDDA = $262.IsHTMLDDA;
assert.sameValue(arrow(IsHTMLDDA), IsHTMLDDA);
assert.sameValue(initCount, 0);
function fn(x, y = counter()) {
return y;
}
assert.sameValue(fn(1, IsHTMLDDA), IsHTMLDDA);
assert.sameValue(initCount, 0);
reportCompare(0, 0);

Просмотреть файл

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.indexof
description: >
Returns -1 if length is 0.
info: |
Array.prototype.indexOf ( searchElement [ , fromIndex ] )
1. Let O be ? ToObject(this value).
2. Let len be ? LengthOfArrayLike(O).
3. If len is 0, return -1.
---*/
var fromIndex = {
valueOf: function() {
throw new Test262Error("Length should be checked before ToInteger(fromIndex).");
},
};
assert.sameValue([].indexOf(1), -1);
assert.sameValue([].indexOf(2, fromIndex), -1);
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,24 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.lastindexof
description: >
Returns -1 if length is 0.
info: |
Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )
1. Let O be ? ToObject(this value).
2. Let len be ? LengthOfArrayLike(O).
3. If len is 0, return -1.
---*/
var fromIndex = {
valueOf: function() {
throw new Test262Error("Length should be checked before ToInteger(fromIndex).");
},
};
assert.sameValue([].lastIndexOf(1), -1);
assert.sameValue([].lastIndexOf(2, fromIndex), -1);
reportCompare(0, 0);

Просмотреть файл

@ -11,6 +11,8 @@ defines:
- intArrayConstructors
- TypedArray
- testWithTypedArrayConstructors
- testWithAtomicsFriendlyTypedArrayConstructors
- testWithNonAtomicsFriendlyTypedArrayConstructors
- testTypedArrayConversions
---*/
@ -63,6 +65,37 @@ function testWithTypedArrayConstructors(f, selected) {
}
}
/**
* Calls the provided function for every non-"Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Float64Array,
Float32Array,
Uint8ClampedArray
]);
}
/**
* Calls the provided function for every "Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
]);
}
/**
* Helper for conversion operations on TypedArrays, the expected values
* properties are indexed in order to match the respective value for each

Просмотреть файл

@ -29,6 +29,8 @@ defines:
- intArrayConstructors
- TypedArray
- testWithTypedArrayConstructors
- testWithAtomicsFriendlyTypedArrayConstructors
- testWithNonAtomicsFriendlyTypedArrayConstructors
- testTypedArrayConversions
---*/
@ -81,6 +83,37 @@ function testWithTypedArrayConstructors(f, selected) {
}
}
/**
* Calls the provided function for every non-"Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithNonAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Float64Array,
Float32Array,
Uint8ClampedArray
]);
}
/**
* Calls the provided function for every "Atomics Friendly" typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithAtomicsFriendlyTypedArrayConstructors(f) {
testWithTypedArrayConstructors(f, [
Int32Array,
Int16Array,
Int8Array,
Uint32Array,
Uint16Array,
Uint8Array,
]);
}
/**
* Helper for conversion operations on TypedArrays, the expected values
* properties are indexed in order to match the respective value for each

Просмотреть файл

@ -0,0 +1,54 @@
// |reftest| async
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%asyncfromsynciteratorprototype%.return
description: >
If syncIterator's "return" method is `null`,
a Promise resolved with `undefined` value is returned.
info: |
%AsyncFromSyncIteratorPrototype%.return ( value )
[...]
5. Let return be GetMethod(syncIterator, "return").
[...]
7. If return is undefined, then
a. Let iterResult be ! CreateIterResultObject(value, true).
b. Perform ! Call(promiseCapability.[[Resolve]], undefined, « iterResult »).
c. Return promiseCapability.[[Promise]].
GetMethod ( V, P )
[...]
2. Let func be ? GetV(V, P).
3. If func is either undefined or null, return undefined.
flags: [async]
features: [async-iteration]
---*/
var iterationCount = 0;
var returnGets = 0;
var syncIterator = {
[Symbol.iterator]() {
return this;
},
next() {
return {value: 1, done: false};
},
get return() {
returnGets += 1;
return null;
},
};
(async function() {
for await (let _ of syncIterator) {
iterationCount += 1;
break;
}
assert.sameValue(iterationCount, 1);
assert.sameValue(returnGets, 1);
}()).then($DONE, $DONE);

Просмотреть файл

@ -0,0 +1,60 @@
// |reftest| async
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%asyncfromsynciteratorprototype%.throw
description: >
If syncIterator's "throw" method is `null`,
a Promise rejected with provided value is returned.
info: |
%AsyncFromSyncIteratorPrototype%.throw ( value )
[...]
5. Let throw be GetMethod(syncIterator, "throw").
[...]
7. If throw is undefined, then
a. Perform ! Call(promiseCapability.[[Reject]], undefined, « value »).
b. Return promiseCapability.[[Promise]].
GetMethod ( V, P )
[...]
2. Let func be ? GetV(V, P).
3. If func is either undefined or null, return undefined.
flags: [async]
features: [async-iteration]
---*/
var throwGets = 0;
var syncIterator = {
[Symbol.iterator]() {
return this;
},
next() {
return {value: 1, done: false};
},
get throw() {
throwGets += 1;
return null;
},
};
async function* asyncGenerator() {
yield* syncIterator;
}
var asyncIterator = asyncGenerator();
var thrownError = { name: "err" };
asyncIterator.next().then(function() {
return asyncIterator.throw(thrownError);
}).then(function(result) {
throw new Test262Error("Promise should be rejected, got: " + result.value);
}, function(err) {
assert.sameValue(err, thrownError);
return asyncIterator.next().then(function(result) {
assert.sameValue(result.value, undefined);
assert.sameValue(result.done, true);
});
}).then($DONE, $DONE);

Просмотреть файл

@ -0,0 +1,52 @@
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-createdynamicfunction
description: >
While default [[Prototype]] value derives from realm of the newTarget,
"prototype" object inherits from %Object.prototype% of constructor's realm.
info: |
AsyncGeneratorFunction ( p1, p2, , pn, body )
[...]
3. Return ? CreateDynamicFunction(C, NewTarget, asyncGenerator, args).
CreateDynamicFunction ( constructor, newTarget, kind, args )
[...]
18. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
19. Let realmF be the current Realm Record.
20. Let scope be realmF.[[GlobalEnv]].
21. Let F be ! OrdinaryFunctionCreate(proto, parameters, body, non-lexical-this, scope).
[...]
24. Else if kind is asyncGenerator, then
a. Let prototype be OrdinaryObjectCreate(%AsyncGenerator.prototype%).
b. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]:
prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
[...]
30. Return F.
features: [async-iteration, cross-realm, Reflect]
---*/
var realmA = $262.createRealm().global;
realmA.calls = 0;
var aAsyncGeneratorFunction = realmA.eval("(async function* () {})").constructor;
var aAsyncGeneratorPrototype = Object.getPrototypeOf(
realmA.eval("(async function* () {})").prototype
);
var realmB = $262.createRealm().global;
var bAsyncGeneratorFunction = realmB.eval("(async function* () {})").constructor;
var newTarget = new realmB.Function();
newTarget.prototype = null;
var fn = Reflect.construct(aAsyncGeneratorFunction, ["calls += 1;"], newTarget);
assert.sameValue(Object.getPrototypeOf(fn), bAsyncGeneratorFunction.prototype);
assert.sameValue(Object.getPrototypeOf(fn.prototype), aAsyncGeneratorPrototype);
var gen = fn();
assert(gen instanceof realmA.Object);
gen.next();
assert.sameValue(realmA.calls, 1);
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,18 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Atomics.add will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.sameValue(Atomics.add(view, 0, 1n), 0n, 'Atomics.add(view, 0, 1n) returns 0n');
assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n');
});
reportCompare(0, 0);

Просмотреть файл

@ -1,19 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Test Atomics.add on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
var ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.add(new TA(ab), 0, 0n);
}, '`Atomics.add(new TA(ab), 0, 0n)` throws TypeError');
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Atomics.add will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
const view = new TA(
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.add(view, 0, 1), 0, 'Atomics.add(view, 0, 1) returns 0');
assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1');
});
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Atomics.add throws when operating on non-sharable integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithNonAtomicsFriendlyTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.add(view, 0, 1);
}, `Atomics.add(new ${TA.name}(buffer), 0, 1) throws TypeError`);
});
reportCompare(0, 0);

Просмотреть файл

@ -1,22 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Test Atomics.add on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const ab = new ArrayBuffer(16);
const views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.add(new TA(ab), 0, 0);
}, '`Atomics.add(new TA(ab), 0, 0)` throws TypeError');
}, views);
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,18 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.sameValue(Atomics.and(view, 0, 1n), 0n, 'Atomics.and(view, 0, 1n) returns 0n');
assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n');
});
reportCompare(0, 0);

Просмотреть файл

@ -1,19 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Test Atomics.and on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.and(new TA(buffer), 0, 0n);
}, '`Atomics.and(new TA(buffer), 0, 0n)` throws TypeError');
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Atomics.and will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
const view = new TA(
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.and(view, 0, 1), 0, 'Atomics.and(view, 0, 1) returns 0');
assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0');
});
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Atomics.and throws when operating on non-sharable integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithNonAtomicsFriendlyTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.and(view, 0, 1);
}, `Atomics.and(new ${TA.name}(buffer), 0, 1) throws TypeError`);
});
reportCompare(0, 0);

Просмотреть файл

@ -1,22 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.and
description: >
Test Atomics.and on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
const buffer = new ArrayBuffer(16);
const views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.and(new TA(buffer), 0, 0);
}, '`Atomics.and(new TA(buffer), 0, 0)` throws TypeError');
}, views);
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,18 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareExchange
description: >
Atomics.compareExchange will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.sameValue(Atomics.compareExchange(view, 0, 0n, 1n), 0n, 'Atomics.compareExchange(view, 0, 0n, 1n) returns 0n');
assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n');
});
reportCompare(0, 0);

Просмотреть файл

@ -1,19 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
const buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.compareExchange(new TA(buffer), 0, 0n, 0n);
}, '`Atomics.compareExchange(new TA(buffer), 0, 0n, 0n)` throws TypeError');
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareExchange
description: >
Atomics.compareExchange will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
const view = new TA(
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.compareExchange(view, 0, 0, 1), 0, 'Atomics.compareExchange(view, 0, 0, 1) returns 0');
assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1');
});
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareExchange
description: >
Atomics.compareExchange throws when operating on non-sharable integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithNonAtomicsFriendlyTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.compareExchange(view, 0, 0, 0);
}, `Atomics.compareExchange(new ${TA.name}(buffer), 0, 0, 0) throws TypeError`);
});
reportCompare(0, 0);

Просмотреть файл

@ -1,22 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.compareexchange
description: >
Test Atomics.compareExchange on non-shared integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
var buffer = new ArrayBuffer(16);
var views = intArrayConstructors.slice();
testWithTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.compareExchange(new TA(buffer), 0, 0, 0);
}, '`Atomics.compareExchange(new TA(buffer), 0, 0, 0)` throws TypeError');
}, views);
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,18 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.exchange
description: >
Atomics.exchange will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.sameValue(Atomics.exchange(view, 0, 1n), 0n, 'Atomics.exchange(view, 0, 1n) returns 0n');
assert.sameValue(Atomics.load(view, 0), 1n, 'Atomics.load(view, 0) returns 1n');
});
reportCompare(0, 0);

Просмотреть файл

@ -1,19 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.exchange
description: >
Test Atomics.exchange on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
var buffer = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
assert.throws(TypeError, function() {
Atomics.exchange(new TA(buffer), 0n, 0n);
}, '`Atomics.exchange(new TA(buffer), 0n, 0n)` throws TypeError');
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,21 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.exchange
description: >
Atomics.exchange will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
const view = new TA(
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.exchange(view, 0, 1), 0, 'Atomics.exchange(view, 0, 1) returns 0');
assert.sameValue(Atomics.load(view, 0), 1, 'Atomics.load(view, 0) returns 1');
});
reportCompare(0, 0);

Просмотреть файл

@ -0,0 +1,20 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.add
description: >
Atomics.add throws when operating on non-sharable integer TypedArrays
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithNonAtomicsFriendlyTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.throws(TypeError, function() {
Atomics.add(view, 0, 1);
}, `Atomics.add(new ${TA.name}(buffer), 0, 1) throws TypeError`);
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,17 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.load
description: >
Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, Atomics, BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(TA => {
const buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4);
const view = new TA(buffer);
assert.sameValue(Atomics.load(view, 0), 0n, 'Atomics.load(view, 0) returns 0n');
});
reportCompare(0, 0);

Просмотреть файл

@ -1,24 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2018 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.load
description: >
Test Atomics.load on non-shared integer TypedArrays
includes: [testBigIntTypedArray.js]
features: [ArrayBuffer, arrow-function, Atomics, BigInt, TypedArray]
---*/
var ab = new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 2);
testWithBigIntTypedArrayConstructors(function(TA) {
var view = new TA(ab);
assert.throws(TypeError, function() {
Atomics.load(view, 0);
}, '`Atomics.load(view, 0)` throws TypeError');
});
reportCompare(0, 0);

Просмотреть файл

@ -5,7 +5,9 @@
/*---
description: |
Collection of functions used to assert the correctness of BigInt TypedArray objects.
defines: [TypedArray, testWithBigIntTypedArrayConstructors]
defines:
- TypedArray
- testWithBigIntTypedArrayConstructors
---*/
/**
@ -17,12 +19,13 @@ var TypedArray = Object.getPrototypeOf(Int8Array);
* Calls the provided function for every typed array constructor.
*
* @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor.
* @param {Array} selected - An optional Array with filtered typed arrays
*/
function testWithBigIntTypedArrayConstructors(f) {
function testWithBigIntTypedArrayConstructors(f, selected) {
/**
* Array containing every BigInt typed array constructor.
*/
var constructors = [
var constructors = selected || [
BigInt64Array,
BigUint64Array
];

Просмотреть файл

@ -0,0 +1,20 @@
// |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-atomics.load
description: >
Atomics.load will operate on TA when TA.buffer is not a SharedArrayBuffer
includes: [testTypedArray.js]
features: [ArrayBuffer, Atomics, TypedArray]
---*/
testWithAtomicsFriendlyTypedArrayConstructors(TA => {
const view = new TA(
new ArrayBuffer(TA.BYTES_PER_ELEMENT * 4)
);
assert.sameValue(Atomics.load(view, 0), 0, 'Atomics.load(view, 0) returns 0');
});
reportCompare(0, 0);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше