Skip to content

Commit

Permalink
Merge branch 'main' into import-attributes-3
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo authored Oct 9, 2023
2 parents 6389d28 + 715dd10 commit 1173c01
Show file tree
Hide file tree
Showing 495 changed files with 7,153 additions and 3,760 deletions.
16 changes: 16 additions & 0 deletions harness/propertyHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,28 @@ function verifyProperty(obj, name, desc, options) {
"The desc argument should be an object or undefined, " + String(desc)
);

var names = Object.getOwnPropertyNames(desc);
for (var i = 0; i < names.length; i++) {
assert(
names[i] === "value" ||
names[i] === "writable" ||
names[i] === "enumerable" ||
names[i] === "configurable" ||
names[i] === "get" ||
names[i] === "set",
"Invalid descriptor field: " + names[i],
);
}

var failures = [];

if (Object.prototype.hasOwnProperty.call(desc, 'value')) {
if (!isSameValue(desc.value, originalDesc.value)) {
failures.push("descriptor value should be " + desc.value);
}
if (!isSameValue(desc.value, obj[name])) {
failures.push("object value should be " + desc.value);
}
}

if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ features: [class, decorators]
class C {
/*{ elements }*/
static {
/*{ decorators }*/ class C {}
/*{ decorators }*/ class D {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ info: |
features: [class, decorators]
---*/

var C = class {
class C {
/*{ elements }*/
static {
var C = /*{ decorators }*/ class {}
var D = /*{ decorators }*/ class {}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2023 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-globaldeclarationinstantiation
description: Let binding collision with existing var declaration that was created for hoisted function.
info: |
[...]
3. For each element name of lexNames, do
a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception.
flags: [noStrict]
---*/

eval('if (true) { function test262Fn() {} }');

assert.throws(SyntaxError, function() {
$262.evalScript('var x; let test262Fn;');
});

assert.throws(ReferenceError, function() {
x;
}, 'no bindings created');
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2023 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-globaldeclarationinstantiation
description: No let binding collision with existing var declaration due to strict-mode eval().
info: |
PerformEval ( x, strictCaller, direct )
[...]
16. If direct is true, then
a. Let lexEnv be NewDeclarativeEnvironment(runningContext's LexicalEnvironment).
[...]
18. If strictEval is true, set varEnv to lexEnv.
flags: [onlyStrict]
---*/

eval('if (true) { function test262Fn() {} }');

$262.evalScript('let test262Fn = 1;');

assert.sameValue(test262Fn, 1);
23 changes: 23 additions & 0 deletions test/annexB/language/global-code/script-decl-lex-collision.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2023 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-globaldeclarationinstantiation
description: Let binding collision with existing var declaration that was created for hoisted function.
info: |
[...]
3. For each element name of lexNames, do
a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception.
flags: [noStrict]
---*/

if (true) {
function test262Fn() {}
}

assert.throws(SyntaxError, function() {
$262.evalScript('var x; let test262Fn;');
});

assert.throws(ReferenceError, function() {
x;
}, 'no bindings created');
2 changes: 0 additions & 2 deletions test/built-ins/Array/fromAsync/this-constructor-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ asyncTest(async function () {

actualCalls.splice(0); // reset

// Note https://github.com/tc39/proposal-array-from-async/issues/35
const expectedCallsForArrayLike = [
"construct MyArray",
"construct MyArray",
"defineProperty A[0]",
"defineProperty A[1]",
Expand Down
5 changes: 2 additions & 3 deletions test/built-ins/Array/fromAsync/this-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ asyncTest(async function () {
assert.sameValue(result.length, 2, "length is set on result");
assert.sameValue(result[0], 1, "element 0 is set on result");
assert.sameValue(result[1], 2, "element 1 is set on result");
assert.sameValue(constructorCalls.length, 2, "constructor is called twice");
assert.compareArray(constructorCalls[0], [], "constructor is called first with no arguments");
assert.compareArray(constructorCalls[1], [2], "constructor is called second with a length argument");
assert.sameValue(constructorCalls.length, 1, "constructor is called once");
assert.compareArray(constructorCalls[0], [2], "constructor is called with a length argument");
});
2 changes: 1 addition & 1 deletion test/built-ins/ArrayBuffer/prototype/resize/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ includes: [propertyHelper.js]
verifyProperty(ArrayBuffer.prototype.resize, 'name', {
value: 'resize',
enumerable: false,
wrtiable: false,
writable: false,
configurable: true
});
2 changes: 1 addition & 1 deletion test/built-ins/ArrayBuffer/prototype/transfer/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ includes: [propertyHelper.js]
verifyProperty(ArrayBuffer.prototype.transfer, 'name', {
value: 'transfer',
enumerable: false,
wrtiable: false,
writable: false,
configurable: true
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ includes: [propertyHelper.js]
verifyProperty(ArrayBuffer.prototype.transferToFixedLength, 'name', {
value: 'transferToFixedLength',
enumerable: false,
wrtiable: false,
writable: false,
configurable: true
});
2 changes: 1 addition & 1 deletion test/built-ins/Error/cause_property.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var error = new Error(message, { cause });
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var error = new AggregateError(errors, message, { cause });
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});

Expand Down
2 changes: 1 addition & 1 deletion test/built-ins/NativeErrors/cause_property_native_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ for (var i = 0; i < nativeErrors.length; ++i) {
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: >
Non-string values of `Symbol.toStringTag` property are ignored.
info: |
Object.prototype.toString ( )
[...]
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, iterator-helpers]
---*/

var toString = Object.prototype.toString;

var arrIter = [][Symbol.iterator]();
var arrIterProto = Object.getPrototypeOf(arrIter);

assert.sameValue(toString.call(arrIter), '[object Array Iterator]');

Object.defineProperty(arrIterProto, Symbol.toStringTag, {configurable: true, value: null});
assert.sameValue(toString.call(arrIter), '[object Object]');

delete arrIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(arrIter), '[object Iterator]');
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: >
Non-string values of `Symbol.toStringTag` property are ignored.
info: |
Object.prototype.toString ( )
[...]
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, generators, iterator-helpers]
---*/

var toString = Object.prototype.toString;

var genFn = function* () {};
assert.sameValue(toString.call(gen), '[object GeneratorFunction]');

var gen = genFn();
assert.sameValue(toString.call(gen), '[object Generator]');

var genProto = Object.getPrototypeOf(gen);
Object.defineProperty(genProto, Symbol.toStringTag, {
configurable: true,
get: function() { return {}; },
});
assert.sameValue(toString.call(gen), '[object Object]');

delete genProto[Symbol.toStringTag];
assert.sameValue(toString.call(gen), '[object Iterator]');
33 changes: 33 additions & 0 deletions test/built-ins/Object/prototype/toString/symbol-tag-map-builtin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: >
Non-string values of `Symbol.toStringTag` property are ignored.
info: |
Object.prototype.toString ( )
[...]
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, Map, iterator-helpers]
---*/

var toString = Object.prototype.toString;

var map = new Map();
delete Map.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(map), '[object Object]');

var mapIter = map[Symbol.iterator]();
var mapIterProto = Object.getPrototypeOf(mapIter);
assert.sameValue(toString.call(mapIter), '[object Map Iterator]');
Object.defineProperty(mapIterProto, Symbol.toStringTag, {
configurable: true,
get: function() { return new String('ShouldNotBeUnwrapped'); },
});
assert.sameValue(toString.call(mapIter), '[object Object]');

delete mapIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(mapIter), '[object Iterator]');
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ info: |
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Symbol.iterator, generators, WeakMap, iterator-helpers]
features: [Symbol.toStringTag]
---*/

var toString = Object.prototype.toString;
Expand All @@ -22,58 +22,6 @@ assert.sameValue(toString.call(Symbol('desc')), '[object Object]');
Object.defineProperty(Math, Symbol.toStringTag, {value: Symbol()});
assert.sameValue(toString.call(Math), '[object Object]');

var strIter = ''[Symbol.iterator]();
var strIterProto = Object.getPrototypeOf(strIter);
assert.sameValue(toString.call(strIter), '[object String Iterator]');
delete strIterProto[Symbol.toStringTag];
assert.sameValue(toString.call(strIter), '[object Iterator]');

var arrIter = [][Symbol.iterator]();
var arrIterProto = Object.getPrototypeOf(arrIter)
assert.sameValue(toString.call(arrIter), '[object Array Iterator]');
Object.defineProperty(arrIterProto, Symbol.toStringTag, {value: null});
assert.sameValue(toString.call(arrIter), '[object Object]');

var map = new Map();
delete Map.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(map), '[object Object]');

var mapIter = map[Symbol.iterator]();
var mapIterProto = Object.getPrototypeOf(mapIter);
assert.sameValue(toString.call(mapIter), '[object Map Iterator]');
Object.defineProperty(mapIterProto, Symbol.toStringTag, {
get: function() { return new String('ShouldNotBeUnwrapped'); },
});
assert.sameValue(toString.call(mapIter), '[object Object]');

var set = new Set();
delete Set.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(set), '[object Object]');

var setIter = set[Symbol.iterator]();
var setIterProto = Object.getPrototypeOf(setIter);
assert.sameValue(toString.call(setIter), '[object Set Iterator]');
Object.defineProperty(setIterProto, Symbol.toStringTag, {value: false});
assert.sameValue(toString.call(setIter), '[object Object]');

var wm = new WeakMap();
delete WeakMap.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(wm), '[object Object]');

var ws = new WeakSet();
Object.defineProperty(WeakSet.prototype, Symbol.toStringTag, {value: 0});
assert.sameValue(toString.call(ws), '[object Object]');

delete JSON[Symbol.toStringTag];
assert.sameValue(toString.call(JSON), '[object Object]');

var gen = (function* () {})();
var genProto = Object.getPrototypeOf(gen);
Object.defineProperty(genProto, Symbol.toStringTag, {
get: function() { return {}; },
});
assert.sameValue(toString.call(gen), '[object Object]');

var promise = new Promise(function() {});
delete Promise.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(promise), '[object Object]');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.tostring
description: >
Non-string values of `Symbol.toStringTag` property are ignored.
info: |
Object.prototype.toString ( )
[...]
15. Let tag be ? Get(O, @@toStringTag).
16. If Type(tag) is not String, set tag to builtinTag.
17. Return the string-concatenation of "[object ", tag, and "]".
features: [Symbol.toStringTag, Promise]
---*/

var toString = Object.prototype.toString;

var promise = new Promise(function () {});
assert.sameValue(toString.call(promise), '[object Promise]');

delete Promise.prototype[Symbol.toStringTag];
assert.sameValue(toString.call(promise), '[object Object]');
Loading

0 comments on commit 1173c01

Please sign in to comment.