Skip to content

Commit

Permalink
Update test for o[p] = f() (#4052)
Browse files Browse the repository at this point in the history
* Update test for o[p] = f()

Update S11.13.1_A7_T3.js now that consensus has been reached on tc39/ecma262#3307.

* Rename test and add an analogous one for super.
  • Loading branch information
rkirsling committed Apr 12, 2024
1 parent c5a8099 commit 142a6a6
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 26 deletions.
26 changes: 0 additions & 26 deletions test/language/expressions/assignment/S11.13.1_A7_T3.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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.
---*/

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();
});

0 comments on commit 142a6a6

Please sign in to comment.