Add tests for accessor names

This commit is contained in:
Mike Pennisi 2016-06-28 15:23:49 -04:00 committed by Leonardo Balter
parent d93bee595e
commit 228851fbe4
No known key found for this signature in database
GPG Key ID: 4191D7EB5EC82FF7
41 changed files with 1204 additions and 0 deletions

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion when evaluating expression
template: error
info: |
12.2.6.7 Runtime Semantics: Evaluation
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
---*/
//- setup
var thrower = function() {
throw new Test262Error();
};
//- error
Test262Error
//- name
thrower()

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion when coercing to property key value
template: error
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
7.1.14 ToPropertyKey
1. Let key be ? ToPrimitive(argument, hint String).
7.1.1 ToPrimitive
[...]
7. Return ? OrdinaryToPrimitive(input, hint).
7.1.1.1 OrdinaryToPrimitive
5. For each name in methodNames in List order, do
[...]
6. Throw a TypeError exception.
---*/
//- setup
var badKey = Object.create(null);
//- error
TypeError
//- name
badKey

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Abrupt completion when resolving reference value
template: error
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
---*/
//- error
ReferenceError
//- name
test262unresolvable

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (AssignmentExpression)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- setup
var _;
//- declareWith
[_ = 'str' + 'ing']
//- referenceWith
'string'

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/class/accessor-name-inst-
name: Class declaration, instance method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
---*/
var stringSet;
class C {
get /*{ declareWith }*/() { return 'get string'; }
set /*{ declareWith }*/(param) { stringSet = param; }
}
assert.sameValue(C.prototype[/*{ referenceWith }*/], 'get string');
C.prototype[/*{ referenceWith }*/] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/class/accessor-name-static-
name: Class declaration, static method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
---*/
var stringSet;
class C {
static get /*{ declareWith }*/() { return 'get string'; }
static set /*{ declareWith }*/(param) { stringSet = param; }
}
assert.sameValue(C[/*{ referenceWith }*/], 'get string');
C[/*{ referenceWith }*/] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/class/accessor-name-inst-
name: Class expression, instance method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
---*/
var stringSet;
var C = class {
get /*{ declareWith }*/() { return 'get string'; }
set /*{ declareWith }*/(param) { stringSet = param; }
};
assert.sameValue(C.prototype[/*{ referenceWith }*/], 'get string');
C.prototype[/*{ referenceWith }*/] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/class/accessor-name-static-
name: Class expression, static method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
---*/
var stringSet;
var C = class {
static get /*{ declareWith }*/() { return 'get string'; }
static set /*{ declareWith }*/(param) { stringSet = param; }
};
assert.sameValue(C[/*{ referenceWith }*/], 'get string');
C[/*{ referenceWith }*/] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,27 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/object/accessor-name-
name: Object initializer
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
1. Let obj be ObjectCreate(%ObjectPrototype%).
2. Let status be the result of performing PropertyDefinitionEvaluation of
PropertyDefinitionList with arguments obj and true.
---*/
var stringSet;
var obj = {
get [/*{ declareWith }*/]() { return 'get string'; },
set [/*{ declareWith }*/](param) { stringSet = param; }
};
assert.sameValue(obj[/*{ referenceWith }*/], 'get string');
obj[/*{ referenceWith }*/] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/class/accessor-name-inst-
name: Class declaration, instance method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
---*/
assert.throws(/*{ error }*/, function() {
class C {
get [/*{ name }*/]() {}
}
}, '`get` accessor');
assert.throws(/*{ error }*/, function() {
class C {
set [/*{ name }*/](_) {}
}
}, '`set` accessor');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/class/accessor-name-static-
name: Class declaration, static method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
---*/
assert.throws(/*{ error }*/, function() {
class C {
static get [/*{ name }*/]() {}
}
}, '`get` accessor');
assert.throws(/*{ error }*/, function() {
class C {
static set [/*{ name }*/](_) {}
}
}, '`set` accessor');

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/class/accessor-name-inst-
name: Class expression, instance method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
---*/
assert.throws(/*{ error }*/, function() {
0, class {
get [/*{ name }*/]() {}
};
}, '`get` accessor');
assert.throws(/*{ error }*/, function() {
0, class {
set [/*{ name }*/](_) {}
};
}, '`set` accessor');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/class/accessor-name-static-
name: Class expression, static method
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
---*/
assert.throws(/*{ error }*/, function() {
0, class {
static get [/*{ name }*/]() {}
};
}, '`get` accessor');
assert.throws(/*{ error }*/, function() {
0, class {
static set [/*{ name }*/](_) {}
};
}, '`set` accessor');

