diff --git a/implementation-contributed/curation_logs/javascriptcore.json b/implementation-contributed/curation_logs/javascriptcore.json index 89a1559e81d52712d30109efbc7dfdd2769fb502..face9658cde9e220d3fb9159fe0053489bb2d9b1 100644 --- a/implementation-contributed/curation_logs/javascriptcore.json +++ b/implementation-contributed/curation_logs/javascriptcore.json @@ -1,6 +1,6 @@ { - "sourceRevisionAtLastExport": "60ed1be8cd", - "targetRevisionAtLastExport": "31e654a339", + "sourceRevisionAtLastExport": "205489c4f0", + "targetRevisionAtLastExport": "cab19d71a6", "curatedFiles": { "/stress/Number-isNaN-basics.js": "DELETED_IN_TARGET", "/stress/Object_static_methods_Object.getOwnPropertyDescriptors-proxy.js": "DELETED_IN_TARGET", diff --git a/implementation-contributed/javascriptcore/stress/big-int-left-shift-wrapped-value.js b/implementation-contributed/javascriptcore/stress/big-int-left-shift-wrapped-value.js new file mode 100644 index 0000000000000000000000000000000000000000..c69dbda33d30fc1172342c5a14e5a14bbb2e6df7 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/big-int-left-shift-wrapped-value.js @@ -0,0 +1,36 @@ +//@ runBigIntEnabled + +assert = { + sameValue: function (input, expected, message) { + if (input !== expected) + throw new Error(message); + } +}; + +function testLeftShift(x, y, z, message) { + assert.sameValue(x << y, z, message); +} + +testLeftShift(Object(0b10n), 1n, 0b100n, "ToPrimitive: unbox object with internal slot"); + +let o = { + [Symbol.toPrimitive]: function() { + return 0b10n; + } +}; +testLeftShift(o, 0b01n, 0b100n, "ToPrimitive: @@toPrimitive"); + +o = { + valueOf: function() { + return 0b10n; + } +}; +testLeftShift(o, 0b01n, 0b100n, "ToPrimitive: valueOf"); + +o = { + toString: function() { + return 0b10n; + } +} +testLeftShift(o, 0b01n, 0b100n, "ToPrimitive: toString"); + diff --git a/implementation-contributed/javascriptcore/stress/big-int-right-shift-general.js b/implementation-contributed/javascriptcore/stress/big-int-right-shift-general.js new file mode 100644 index 0000000000000000000000000000000000000000..4e58ca607402b7f15f3b1b3bb31c836c0169ce85 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/big-int-right-shift-general.js @@ -0,0 +1,104 @@ +//@ runBigIntEnabled + +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +function assert(a) { + if (!a) + throw new Error("Bad assertion"); +} + +assert.sameValue = function (input, expected, message) { + if (input !== expected) + throw new Error(message); +} + +assert.sameValue(0n >> 0n, 0n, "0n >> 0n === 0n"); +assert.sameValue(0b101n >> -1n, 0b1010n, "0b101n >> -1n === 0b1010n"); +assert.sameValue(0b101n >> -2n, 0b10100n, "0b101n >> -2n === 0b10100n"); +assert.sameValue(0b101n >> -3n, 0b101000n, "0b101n >> -3n === 0b101000n"); +assert.sameValue(0b101n >> 1n, 0b10n, "0b101n >> 1n === 0b10n"); +assert.sameValue(0b101n >> 2n, 1n, "0b101n >> 2n === 1n"); +assert.sameValue(0b101n >> 3n, 0n, "0b101n >> 3n === 0n"); +assert.sameValue(0n >> -128n, 0n, "0n >> -128n === 0n"); +assert.sameValue(0n >> 128n, 0n, "0n >> 128n === 0n"); +assert.sameValue(0x246n >> 0n, 0x246n, "0x246n >> 0n === 0x246n"); +assert.sameValue(0x246n >> -127n, 0x12300000000000000000000000000000000n, "0x246n >> -127n === 0x12300000000000000000000000000000000n"); +assert.sameValue(0x246n >> -128n, 0x24600000000000000000000000000000000n, "0x246n >> -128n === 0x24600000000000000000000000000000000n"); +assert.sameValue(0x246n >> -129n, 0x48c00000000000000000000000000000000n, "0x246n >> -129n === 0x48c00000000000000000000000000000000n"); +assert.sameValue(0x246n >> 128n, 0n, "0x246n >> 128n === 0n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> -64n, 0x123456789abcdef0fedcba98765432123456780000000000000000n, + "0x123456789abcdef0fedcba9876543212345678n >> -64n === 0x123456789abcdef0fedcba98765432123456780000000000000000n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> -32n, 0x123456789abcdef0fedcba987654321234567800000000n, + "0x123456789abcdef0fedcba9876543212345678n >> -32n === 0x123456789abcdef0fedcba987654321234567800000000n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> -16n, 0x123456789abcdef0fedcba98765432123456780000n, + "0x123456789abcdef0fedcba9876543212345678n >> -16n === 0x123456789abcdef0fedcba98765432123456780000n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 0n, 0x123456789abcdef0fedcba9876543212345678n, + "0x123456789abcdef0fedcba9876543212345678n >> 0n === 0x123456789abcdef0fedcba9876543212345678n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 16n, 0x123456789abcdef0fedcba987654321234n, + "0x123456789abcdef0fedcba9876543212345678n >> 16n === 0x123456789abcdef0fedcba987654321234n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 32n, 0x123456789abcdef0fedcba98765432n, + "0x123456789abcdef0fedcba9876543212345678n >> 32n === 0x123456789abcdef0fedcba98765432n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 64n, 0x123456789abcdef0fedcban, + "0x123456789abcdef0fedcba9876543212345678n >> 64n === 0x123456789abcdef0fedcban"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 127n, 0x2468acn, + "0x123456789abcdef0fedcba9876543212345678n >> 127n === 0x2468acn"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 128n, 0x123456n, + "0x123456789abcdef0fedcba9876543212345678n >> 128n === 0x123456n"); +assert.sameValue( + 0x123456789abcdef0fedcba9876543212345678n >> 129n, 0x91a2bn, + "0x123456789abcdef0fedcba9876543212345678n >> 129n === 0x91a2bn"); +assert.sameValue(-5n >> -1n, -0xan, "-5n >> -1n === -0xan"); +assert.sameValue(-5n >> -2n, -0x14n, "-5n >> -2n === -0x14n"); +assert.sameValue(-5n >> -3n, -0x28n, "-5n >> -3n === -0x28n"); +assert.sameValue(-5n >> 1n, -3n, "-5n >> 1n === -3n"); +assert.sameValue(-5n >> 2n, -2n, "-5n >> 2n === -2n"); +assert.sameValue(-5n >> 3n, -1n, "-5n >> 3n === -1n"); +assert.sameValue(-1n >> -128n, -0x100000000000000000000000000000000n, "-1n >> -128n === -0x100000000000000000000000000000000n"); +assert.sameValue(-1n >> 0n, -1n, "-1n >> 0n === -1n"); +assert.sameValue(-1n >> 128n, -1n, "-1n >> 128n === -1n"); +assert.sameValue(-0x246n >> 0n, -0x246n, "-0x246n >> 0n === -0x246n"); +assert.sameValue(-0x246n >> -127n, -0x12300000000000000000000000000000000n, "-0x246n >> -127n === -0x12300000000000000000000000000000000n"); +assert.sameValue(-0x246n >> -128n, -0x24600000000000000000000000000000000n, "-0x246n >> -128n === -0x24600000000000000000000000000000000n"); +assert.sameValue(-0x246n >> -129n, -0x48c00000000000000000000000000000000n, "-0x246n >> -129n === -0x48c00000000000000000000000000000000n"); +assert.sameValue(-0x246n >> 128n, -1n, "-0x246n >> 128n === -1n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> -64n, -0x123456789abcdef0fedcba98765432123456780000000000000000n, + "-0x123456789abcdef0fedcba9876543212345678n >> -64n === -0x123456789abcdef0fedcba98765432123456780000000000000000n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> -32n, -0x123456789abcdef0fedcba987654321234567800000000n, + "-0x123456789abcdef0fedcba9876543212345678n >> -32n === -0x123456789abcdef0fedcba987654321234567800000000n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> -16n, -0x123456789abcdef0fedcba98765432123456780000n, + "-0x123456789abcdef0fedcba9876543212345678n >> -16n === -0x123456789abcdef0fedcba98765432123456780000n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 0n, -0x123456789abcdef0fedcba9876543212345678n, + "-0x123456789abcdef0fedcba9876543212345678n >> 0n === -0x123456789abcdef0fedcba9876543212345678n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 16n, -0x123456789abcdef0fedcba987654321235n, + "-0x123456789abcdef0fedcba9876543212345678n >> 16n === -0x123456789abcdef0fedcba987654321235n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 32n, -0x123456789abcdef0fedcba98765433n, + "-0x123456789abcdef0fedcba9876543212345678n >> 32n === -0x123456789abcdef0fedcba98765433n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 64n, -0x123456789abcdef0fedcbbn, + "-0x123456789abcdef0fedcba9876543212345678n >> 64n === -0x123456789abcdef0fedcbbn"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 127n, -0x2468adn, + "-0x123456789abcdef0fedcba9876543212345678n >> 127n === -0x2468adn"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 128n, -0x123457n, + "-0x123456789abcdef0fedcba9876543212345678n >> 128n === -0x123457n"); +assert.sameValue( + -0x123456789abcdef0fedcba9876543212345678n >> 129n, -0x91a2cn, + "-0x123456789abcdef0fedcba9876543212345678n >> 129n === -0x91a2cn"); + diff --git a/implementation-contributed/javascriptcore/stress/big-int-right-shift-type-error.js b/implementation-contributed/javascriptcore/stress/big-int-right-shift-type-error.js new file mode 100644 index 0000000000000000000000000000000000000000..084ccd462d60f89cc6974fbce3287f73d0f9f28f --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/big-int-right-shift-type-error.js @@ -0,0 +1,104 @@ +//@ runBigIntEnabled + +function assert(a, message) { + if (!a) + throw new Error(message); +} + +function assertThrowTypeError(a, b, message) { + try { + let n = a >> b; + assert(false, message + ": Should throw TypeError, but executed without exception"); + } catch (e) { + assert(e instanceof TypeError, message + ": expected TypeError, got: " + e); + } +} + +assertThrowTypeError(30n, "foo", "BigInt >> String"); +assertThrowTypeError("bar", 18757382984821n, "String >> BigInt"); +assertThrowTypeError(30n, Symbol("foo"), "BigInt >> Symbol"); +assertThrowTypeError(Symbol("bar"), 18757382984821n, "Symbol >> BigInt"); +assertThrowTypeError(30n, 3320, "BigInt >> Int32"); +assertThrowTypeError(33256, 18757382984821n, "Int32 >> BigInt"); +assertThrowTypeError(30n, 0.543, "BigInt >> Double"); +assertThrowTypeError(230.19293, 18757382984821n, "Double >> BigInt"); +assertThrowTypeError(30n, NaN, "BigInt >> NaN"); +assertThrowTypeError(NaN, 18757382984821n, "NaN >> BigInt"); +assertThrowTypeError(30n, +Infinity, "BigInt >> +Infinity"); +assertThrowTypeError(+Infinity, 18757382984821n, "+Infinity >> BigInt"); +assertThrowTypeError(30n, -Infinity, "BigInt >> -Infinity"); +assertThrowTypeError(-Infinity, 18757382984821n, "-Infinity >> BigInt"); +assertThrowTypeError(30n, null, "BigInt >> null"); +assertThrowTypeError(null, 18757382984821n, "null >> BigInt"); +assertThrowTypeError(30n, undefined, "BigInt >> undefined"); +assertThrowTypeError(undefined, 18757382984821n, "undefined >> BigInt"); +assertThrowTypeError(30n, true, "BigInt >> true"); +assertThrowTypeError(true, 18757382984821n, "true >> BigInt"); +assertThrowTypeError(30n, false, "BigInt >> false"); +assertThrowTypeError(false, 18757382984821n, "false >> BigInt"); + +// Error when returning from object + +let o = { + valueOf: function () { return Symbol("Foo"); } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.valueOf returning Symbol"); +assertThrowTypeError(o, 18757382984821n, "Object.valueOf returning Symbol >> BigInt"); + +o = { + valueOf: function () { return 33256; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.valueOf returning Int32"); +assertThrowTypeError(o, 18757382984821n, "Object.valueOf returning Int32 >> BigInt"); + +o = { + valueOf: function () { return 0.453; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.valueOf returning Double"); +assertThrowTypeError(o, 18757382984821n, "Object.valueOf returning Double >> BigInt"); + +o = { + toString: function () { return Symbol("Foo"); } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.toString returning Symbol"); +assertThrowTypeError(o, 18757382984821n, "Object.toString returning Symbol >> BigInt"); + +o = { + toString: function () { return 33256; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.toString returning Int32"); +assertThrowTypeError(o, 18757382984821n, "Object.toString returning Int32 >> BigInt"); + +o = { + toString: function () { return 0.453; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.toString returning Double"); +assertThrowTypeError(o, 18757382984821n, "Object.toString returning Double >> BigInt"); + +o = { + [Symbol.toPrimitive]: function () { return Symbol("Foo"); } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.@@toPrimitive returning Symbol"); +assertThrowTypeError(o, 18757382984821n, "Object.@@toPrimitive returning Symbol >> BigInt"); + +o = { + [Symbol.toPrimitive]: function () { return 33256; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.@@toPrimitive returning Int32"); +assertThrowTypeError(o, 18757382984821n, "Object.@@toPrimitive returning Int32 >> BigInt"); + +o = { + [Symbol.toPrimitive]: function () { return 0.453; } +}; + +assertThrowTypeError(30n, o, "BigInt >> Object.@@toPrimitive returning Double"); +assertThrowTypeError(o, 18757382984821n, "Object.@@toPrimitive returning Double >> BigInt"); + diff --git a/implementation-contributed/javascriptcore/stress/big-int-right-shift-wrapped-value.js b/implementation-contributed/javascriptcore/stress/big-int-right-shift-wrapped-value.js new file mode 100644 index 0000000000000000000000000000000000000000..b96b2e393cf306d54bb58d694f1e2b0da9b796e9 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/big-int-right-shift-wrapped-value.js @@ -0,0 +1,36 @@ +//@ runBigIntEnabled + +assert = { + sameValue: function (input, expected, message) { + if (input !== expected) + throw new Error(message); + } +}; + +function testRightShift(x, y, z, message) { + assert.sameValue(x >> y, z, message); +} + +testRightShift(Object(0b10n), 1n, 0b1n, "ToPrimitive: unbox object with internal slot"); + +let o = { + [Symbol.toPrimitive]: function() { + return 0b10n; + } +}; +testRightShift(o, 0b01n, 0b1n, "ToPrimitive: @@toPrimitive"); + +o = { + valueOf: function() { + return 0b10n; + } +}; +testRightShift(o, 0b01n, 0b1n, "ToPrimitive: valueOf"); + +o = { + toString: function() { + return 0b10n; + } +} +testRightShift(o, 0b01n, 0b1n, "ToPrimitive: toString"); + diff --git a/implementation-contributed/javascriptcore/stress/left-shift-to-primitive-precedence.js b/implementation-contributed/javascriptcore/stress/left-shift-to-primitive-precedence.js new file mode 100644 index 0000000000000000000000000000000000000000..56d266fc39134f7ef059d2d4641dc13d5390168a --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/left-shift-to-primitive-precedence.js @@ -0,0 +1,29 @@ +//@ runBigIntEnabled + +assert = { + sameValue: function (input, expected, message) { + if (input !== expected) + throw new Error(message); + } +}; + +let o = { + [Symbol.toPrimitive]: function() { + throw new Error("Bad"); + } +}; + +try{ + o << Symbol("2"); + assert.sameValue(true, false, "Exception expected to be throwed, but executed without error"); +} catch (e) { + assert.sameValue(e.message, "Bad", "Expected to throw Error('Bad'), but got: " + e); +} + +try{ + Symbol("2") << o; + assert.sameValue(true, false, "Exception expected to be throwed, but executed without error"); +} catch (e) { + assert.sameValue(e instanceof TypeError, true, "Expected to throw TypeError, but got: " + e) +} + diff --git a/implementation-contributed/javascriptcore/stress/right-shift-to-primitive-precedence.js b/implementation-contributed/javascriptcore/stress/right-shift-to-primitive-precedence.js new file mode 100644 index 0000000000000000000000000000000000000000..1eb6b034c0724e53340f3bfe6c5f1b764cd742d4 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/right-shift-to-primitive-precedence.js @@ -0,0 +1,29 @@ +//@ runBigIntEnabled + +assert = { + sameValue: function (input, expected, message) { + if (input !== expected) + throw new Error(message); + } +}; + +let o = { + [Symbol.toPrimitive]: function() { + throw new Error("Bad"); + } +}; + +try{ + o >> Symbol("2"); + assert.sameValue(true, false, "Exception expected to be throwed, but executed without error"); +} catch (e) { + assert.sameValue(e.message, "Bad", "Expected to throw Error('Bad'), but got: " + e); +} + +try{ + Symbol("2") >> o; + assert.sameValue(true, false, "Exception expected to be throwed, but executed without error"); +} catch (e) { + assert.sameValue(e instanceof TypeError, true, "Expected to throw TypeError, but got: " + e) +} + diff --git a/implementation-contributed/javascriptcore/stress/simple-module.mjs b/implementation-contributed/javascriptcore/stress/simple-module.mjs new file mode 100644 index 0000000000000000000000000000000000000000..2d96b58009d505602ee2b88b7919ee9de24442d4 --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/simple-module.mjs @@ -0,0 +1,2 @@ +if (this !== undefined) + throw new Error("this === undefined in module code"); diff --git a/implementation-contributed/javascriptcore/stress/simple-script.js b/implementation-contributed/javascriptcore/stress/simple-script.js new file mode 100644 index 0000000000000000000000000000000000000000..6f204526618aaf2acb5b5e6ec23a3edf0207befd --- /dev/null +++ b/implementation-contributed/javascriptcore/stress/simple-script.js @@ -0,0 +1,2 @@ +if (this === undefined) + throw new Error("this !== undefined in script code");