Test computed accessor properties and AggregateError constructor without arguments (#4222)

This commit is contained in:
Paul Bakker 2024-09-11 11:41:07 +02:00 committed by GitHub
parent 70cdc562e3
commit 98c7e9114e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 1 deletions

View File

@ -67,3 +67,7 @@ new AggregateError(case1);
assert.sameValue(count, 3); assert.sameValue(count, 3);
assert.compareArray(values, [1, 2]); assert.compareArray(values, [1, 2]);
assert.throws(TypeError, () => {
new AggregateError();
}, 'GetMethod(obj, @@iterator) returns undefined');

View File

@ -5,9 +5,18 @@ es6id: 12.2.5
description: > description: >
Computed property names for getters Computed property names for getters
---*/ ---*/
var s = Symbol();
var A = { var A = {
get ["a"]() { get ["a"]() {
return "A"; return "A";
},
get [1]() {
return 1;
},
get [s]() {
return s;
} }
}; };
assert.sameValue(A.a, "A", "The value of `A.a` is `'A'`"); assert.sameValue(A.a, "A", "The value of `A.a` is `'A'`");
assert.sameValue(A[1], 1, "The value of `A[1]` is `1`");
assert.sameValue(A[s], s, "The value of `A[s]` is `Symbol()`");

View File

@ -7,10 +7,19 @@ description: >
that name, whose value is the value of the last property of that name. that name, whose value is the value of the last property of that name.
---*/ ---*/
var calls = 0; var calls = 0;
var s = Symbol();
var A = { var A = {
set ['a'](_) { set ['a'](_) {
calls++; calls++;
},
set [1](_) {
calls++;
},
set [s](_) {
calls++;
} }
}; };
A.a = 'A'; A.a = 'A';
assert.sameValue(calls, 1, "The value of `calls` is `1`, after executing `A.a = 'A';`"); A[1] = 1;
A[s] = s;
assert.sameValue(calls, 3, "The value of `calls` is `1`, after executing `A.a = 'A'; A[1] = 1; A[s] = s;`");