diff options
Diffstat (limited to 'js/src/tests/test262/language/expressions')
3 files changed, 93 insertions, 28 deletions
diff --git a/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js b/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js deleted file mode 100644 index 8675448e23..0000000000 --- a/js/src/tests/test262/language/expressions/assignment/S11.13.1_A7_T3.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -info: Assignment Operator evaluates its operands from left to right. -description: > - The left-hand side expression is evaluated before the right-hand side. - Left-hand side expression is MemberExpression: base[prop]. Evaluating - ToPropertyKey(prop) throws an error. ----*/ - -function DummyError() { } - -assert.throws(DummyError, function() { - var base = {}; - var prop = { - toString: function() { - throw new DummyError(); - } - }; - var expr = function() { - throw new Test262Error("right-hand side expression evaluated"); - }; - - base[prop] = expr(); -}); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js b/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js new file mode 100644 index 0000000000..fefc73370f --- /dev/null +++ b/js/src/tests/test262/language/expressions/assignment/target-member-computed-reference.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assignment-operators +description: Assignment Operator evaluates its operands from left to right (formerly S11.13.1_A7_T3) +info: | + The left-hand side expression is evaluated before the right-hand side. + Left-hand side expression is MemberExpression: base[prop]. + ToPropertyKey(prop) occurs after both sides are evaluated. +---*/ + +function DummyError() { } + +assert.throws(DummyError, function() { + var base = {}; + var prop = function() { + throw new DummyError(); + }; + var expr = function() { + throw new Test262Error("right-hand side expression evaluated"); + }; + + base[prop()] = expr(); +}); + +assert.throws(DummyError, function() { + var base = {}; + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + var expr = function() { + throw new DummyError(); + }; + + base[prop] = expr(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js b/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js new file mode 100644 index 0000000000..39d692a81b --- /dev/null +++ b/js/src/tests/test262/language/expressions/assignment/target-super-computed-reference.js @@ -0,0 +1,51 @@ +// Copyright (C) 2024 Sony Interactive Entertainment Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-assignment-operators +description: Assignment Operator evaluates its operands from left to right +info: | + The left-hand side expression is evaluated before the right-hand side. + Left-hand side expression is MemberExpression: super[prop]. + ToPropertyKey(prop) occurs after both sides are evaluated. +---*/ + +function DummyError() {} + +assert.throws(DummyError, function() { + var prop = function() { + throw new DummyError(); + }; + var expr = function() { + throw new Test262Error("right-hand side expression evaluated"); + }; + + class C extends class {} { + m() { + super[prop()] = expr(); + } + } + + (new C()).m(); +}); + +assert.throws(DummyError, function() { + var prop = { + toString: function() { + throw new Test262Error("property key evaluated"); + } + }; + var expr = function() { + throw new DummyError(); + }; + + class C extends class {} { + m() { + super[prop] = expr(); + } + } + + (new C()).m(); +}); + +reportCompare(0, 0); |