diff options
Diffstat (limited to 'js/src/tests/test262/language/statements/class/elements/gen-private-method')
13 files changed, 633 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/browser.js diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/shell.js diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000..385e2b978c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + var yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js new file mode 100644 index 0000000000..22dbaab59b --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + var yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000..2795745d2c --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + void yi\u0065ld; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js new file mode 100644 index 0000000000..b67e9655e0 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + void yield; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000..c08efad0c1 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + yi\u0065ld: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js new file mode 100644 index 0000000000..3137bbb7dd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// |reftest| error:SyntaxError +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +$DONOTEVALUATE(); + +class C { *#gen() { + yield: ; +}} diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js new file mode 100644 index 0000000000..d8ec3056cf --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-spread-strict-strict.js @@ -0,0 +1,85 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js new file mode 100644 index 0000000000..0d4ecfecc4 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-identifier-strict-strict.js @@ -0,0 +1,76 @@ +// |reftest| error:SyntaxError +'use strict'; +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +$DONOTEVALUATE(); + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js new file mode 100644 index 0000000000..5f066c3b1d --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-multiple.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield [...yield yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); +item = iter.next(item.value); + +assert.compareArray(item.value, arr); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js new file mode 100644 index 0000000000..e683264094 --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-arr-single.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-methods-private] +flags: [generated] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] +---*/ +var arr = ['a', 'b', 'c']; + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield [...yield]; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(false); +var item = iter.next(arr); +var value = item.value; + +assert.notSameValue(value, arr, 'value is a new array'); +assert(Array.isArray(value), 'value is an Array exotic object'); +assert.sameValue(value.length, 3) +assert.sameValue(value[0], 'a'); +assert.sameValue(value[1], 'b'); +assert.sameValue(value[2], 'c'); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js new file mode 100644 index 0000000000..cf3eb131fd --- /dev/null +++ b/js/src/tests/test262/language/statements/class/elements/gen-private-method/yield-spread-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-private-method.template +/*--- +description: Use yield value in a object spread position (Generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-methods-private] +flags: [generated] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +var iter = c.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +assert.sameValue(item.value.x, 42); +assert.sameValue(item.value.y, 39); +assert.sameValue(Object.keys(item.value).length, 2); +assert.sameValue(item.done, false); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert( + !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), + "Private field '#gen' does not appear as an own property on C prototype" +); +assert( + !Object.prototype.hasOwnProperty.call(C, "#gen"), + "Private field '#gen' does not appear as an own property on C constructor" +); +assert( + !Object.prototype.hasOwnProperty.call(c, "#gen"), + "Private field '#gen' does not appear as an own property on C instance" +); + +reportCompare(0, 0); |