View File

@ -0,0 +1,28 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/object/accessor-name-
name: Object initializer
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
1. Let obj be ObjectCreate(%ObjectPrototype%).
2. Let status be the result of performing PropertyDefinitionEvaluation of
PropertyDefinitionList with arguments obj and true.
---*/
assert.throws(/*{ error }*/, function() {
({
get [/*{ name }*/]() {}
});
}, '`get` accessor');
assert.throws(/*{ error }*/, function() {
({
set [/*{ name }*/](_) {}
});
}, '`set` accessor');

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal in binary notation)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
0b10
//- referenceWith
'2'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal in exponent notation)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
1E+9
//- referenceWith
'1000000000'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal in hexadecimal notation)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
0x10
//- referenceWith
'16'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal with leading decimal point)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
.1
//- referenceWith
'0.1'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal with non-canonical representation)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
0.0000001
//- referenceWith
'1e-7'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal in octal notation)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
0o10
//- referenceWith
'8'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (numeric literal zero)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
0
//- referenceWith
'0'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal containing a character escape sequence)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
'character\tescape'
//- referenceWith
'character escape'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal using double quotes)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
"doubleQuote"
//- referenceWith
"doubleQuote"

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal, the empty string)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
''
//- referenceWith
''

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal containing a hexadecimal escape sequence)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
'hex\x45scape'
//- referenceWith
'hexEscape'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal using single quotes)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
'singleQuote'
//- referenceWith
'singleQuote'

View File

@ -0,0 +1,21 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Computed values as accessor property names (string literal containing a Unicode escape sequence)
template: default
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
//- declareWith
'unicod\u{000065}Escape'
//- referenceWith
'unicodeEscape'

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
description: >
AssignmentExpression may contain `in` keyword regardless of outer context
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var empty = Object.create(null);
var C, value;
for (C = class { get ['x' in empty]() { return 'via get'; } }; ; ) {
value = C.prototype.false;
break;
}
assert.sameValue(value, 'via get');
for (C = class { set ['x' in empty](param) { value = param; } }; ; ) {
C.prototype.false = 'via set';
break;
}
assert.sameValue(value, 'via set');

View File

@ -0,0 +1,41 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as a YieldExpression within a generator function
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
features: [generators]
---*/
var yieldSet, C, iter;
function* g() {
C = class {
get [yield]() { return 'get yield'; }
set [yield](param) { yieldSet = param; }
};
}
iter = g();
iter.next();
iter.next('first');
iter.next('second');
assert.sameValue(C.prototype.first, 'get yield');
C.prototype.second = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Computed values as accessor property names (string literal containing a line terminator) (Class expression, instance method)
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var stringSet;
var C = class {
get 'line\
Terminator'
() { return 'get string'; }
set 'line\
Terminator'
(param) { stringSet = param; }
};
assert.sameValue(C.prototype['lineTerminator'], 'get string');
C.prototype['lineTerminator'] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,39 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
description: >
AssignmentExpression may contain `in` keyword regardless of outer context
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var empty = Object.create(null);
var C, value;
for (C = class { static get ['x' in empty]() { return 'via get'; } }; ; ) {
value = C.false;
break;
}
assert.sameValue(value, 'via get');
for (C = class { static set ['x' in empty](param) { value = param; } }; ; ) {
C.false = 'via set';
break;
}
assert.sameValue(value, 'via set');

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as a YieldExpression within a generator function
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
features: [generators]
---*/
var yieldSet, C, iter;
function* g() {
C = class {
static get [yield]() { return 'get yield'; }
static set [yield](param) { yieldSet = param; }
};
}
iter = g();
iter.next();
iter.next('first');
iter.next('second');
assert.sameValue(C.first, 'get yield');
C.second = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Computed values as accessor property names (string literal containing a line terminator) (Class expression, static method)
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var stringSet;
var C = class {
static get 'line\
Terminator'
() { return 'get string'; }
static set 'line\
Terminator'
(param) { stringSet = param; }
};
assert.sameValue(C['lineTerminator'], 'get string');
C['lineTerminator'] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,35 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
AssignmentExpression may contain `in` keyword regardless of outer context
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var empty = Object.create(null);
var obj, value;
for (obj = { get ['x' in empty]() { return 'via get'; } }; ; ) {
value = obj.false;
break;
}
assert.sameValue(value, 'via get');
for (obj = { set ['x' in empty](param) { value = param; } }; ; ) {
obj.false = 'via set';
break;
}
assert.sameValue(value, 'via set');

