diff --git a/src/accessor-names/computed-err-evaluation.case b/src/accessor-names/computed-err-evaluation.case new file mode 100644 index 0000000000..f2d4db8917 --- /dev/null +++ b/src/accessor-names/computed-err-evaluation.case @@ -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() diff --git a/src/accessor-names/computed-err-to-prop-key.case b/src/accessor-names/computed-err-to-prop-key.case new file mode 100644 index 0000000000..64e6e688d8 --- /dev/null +++ b/src/accessor-names/computed-err-to-prop-key.case @@ -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 diff --git a/src/accessor-names/computed-err-unresolvable.case b/src/accessor-names/computed-err-unresolvable.case new file mode 100644 index 0000000000..475e6fd638 --- /dev/null +++ b/src/accessor-names/computed-err-unresolvable.case @@ -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 diff --git a/src/accessor-names/computed.case b/src/accessor-names/computed.case new file mode 100644 index 0000000000..653402968d --- /dev/null +++ b/src/accessor-names/computed.case @@ -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' diff --git a/src/accessor-names/default/cls-decl-inst.template b/src/accessor-names/default/cls-decl-inst.template new file mode 100644 index 0000000000..ba8a7c25ea --- /dev/null +++ b/src/accessor-names/default/cls-decl-inst.template @@ -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'); diff --git a/src/accessor-names/default/cls-decl-static.template b/src/accessor-names/default/cls-decl-static.template new file mode 100644 index 0000000000..166c4f80e7 --- /dev/null +++ b/src/accessor-names/default/cls-decl-static.template @@ -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'); diff --git a/src/accessor-names/default/cls-expr-inst.template b/src/accessor-names/default/cls-expr-inst.template new file mode 100644 index 0000000000..3557bd4a8d --- /dev/null +++ b/src/accessor-names/default/cls-expr-inst.template @@ -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'); diff --git a/src/accessor-names/default/cls-expr-static.template b/src/accessor-names/default/cls-expr-static.template new file mode 100644 index 0000000000..23659a813e --- /dev/null +++ b/src/accessor-names/default/cls-expr-static.template @@ -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'); diff --git a/src/accessor-names/default/obj.template b/src/accessor-names/default/obj.template new file mode 100644 index 0000000000..5ceac65cf2 --- /dev/null +++ b/src/accessor-names/default/obj.template @@ -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'); diff --git a/src/accessor-names/error/cls-decl-inst.template b/src/accessor-names/error/cls-decl-inst.template new file mode 100644 index 0000000000..1a32ff17f8 --- /dev/null +++ b/src/accessor-names/error/cls-decl-inst.template @@ -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'); diff --git a/src/accessor-names/error/cls-decl-static.template b/src/accessor-names/error/cls-decl-static.template new file mode 100644 index 0000000000..1eea03e751 --- /dev/null +++ b/src/accessor-names/error/cls-decl-static.template @@ -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'); diff --git a/src/accessor-names/error/cls-expr-inst.template b/src/accessor-names/error/cls-expr-inst.template new file mode 100644 index 0000000000..00aca595c9 --- /dev/null +++ b/src/accessor-names/error/cls-expr-inst.template @@ -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'); diff --git a/src/accessor-names/error/cls-expr-static.template b/src/accessor-names/error/cls-expr-static.template new file mode 100644 index 0000000000..692b90f1b4 --- /dev/null +++ b/src/accessor-names/error/cls-expr-static.template @@ -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'); diff --git a/src/accessor-names/error/obj.template b/src/accessor-names/error/obj.template new file mode 100644 index 0000000000..d4e197cfc2 --- /dev/null +++ b/src/accessor-names/error/obj.template @@ -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'); diff --git a/src/accessor-names/literal-numeric-binary.case b/src/accessor-names/literal-numeric-binary.case new file mode 100644 index 0000000000..8a240aa7c7 --- /dev/null +++ b/src/accessor-names/literal-numeric-binary.case @@ -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' diff --git a/src/accessor-names/literal-numeric-exponent.case b/src/accessor-names/literal-numeric-exponent.case new file mode 100644 index 0000000000..e631dab780 --- /dev/null +++ b/src/accessor-names/literal-numeric-exponent.case @@ -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' diff --git a/src/accessor-names/literal-numeric-hex.case b/src/accessor-names/literal-numeric-hex.case new file mode 100644 index 0000000000..669502a300 --- /dev/null +++ b/src/accessor-names/literal-numeric-hex.case @@ -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' diff --git a/src/accessor-names/literal-numeric-leading-decimal.case b/src/accessor-names/literal-numeric-leading-decimal.case new file mode 100644 index 0000000000..a9ae1c7a27 --- /dev/null +++ b/src/accessor-names/literal-numeric-leading-decimal.case @@ -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' diff --git a/src/accessor-names/literal-numeric-non-canonical.case b/src/accessor-names/literal-numeric-non-canonical.case new file mode 100644 index 0000000000..18ddb93299 --- /dev/null +++ b/src/accessor-names/literal-numeric-non-canonical.case @@ -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' diff --git a/src/accessor-names/literal-numeric-octal.case b/src/accessor-names/literal-numeric-octal.case new file mode 100644 index 0000000000..ad48462834 --- /dev/null +++ b/src/accessor-names/literal-numeric-octal.case @@ -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' diff --git a/src/accessor-names/literal-numeric-zero.case b/src/accessor-names/literal-numeric-zero.case new file mode 100644 index 0000000000..5d2bc8a3a5 --- /dev/null +++ b/src/accessor-names/literal-numeric-zero.case @@ -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' diff --git a/src/accessor-names/literal-string-char-escape.case b/src/accessor-names/literal-string-char-escape.case new file mode 100644 index 0000000000..5c13028c15 --- /dev/null +++ b/src/accessor-names/literal-string-char-escape.case @@ -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' diff --git a/src/accessor-names/literal-string-double-quote.case b/src/accessor-names/literal-string-double-quote.case new file mode 100644 index 0000000000..13117b4834 --- /dev/null +++ b/src/accessor-names/literal-string-double-quote.case @@ -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" diff --git a/src/accessor-names/literal-string-empty.case b/src/accessor-names/literal-string-empty.case new file mode 100644 index 0000000000..5ff1f60f4b --- /dev/null +++ b/src/accessor-names/literal-string-empty.case @@ -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 +'' diff --git a/src/accessor-names/literal-string-hex-escape.case b/src/accessor-names/literal-string-hex-escape.case new file mode 100644 index 0000000000..54cbd3d09a --- /dev/null +++ b/src/accessor-names/literal-string-hex-escape.case @@ -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' diff --git a/src/accessor-names/literal-string-single-quote.case b/src/accessor-names/literal-string-single-quote.case new file mode 100644 index 0000000000..c473f4e6c2 --- /dev/null +++ b/src/accessor-names/literal-string-single-quote.case @@ -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' diff --git a/src/accessor-names/literal-string-unicode-escape.case b/src/accessor-names/literal-string-unicode-escape.case new file mode 100644 index 0000000000..8ecb8bb7b9 --- /dev/null +++ b/src/accessor-names/literal-string-unicode-escape.case @@ -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' diff --git a/test/language/expressions/class/accessor-name-inst-computed-in.js b/test/language/expressions/class/accessor-name-inst-computed-in.js new file mode 100644 index 0000000000..4056b71b40 --- /dev/null +++ b/test/language/expressions/class/accessor-name-inst-computed-in.js @@ -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'); diff --git a/test/language/expressions/class/accessor-name-inst-computed-yield-expr.js b/test/language/expressions/class/accessor-name-inst-computed-yield-expr.js new file mode 100644 index 0000000000..2cd67d5311 --- /dev/null +++ b/test/language/expressions/class/accessor-name-inst-computed-yield-expr.js @@ -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'); diff --git a/test/language/expressions/class/accessor-name-inst-literal-string-line-terminator.js b/test/language/expressions/class/accessor-name-inst-literal-string-line-terminator.js new file mode 100644 index 0000000000..693d03160c --- /dev/null +++ b/test/language/expressions/class/accessor-name-inst-literal-string-line-terminator.js @@ -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'); diff --git a/test/language/expressions/class/accessor-name-static-computed-in.js b/test/language/expressions/class/accessor-name-static-computed-in.js new file mode 100644 index 0000000000..257d416f2d --- /dev/null +++ b/test/language/expressions/class/accessor-name-static-computed-in.js @@ -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'); diff --git a/test/language/expressions/class/accessor-name-static-computed-yield-expr.js b/test/language/expressions/class/accessor-name-static-computed-yield-expr.js new file mode 100644 index 0000000000..5221f36874 --- /dev/null +++ b/test/language/expressions/class/accessor-name-static-computed-yield-expr.js @@ -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'); diff --git a/test/language/expressions/class/accessor-name-static-literal-string-line-terminator.js b/test/language/expressions/class/accessor-name-static-literal-string-line-terminator.js new file mode 100644 index 0000000000..be13537550 --- /dev/null +++ b/test/language/expressions/class/accessor-name-static-literal-string-line-terminator.js @@ -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'); diff --git a/test/language/expressions/object/accessor-name-computed-in.js b/test/language/expressions/object/accessor-name-computed-in.js new file mode 100644 index 0000000000..f98519658a --- /dev/null +++ b/test/language/expressions/object/accessor-name-computed-in.js @@ -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'); diff --git a/test/language/expressions/object/accessor-name-computed-yield-expr.js b/test/language/expressions/object/accessor-name-computed-yield-expr.js new file mode 100644 index 0000000000..59aef8d584 --- /dev/null +++ b/test/language/expressions/object/accessor-name-computed-yield-expr.js @@ -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'); diff --git a/test/language/expressions/object/accessor-name-computed-yield-id.js b/test/language/expressions/object/accessor-name-computed-yield-id.js new file mode 100644 index 0000000000..b7c10187b2 --- /dev/null +++ b/test/language/expressions/object/accessor-name-computed-yield-id.js @@ -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'); diff --git a/test/language/expressions/object/accessor-name-literal-string-line-terminator.js b/test/language/expressions/object/accessor-name-literal-string-line-terminator.js new file mode 100644 index 0000000000..bb230c3ad4 --- /dev/null +++ b/test/language/expressions/object/accessor-name-literal-string-line-terminator.js @@ -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'); diff --git a/test/language/statements/class/accessor-name-inst-computed-yield-expr.js b/test/language/statements/class/accessor-name-inst-computed-yield-expr.js new file mode 100644 index 0000000000..c0719c72ad --- /dev/null +++ b/test/language/statements/class/accessor-name-inst-computed-yield-expr.js @@ -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'); diff --git a/test/language/statements/class/accessor-name-inst-literal-string-line-terminator.js b/test/language/statements/class/accessor-name-inst-literal-string-line-terminator.js new file mode 100644 index 0000000000..a9fa0c268c --- /dev/null +++ b/test/language/statements/class/accessor-name-inst-literal-string-line-terminator.js @@ -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'); diff --git a/test/language/statements/class/accessor-name-static-computed-yield-expr.js b/test/language/statements/class/accessor-name-static-computed-yield-expr.js new file mode 100644 index 0000000000..fe0ae13a93 --- /dev/null +++ b/test/language/statements/class/accessor-name-static-computed-yield-expr.js @@ -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'); diff --git a/test/language/statements/class/accessor-name-static-literal-string-line-terminator.js b/test/language/statements/class/accessor-name-static-literal-string-line-terminator.js new file mode 100644 index 0000000000..b68f24df8c --- /dev/null +++ b/test/language/statements/class/accessor-name-static-literal-string-line-terminator.js @@ -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');