Skip to content

Commit

Permalink
Add additional tests for tc39/ecma262#3307.
Browse files Browse the repository at this point in the history
Ensure that the following cases are covered:
- tc39/ecma262#3295 (comment)
- tc39/ecma262#2659 (comment)
  • Loading branch information
rkirsling committed Apr 18, 2024
1 parent 830b17a commit 953ad44
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function targetKey() {

assert.compareArray(log, [
"source", "iterator",
"target", "target-key", "target-key-tostring",
"target", "target-key",
"iterator-step", "iterator-done",
"set",
"target-key-tostring", "set",
]);
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ function targetKey() {

assert.compareArray(log, [
"source", "source-key", "source-key-tostring",
"target", "target-key", "target-key-tostring",
"get", "set",
"target", "target-key",
"get", "target-key-tostring", "set",
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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-evaluate-property-access-with-expression-key
description: When getting the value of o[p], ToObject(o) precedes ToPropertyKey(p).
info: |
13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue, expression, strict )
1. Let _propertyNameReference_ be ? Evaluation of _expression_.
2. Let _propertyNameValue_ be ? GetValue(_propertyNameReference_).
...
4. Return the Reference Record { [[Base]]: _baseValue_, [[ReferencedName]]: _propertyNameValue_, [[Strict]]: _strict_, [[ThisValue]]: ~empty~ }.
6.2.5.5 GetValue ( V )
1. If V is not a Reference Record, return V.
...
3. If IsPropertyReference(V) is true, then
a. Let baseObj be ? ToObject(V.[[Base]]).
...
c. If V.[[ReferencedName]] is neither a String nor a Symbol, then
i. Let referencedName be ? ToPropertyKey(V.[[ReferencedName]]).
---*/

assert.throws(TypeError, function() {
var base = null;
var prop = {
toString: function() {
throw new Test262Error("property key evaluated");
}
};

base[prop];
});

assert.throws(TypeError, function() {
var base = undefined;
var prop = {
toString: function() {
throw new Test262Error("property key evaluated");
}
};

base[prop];
});

0 comments on commit 953ad44

Please sign in to comment.