View File

@ -0,0 +1,39 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as a YieldExpression within a generator function
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
features: [generators]
---*/
var yieldSet, obj, iter;
function* g() {
obj = {
get [yield]() { return 'get yield'; },
set [yield](param) { yieldSet = param; }
};
}
iter = g();
iter.next();
iter.next('first');
iter.next('second');
assert.sameValue(obj.first, 'get yield');
obj.second = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,32 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as an Identifier outside of a generator function
info: |
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
flags: [noStrict]
---*/
var yield = 'y';
var yieldSet;
var obj = {
get [yield]() { return 'get yield'; },
set [yield](param) { yieldSet = param; }
};
assert.sameValue(obj.y, 'get yield');
obj.y = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,40 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Computed values as accessor property names (string literal containing a line terminator) (Object initializer)
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
1. Let obj be ObjectCreate(%ObjectPrototype%).
2. Let status be the result of performing PropertyDefinitionEvaluation of
PropertyDefinitionList with arguments obj and true.
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var stringSet;
var obj = {
get ['line\
Terminator'
]() { return 'get string'; },
set ['line\
Terminator'
](param) { stringSet = param; }
};
assert.sameValue(obj['lineTerminator'], 'get string');
obj['lineTerminator'] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as a YieldExpression within a generator function
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
features: [generators]
---*/
var yieldSet, C, iter;
function* g() {
class C_ {
get [yield]() { return 'get yield'; }
set [yield](param) { yieldSet = param; }
}
C = C_;
}
iter = g();
iter.next();
iter.next('first');
iter.next('second');
assert.sameValue(C.prototype.first, 'get yield');
C.prototype.second = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Computed values as accessor property names (string literal containing a line terminator) (Class declaration, instance method)
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
i. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments proto and false.
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var stringSet;
class C {
get 'line\
Terminator'
() { return 'get string'; }
set 'line\
Terminator'
(param) { stringSet = param; }
}
assert.sameValue(C.prototype['lineTerminator'], 'get string');
C.prototype['lineTerminator'] = 'set string';
assert.sameValue(stringSet, 'set string');

View File

@ -0,0 +1,45 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object-initializer-runtime-semantics-evaluation
es6id: 12.2.6.8
description: >
The `yield` keyword behaves as a YieldExpression within a generator function
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
features: [generators]
---*/
var yieldSet, C, iter;
function* g() {
class C_ {
static get [yield]() { return 'get yield'; }
static set [yield](param) { yieldSet = param; }
}
C = C_;
}
iter = g();
iter.next();
iter.next('first');
iter.next('second');
assert.sameValue(C.first, 'get yield');
C.second = 'set yield';
assert.sameValue(yieldSet, 'set yield');

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Computed values as accessor property names (string literal containing a line terminator) (Class declaration, static method)
esid: sec-runtime-semantics-classdefinitionevaluation
es6id: 14.5.14
info: |
[...]
21. For each ClassElement m in order from methods
a. If IsStatic of m is false, then
[...]
b. Else,
a. Let status be the result of performing PropertyDefinitionEvaluation
for m with arguments F and false.
12.2.6.7 Runtime Semantics: Evaluation
[...]
ComputedPropertyName : [ AssignmentExpression ]
1. Let exprValue be the result of evaluating AssignmentExpression.
2. Let propName be ? GetValue(exprValue).
3. Return ? ToPropertyKey(propName).
---*/
var stringSet;
class C {
static get 'line\
Terminator'
() { return 'get string'; }
static set 'line\
Terminator'
(param) { stringSet = param; }
}
assert.sameValue(C['lineTerminator'], 'get string');
C['lineTerminator'] = 'set string';
assert.sameValue(stringSet, 'set string');