diff --git a/src/async-functions/syntax/async-class-decl-static-private-method.template b/src/async-functions/syntax/async-class-decl-static-private-method.template index 0bede5a4590a0b16cb1a81ff51d1071fced7e1cf..5d9e912804d96ae47ffdb5001af5900186b775ff 100644 --- a/src/async-functions/syntax/async-class-decl-static-private-method.template +++ b/src/async-functions/syntax/async-class-decl-static-private-method.template @@ -16,7 +16,7 @@ info: | AsyncMethod : async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } -features: [async-functions, class-methods-private] +features: [async-functions, class-static-methods-private] ---*/ class C { static async #method() { diff --git a/src/async-functions/syntax/async-class-expr-static-private-method.template b/src/async-functions/syntax/async-class-expr-static-private-method.template index ab154f12f57e9b6de4e3dc5a2aaef1eed477095e..136b6782ebc2cac3f3768574daefbe90d06de3f0 100644 --- a/src/async-functions/syntax/async-class-expr-static-private-method.template +++ b/src/async-functions/syntax/async-class-expr-static-private-method.template @@ -16,7 +16,7 @@ info: | AsyncMethod : async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } -features: [async-functions, class-methods-private] +features: [async-functions, class-static-methods-private] ---*/ var C = class { static async #method() { diff --git a/src/async-generators/syntax/async-class-decl-static-private-method.template b/src/async-generators/syntax/async-class-decl-static-private-method.template index afa110b27cd9857564702665c17ce9e03b421d82..ad427cca7b28700dc593a82cc63f56073d526096 100644 --- a/src/async-generators/syntax/async-class-decl-static-private-method.template +++ b/src/async-generators/syntax/async-class-decl-static-private-method.template @@ -16,7 +16,7 @@ info: | AsyncGeneratorMethod : async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } -features: [async-iteration, class-methods-private] +features: [async-iteration, class-static-methods-private] ---*/ class C { static async *#gen() { diff --git a/src/async-generators/syntax/async-class-expr-static-private-method.template b/src/async-generators/syntax/async-class-expr-static-private-method.template index c69608ebf41c8d479104874a8a8410d3bad99a24..52324446ea9ac132aa9ce60f492cf6d17028f758 100644 --- a/src/async-generators/syntax/async-class-expr-static-private-method.template +++ b/src/async-generators/syntax/async-class-expr-static-private-method.template @@ -16,7 +16,7 @@ info: | AsyncGeneratorMethod : async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } -features: [async-iteration, class-methods-private] +features: [async-iteration, class-static-methods-private] ---*/ var C = class { static async *#gen() { diff --git a/src/generators/default/class-decl-private-method.template b/src/generators/default/class-decl-private-method.template index 3d5c4f69160a991221dbb8b030c2f5aa5cc1981c..933dcfcbb600fa53d105f9085383edefc783a116 100644 --- a/src/generators/default/class-decl-private-method.template +++ b/src/generators/default/class-decl-private-method.template @@ -20,7 +20,7 @@ features: [generators, class-methods-private] var callCount = 0; -class C { +class C { *#gen() { callCount += 1; /*{ body }*/ diff --git a/src/generators/syntax/class-decl-static-private-method.template b/src/generators/syntax/class-decl-static-private-method.template index cf55b4d5ac8e4ebe1a51477da98149d12fb3cea4..c240dbee809301a3f54e6bc5d37ccac0af8df892 100644 --- a/src/generators/syntax/class-decl-static-private-method.template +++ b/src/generators/syntax/class-decl-static-private-method.template @@ -15,7 +15,7 @@ info: | GeneratorMethod : * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } -features: [generators, class-methods-private] +features: [generators, class-static-methods-private] ---*/ class C {static *#gen() { diff --git a/src/generators/syntax/class-expr-static-private-method.template b/src/generators/syntax/class-expr-static-private-method.template index b66123d79db4a684e656b8e32ce35ef5f9266582..e436df940f7a8ecec376e3e838b59cf538435fdf 100644 --- a/src/generators/syntax/class-expr-static-private-method.template +++ b/src/generators/syntax/class-expr-static-private-method.template @@ -15,7 +15,7 @@ info: | GeneratorMethod : * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } -features: [generators, class-methods-private] +features: [generators, class-static-methods-private] ---*/ var C = class { static *#gen() { diff --git a/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..8fa3749e7033fce9e58e74437b3d9f8c979f1bb0 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + var \u0061wait; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier.js b/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..6fa19021123263bff5deb1cb8f88a8c0722198c8 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + var await; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference-escaped.js b/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..72c1b1fbba0656412caf189707dc1158833f61ad --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + void \u0061wait; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference.js b/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..544dfb3454f39331e57b758995d7d9840fb76f28 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + void await; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-await-as-label-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..3eb1e6f07894a4bb1d4f25434d2ef902b1c075fe --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + \u0061wait: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-await-as-label-identifier.js b/test/language/expressions/class/async-gen-private-method-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..08ea5255b01a5f921dc508589e6a724a8a5fb92f --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + await: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..794a2bf25536457fac3e25cde61cd6ba29c4588d --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + var \u0061wait; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier.js b/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..88fc1e49bfafc59548d65d596e36a4afee8d2889 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + var await; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js b/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..3c49bc3488dfc3ada70fb6c1ff8d05e549335272 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + void \u0061wait; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference.js b/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..dc3f1041013ef5f43dadc0fff1cf0019cf29df40 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + void await; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..7960a94dab8968ba8b8eade5a0827bbfe281bb0d --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + \u0061wait: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier.js b/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..60cf1ade227896d928aa5f05ea716b1a4b8ba937 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + await: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..820f61eda517d4e79616132619246a48d55e4b50 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + var yi\u0065ld; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..b29bb2f8bfda9074129999c85242bc437f91a270 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + var yield; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..1d74a5ca188729ccab068a7b763d36832835e960 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + void yi\u0065ld; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..7dbfcfdd7afc8b68d7dfa2f623c43e6e1fe33b6b --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + void yield; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..f217faf8d90260f8c62fec8c8da6d0cb25daaa44 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + yi\u0065ld: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier.js b/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..de1d36a471d320df58ae6719bde0b8e0a6431047 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async *#gen() { + yield: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-identifier-spread-strict.js b/test/language/expressions/class/async-gen-private-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..97e390c5f29cddd8cb5f40b5da815f2f4ec70090 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-identifier-strict.js b/test/language/expressions/class/async-gen-private-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..6399fd462779ca922ed9d7d9426586d721a12a52 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-identifier-strict.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-expr-static-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. (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-catch.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..7cf9caa82403cac0c44b44c136984136212ff1c6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-catch.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..3a5078c0f95aa7c7d1e34c039be3ed937f71a273 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..d14246a5cad2b4023dae9ca016b747a9f5dcf8df --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..e3caca2ca2569df99c84473ccc84f100714d7461 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield * readFile(); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..8dd4ae7d77c5e5e1265e4066d23d19a461e962ff --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield * iterable; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next.js b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next.js new file mode 100644 index 0000000000000000000000000000000000000000..03be053f3176942ecdc28aee3de14bd94bbedcb2 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-promise-reject-next.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-multiple.js b/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..ca2490c4c708c6e287525c149f1fb2b0844acd79 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-single.js b/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..051a73404cecbaf7f6dbe226fed60a557fdbbc81 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-spread-arr-single.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, 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(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-spread-obj.js b/test/language/expressions/class/async-gen-private-method-static-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..b288a280286ab98a137bce7c7c3f4d853a785eef --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-spread-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-async-next.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-next.js new file mode 100644 index 0000000000000000000000000000000000000000..9ae13afa52b4df02f89d60e780aa14958bf9e794 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-next.js @@ -0,0 +1,234 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-async-return.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-return.js new file mode 100644 index 0000000000000000000000000000000000000000..ffe62ff333d115abd6091476f140ed2c2e5782c3 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-return.js @@ -0,0 +1,250 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-async-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..87d0eda7cfe584f7eff0e08d5345785ae34052fa --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-async-throw.js @@ -0,0 +1,258 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-expr-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-expr-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..eac46893dffae7594fc4a99f83262d64916bcd9a --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-expr-abrupt.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..7029c56050945ffac4248d3153dbc71cd8b50f48 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..89ec007d61514b6fd99c11cee855e50053f4ee7b --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4a99bac22db5a0a10ddad923665a353f9e2817de --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..70e7baeed591b933f9d11c478e13ef7bb2c4bd26 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c3464ff4044c87cd9db06f50c4330461eac9fb33 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4ae2d74a1584fd1a6a7d84626887c9bda2fae5f4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2ecd88a808603401c453738aeb67c96f75d6e211 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4feb8ca988d555287ec3d9810dfa8eb8ad09e746 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6bbced4d77f286eb2f5a3cd66430fe6550cd1500 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..124044db6eb95693061b97aad853792648e6bf32 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..32c32490bfc9ba9a18625bba82e5f1fa56a9127e --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..82d2e5f0437d1917d20508e0dc20922b55f643f6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0bfd04a60018988b760423380394785da05d16c5 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e781f0bf90f7f7ce2034078d4035dd0980409982 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..638baadc17918f28d00440409924d9f377212168 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..291ec8a6ff05fb60d5f8474dd446d3d70b39d200 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7865731e76749836ede35db1110bb3f3d318fd72 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0bd1c16d38426f6679f968f752ef1cc9046c0ce5 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e776365d41cf4e7574351fcc48f8f37a56c37dd3 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..dca98894769c2af5932cab848792436c51986ab4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..512a1ebd145309b0d9e924f0694331d5a83823ee --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..0eceee73ffa93a6f499a3da5607cb944f0a8a960 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f4469eb59b523abba786dce4398426f6585256fd --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e42fe2ae329df50c888bffb7f17fd97e8efcb426 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3732426b8ac59f7add3d6c6a4b4ba8acea5d0dd3 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b0960e20e9b9d78d20bc21850414b444bdef9335 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e8d3189c2b6e3c9ae99d3a832d05624213feb2cc --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..1fae26f520bcb0ac2f26068aec076b9c3d16105c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..ce4b4966bdc1fe8887694a70fbe8edbb8a1191d0 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2f8f02e28e3be66a0f42c935d86fe9f9de7d1704 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..1cce9f4b5ce4d39a2df31801a07656716aa1b352 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d3082648e415f41c5faf33c4c3d8ecda6a471c19 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..0dd5915ff7b70875922251b7eb3001f81f1fec93 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..bb85ca50e7db38d91b478fd256b0371e6c0464d6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..fbe9e4d974fef2185685b3bf66e2898fd141d57b --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6a7b05c8a0ee6f3f12662a5ffecb8fa5e9f23361 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b88dd570a485c705e8d07af3e0e0c35262decbb3 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c5597af4a48bb169d95687feccdf5daf9a78a5c2 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..72c31f73f87ac189687bd1cb5135f168dc590ea9 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8f2e964501a82c437003857176b5fda03a74c164 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..480d8c64a81c9b6351c50b24852fac396fa291cc --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..5d68064b9142af5cba2e114f59bc133d61a9e0fc --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6082230b17c046f254c31482bb0461a1d94ebd4b --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..e336c7a19ba57ccb4bac7b74f5cf362553f27bb6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6bbc9001a50e53fd8da09fa1ef8140a0904c9d6c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..110db43d7f474cfd6afb46961772e31f389fa42e --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..3be5426208f1357cbb6fe8297a59613259e64e54 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6f329bf7aafdf7cbd73617b4961dfe255dafbad5 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4be44dfb0a03b996a0435ee4d0c1d737bafb8d9c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-next.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-next.js new file mode 100644 index 0000000000000000000000000000000000000000..ec12b1168e0d7339ac71d5390b0614616e324f37 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-next.js @@ -0,0 +1,237 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-return.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-return.js new file mode 100644 index 0000000000000000000000000000000000000000..e552ab24d7c34bb52e66462d14598fb19c3ac3ef --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-return.js @@ -0,0 +1,212 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-throw.js b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7d75d915efde91f4d4ef5952b3693ed830f37902 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-static-yield-star-sync-throw.js @@ -0,0 +1,218 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-expr-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Static async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e73503e9297cb9c294d063ae59c017ca6f084f69 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + var yi\u0065ld; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier.js b/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..47c13d57a9a9ef391067bc275633f16e9d189721 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + var yield; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference-escaped.js b/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..93442dd7ae08c6cae32ab12e42bd2a54e1137ebe --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + void yi\u0065ld; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference.js b/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..cedb862550321b27ef85845b8d1d8cd3707c93d7 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + void yield; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier-escaped.js b/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..1d5580f0f6f96113c9c31955461094f3207d1073 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + yi\u0065ld: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier.js b/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..0426cab9349bb5076fe9783291503b8f7b6bc413 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async generator private method as a ClassExpression element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async *#gen() { + yield: ; +}}; diff --git a/test/language/expressions/class/async-gen-private-method-yield-identifier-spread-strict.js b/test/language/expressions/class/async-gen-private-method-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..8047dc96439504c0468bc79073f9033ad43ceecd --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-identifier-spread-strict.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +var C = class { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-identifier-strict.js b/test/language/expressions/class/async-gen-private-method-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..f0a34bf93f6615178a670c3df70216ce0f25a3ce --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-identifier-strict.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-expr-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. (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +var C = class { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-catch.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..25a9f68c2bd8c9569778427b4e5f96489ab7a89e --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-catch.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..a2fd7c9a80c891994e2985c4b1264c5a71782b74 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..c878da09a2d8baecec8d764fd6a7e202148934e2 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..44a57ad61901e390a0003a978739df48012da247 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield * readFile(); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..64a43550422aea9eac1a6b51ebedbe24181e86bd --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield * iterable; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next.js b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next.js new file mode 100644 index 0000000000000000000000000000000000000000..7ee5e440a8c5481d39268513468013ad92e99965 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-promise-reject-next.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-spread-arr-multiple.js b/test/language/expressions/class/async-gen-private-method-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..3ddff189c4f9396c770c12fac09b2412b59ecd88 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-spread-arr-multiple.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Use yield value in a array spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +var C = class { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-spread-arr-single.js b/test/language/expressions/class/async-gen-private-method-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..736e51d0972f6363dd0db83ab6f78703c5eb183f --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-spread-arr-single.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Use yield value in a array spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +var C = class { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, 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(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-spread-obj.js b/test/language/expressions/class/async-gen-private-method-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..0a66df31dc5f467381463f92daf41abb8e456c23 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-spread-obj.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Use yield value in a object spread position (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +var C = class { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-async-next.js b/test/language/expressions/class/async-gen-private-method-yield-star-async-next.js new file mode 100644 index 0000000000000000000000000000000000000000..f90d553efc6d3082421d83820cd0be9c39b8517a --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-async-next.js @@ -0,0 +1,238 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-async-return.js b/test/language/expressions/class/async-gen-private-method-yield-star-async-return.js new file mode 100644 index 0000000000000000000000000000000000000000..a63eaff087c71fac2a27d652b0be9b1e35531898 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-async-return.js @@ -0,0 +1,254 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-async-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-async-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..cd249d34bc860004cf6f39a57557f840dd0e5d22 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-async-throw.js @@ -0,0 +1,262 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-expr-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-expr-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2e09d5b8e2cedc26352d1ad37526c0b346db5d09 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-expr-abrupt.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2041684a0b4510dd6ed3997da473bbc82d481af2 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c475f24927921dab9bfda455421e6e832260b463 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..33386e19627575a1bc1a4157196692a2b8ab4924 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..37a6cf24cb2ef94193165293fefeaa18b1ed6e07 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..9574d3604d260abd87e210966225e28bbf72d63d --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e5494abf829cab885b56f332bd5666b723b03edb --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..853243004655bc638cdcf64fb696325ef43209a4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d67e5df3d673a1f20e9799d612aebe94a6bc2f8c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..650a937861be2207a5317c6b85ad3a7a8a346ba4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..a39991d6089ce1f6a53948b13256f5b8518ce972 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..ec3fb996b2691cdb8c2b146b05f0242d1f348fab --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..2e37d8ca2b5f0dc56eb54eef908a2304820564c6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..503c9c214f622127b57111ab2b110b954626d54f --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4ffe9bc26ce3a8111b097b4306adaf011299009b --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d4763eed7330486ccbfb9c18e892590a78c0efbb --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..ee8c597a2a606b6090739c17a0f91718ed995328 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..82d8f8c9e048fac3c0abcb77023662002389ca63 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b51a6ef89c88a5b9b675b9b5c00e28b0d817e193 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..78984ad3a082b603695f5d91024141ddb1d96ac9 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3f1f866d78e1488220511ef46e4d169d8f996d20 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c93ca91a3a18075a7630f03b4629f49ac0ec4821 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..cf1f69c6c35e19b94f7953c7d653105ca9f8aa5d --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3c70d1f3d7f02fe94cbfcd43de1bf914150c8713 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..097f04f7f7a6aff34dc0662a96135c18305a462c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..ee8525224e05d7a0afb36bf878d8203255a5dcae --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..81ad0a7ce5d6ea43b1181afec023d71fdaba68b8 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..d43176aa681ec012907dd61561f1319b7398f20c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..24bc2f4826c2f0da437c6ab4e637a3840b4f2a87 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..3a664175948da2f6e8d877d28f8b37ebe0b7a143 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting done (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..798b468c98bb92e8c86668c43aa9bb2d634dfc66 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while calling next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..2d2e276e28b4aabab66be3e62405471c72c9ef25 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting value (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..12a529f8744af3b4d0d81990812879641deba7f6 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-get-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Abrupt completion while getting next (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..cbfb1f6c663276ca279048fcb9b1f366fa114037 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b49225aad376013aad26cd334c2604e21b319b98 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f57460836f90ec077c0312989644cb39a6655066 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..72f7cd34cde3a9d19abf32383e873a2fa410f73e --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..978b3ffd13dc1e0549551b5e6db102842181da7e --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3cdf91862b2151a96d43d0374b4d3fd471bc406c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..5952a8e879dbce17038ee7c5aab172654373b410 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..a5eca3bc83939a83efd44e4f5fb99c699dede1eb --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-get-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..428784d0aea7bb33a8a23406ceffde1e9b136fbc --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Return abrupt after getting next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..dc98b06a5ca5809734afbf8fa1aeb9840f2efe5c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2bb6b3bbc912209da384ca7b84c8b2dac9aaf6b3 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..35a48cafd0edad93bdb51f21fc8eeeed5f8b87f4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..1c00e4adba0c55e67484c1a13b9952c626b0a04c --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..bc7a17cecfdb50d850563ddc4c2d25169a203cd4 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..83b602362de9d9b71470ec66b9fe91e5178c5a27 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..a9610c7896638185927f332634e26082df763025 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..cead3eba41aa525bfe3ae8f2a14c3cb266370c9a --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: Return abrupt after calling next().then (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-sync-next.js b/test/language/expressions/class/async-gen-private-method-yield-star-sync-next.js new file mode 100644 index 0000000000000000000000000000000000000000..ddb852271540698f76be374d6dd31f20753fa651 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-sync-next.js @@ -0,0 +1,241 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-sync-return.js b/test/language/expressions/class/async-gen-private-method-yield-star-sync-return.js new file mode 100644 index 0000000000000000000000000000000000000000..d9dcc8b2ccedceee50ca16e424055f0f0c8084ae --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-sync-return.js @@ -0,0 +1,216 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-gen-private-method-yield-star-sync-throw.js b/test/language/expressions/class/async-gen-private-method-yield-star-sync-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7e9dd181f5bce62f1eaf8d5a2792b2d0788fa2b9 --- /dev/null +++ b/test/language/expressions/class/async-gen-private-method-yield-star-sync-throw.js @@ -0,0 +1,222 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-expr-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Async generator method as a ClassExpression element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/async-private-method-await-as-binding-identifier-escaped.js b/test/language/expressions/class/async-private-method-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..3dcd9f86f4ad3a4d0a91f47046fb999d780b97f1 --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + var \u0061wait; +}}; diff --git a/test/language/expressions/class/async-private-method-await-as-binding-identifier.js b/test/language/expressions/class/async-private-method-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..2ad9a3fbd90548284df23f8ff4a30b9a68990b32 --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + var await; +}}; diff --git a/test/language/expressions/class/async-private-method-await-as-identifier-reference-escaped.js b/test/language/expressions/class/async-private-method-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..51b0452cc1814ffc71ded325a123ec456a2fd7f2 --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + void \u0061wait; +}}; diff --git a/test/language/expressions/class/async-private-method-await-as-identifier-reference.js b/test/language/expressions/class/async-private-method-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..06fefecd36b66a79858defd08351a5b6d8797a56 --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + void await; +}}; diff --git a/test/language/expressions/class/async-private-method-await-as-label-identifier-escaped.js b/test/language/expressions/class/async-private-method-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..bd62bbab30973b63270b5cbcad3abd7d2772627d --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + \u0061wait: ; +}}; diff --git a/test/language/expressions/class/async-private-method-await-as-label-identifier.js b/test/language/expressions/class/async-private-method-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..6009bd29492e32c0ed7c96e899bb037c93991b98 --- /dev/null +++ b/test/language/expressions/class/async-private-method-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-expr-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { async #method() { + await: ; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-binding-identifier-escaped.js b/test/language/expressions/class/async-private-method-static-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..9d70f6895b374e8c4a14bc67317449f0e9e33bbd --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + var \u0061wait; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-binding-identifier.js b/test/language/expressions/class/async-private-method-static-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..547b83958bd787c628946bef3738b603ce6b5f7c --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + var await; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-identifier-reference-escaped.js b/test/language/expressions/class/async-private-method-static-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..6ced99024163a769d96e9f5cac07286f3b2ea03d --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + void \u0061wait; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-identifier-reference.js b/test/language/expressions/class/async-private-method-static-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..3701d29201ad1d4780bcb05b930e7391a88c6f5c --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + void await; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-label-identifier-escaped.js b/test/language/expressions/class/async-private-method-static-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..f1016e84bb63eb608fceff42bab75871182ce5bc --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + \u0061wait: ; +}}; diff --git a/test/language/expressions/class/async-private-method-static-await-as-label-identifier.js b/test/language/expressions/class/async-private-method-static-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..183b6c0e061889b2732a196cbaabf5d8a4564149 --- /dev/null +++ b/test/language/expressions/class/async-private-method-static-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-expr-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static private async method as a ClassExpression element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var C = class { static async #method() { + await: ; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier-escaped.js b/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..ee7d55fae4e37816e876f314d6f1caba145fa6b3 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + var yi\u0065ld; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier.js b/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..0c8c6ba0e4ec2e20f00c601b748f60565705c146 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-binding-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + var yield; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference-escaped.js b/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..4c3a128f44a062c2014888c1ed7ea1ead006496d --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + void yi\u0065ld; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference.js b/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..661c0b9d38ee50b243d266135a03b3a70984519e --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-identifier-reference.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + void yield; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier-escaped.js b/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..7af70b228815a625664c3fced420533a8bae4655 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + yi\u0065ld: ; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier.js b/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..589d1fba5b17ad1175a235e20a32961b9295b914 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-as-label-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-expr-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class { static *#gen() { + yield: ; +}}; diff --git a/test/language/expressions/class/gen-private-method-static-yield-identifier-spread-strict.js b/test/language/expressions/class/gen-private-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..e7071edc10f38ec8c52fc4fb0f3c1d961dba61ff --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-expr-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +var C = class { + static *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-static-yield-identifier-strict.js b/test/language/expressions/class/gen-private-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..125d37ad3b62c66deeda1a1153883d4ced4e3840 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-identifier-strict.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-expr-static-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. (Static generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +var C = class { + static *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-static-yield-spread-arr-multiple.js b/test/language/expressions/class/gen-private-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..22d1d6ce7aefa50e92fbb49554c313593d1d21d1 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-expr-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static 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; + +var C = class { + static *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-static-yield-spread-arr-single.js b/test/language/expressions/class/gen-private-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..53a7de857267b930c71613e5065c69025c1bbf38 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-spread-arr-single.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-expr-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + static 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; + +var C = class { + static *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-static-yield-spread-obj.js b/test/language/expressions/class/gen-private-method-static-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..b42b7f64c8c8d4ad430ffb12758313552fdc1050 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-static-yield-spread-obj.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-expr-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var C = class { + static *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-yield-as-binding-identifier-escaped.js b/test/language/expressions/class/gen-private-method-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e08ff26c06e2db06c49a6e1970df38de5bec9d72 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-binding-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + var yi\u0065ld; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-as-binding-identifier.js b/test/language/expressions/class/gen-private-method-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..6c805cd45816464a3d8f40966c61002894cf0d4e --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-binding-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + var yield; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-as-identifier-reference-escaped.js b/test/language/expressions/class/gen-private-method-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..6ea9bbe26bb418ad474a53feab7d356c919e218c --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-identifier-reference-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + void yi\u0065ld; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-as-identifier-reference.js b/test/language/expressions/class/gen-private-method-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..6011e526493c027775d1d5791825615a79e69a6d --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-identifier-reference.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + void yield; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-as-label-identifier-escaped.js b/test/language/expressions/class/gen-private-method-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..9df4259202753e6e9388d58f8712891e4d40335a --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-label-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + yi\u0065ld: ; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-as-label-identifier.js b/test/language/expressions/class/gen-private-method-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..a1b47ef2f74c225b5d10a88d312701b3cdb5a155 --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-as-label-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-expr-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Generator private method as a ClassExpression 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +var C = class {*#gen() { + yield: ; +}}; diff --git a/test/language/expressions/class/gen-private-method-yield-identifier-spread-strict.js b/test/language/expressions/class/gen-private-method-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..4c758b7483b1d5c88bff997ebb2da602d57f418c --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-identifier-spread-strict.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-expr-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 ClassExpression 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] + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +var C = class { + *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-yield-identifier-strict.js b/test/language/expressions/class/gen-private-method-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..d06c0d967056a72da11d145a5fccb07f69eb20bb --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-identifier-strict.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-expr-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 ClassExpression 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 } + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +var C = class { + *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-yield-spread-arr-multiple.js b/test/language/expressions/class/gen-private-method-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..51dbe6425c75502c2e272e1505fa8a900f7b7a6b --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-spread-arr-multiple.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-expr-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassExpression 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; + +var C = class { + *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-yield-spread-arr-single.js b/test/language/expressions/class/gen-private-method-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..83195161351a8b1c599d5bcd93625a3e768ac81a --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-spread-arr-single.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-expr-private-method.template +/*--- +description: Use yield value in a array spread position (Generator private method as a ClassExpression 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; + +var C = class { + *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/expressions/class/gen-private-method-yield-spread-obj.js b/test/language/expressions/class/gen-private-method-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..c0bd525a32d5c380fbb8bc7e0d8d66a116fe602d --- /dev/null +++ b/test/language/expressions/class/gen-private-method-yield-spread-obj.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-expr-private-method.template +/*--- +description: Use yield value in a object spread position (Generator private method as a ClassExpression element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +var C = class { + *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-await-as-binding-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..a8d3265daa766ad11dc92239e57c94a0e38a1484 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + var \u0061wait; +}} diff --git a/test/language/statements/class/async-gen-private-method-await-as-binding-identifier.js b/test/language/statements/class/async-gen-private-method-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..62a36bed7f3182e7b6a888de22aef88de2bc541a --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + var await; +}} diff --git a/test/language/statements/class/async-gen-private-method-await-as-identifier-reference-escaped.js b/test/language/statements/class/async-gen-private-method-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..5c6ed7c7aaee59fa445f4df5c008e7f51887552d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + void \u0061wait; +}} diff --git a/test/language/statements/class/async-gen-private-method-await-as-identifier-reference.js b/test/language/statements/class/async-gen-private-method-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..a128bd805215d92059d6b1e4b889cb4dac243228 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + void await; +}} diff --git a/test/language/statements/class/async-gen-private-method-await-as-label-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..4b388a514abeaefde413bdbc028584fc37c3cba3 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + \u0061wait: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-await-as-label-identifier.js b/test/language/statements/class/async-gen-private-method-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..e00273f3e1818a0b5a6c6ea92acb537609688d41 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + await: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..7b97e191c27c6c40ae210f4b6beb01f2d891771b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + var \u0061wait; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier.js b/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..ea1768a13acc3d51b69d8c5d9613f3bd658f03b0 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + var await; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js b/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..00a2ff7ef9731e5b5133c60a25d1d0ea89ea06c3 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + void \u0061wait; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference.js b/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..c2b10fff8d1b723a4bd65014247a9a0a2226db87 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + void await; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e28610afadefebf12899b17cac98ad87c934f870 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + \u0061wait: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier.js b/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..5c933328a58cb454cfc92f62c7303c4a64b677e9 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/await-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + await: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..545228f4d0701465b1a7dcf483322a767d161d4b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + var yi\u0065ld; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier.js b/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..6f05b86df55cb8e838dad64c45c223c66a152221 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + var yield; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js b/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..a87d5c18585b6c4ac074cc7c112bf79d9793815e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + void yi\u0065ld; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference.js b/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..9bf632c6caba1b3e36e5ead8816cb3b25bd600ab --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + void yield; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..675a0f37df4705694d2c216c17995f24706605a9 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + yi\u0065ld: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier.js b/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..8a6a818ca7bd1f88252f40d0a9b7901c95d18531 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async *#gen() { + yield: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-static-yield-identifier-spread-strict.js b/test/language/statements/class/async-gen-private-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..f7bc16e8c3a5fad9c7c4b7eda898f61cddd426a1 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-identifier-strict.js b/test/language/statements/class/async-gen-private-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..b0aa9aba2f2364450659d17006af562b40275c6b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-identifier-strict.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-class-decl-static-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. (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-catch.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..e8a364cbd10b8883400facb685ff2420ab01186b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-catch.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..8bc57c6e15a40ca221bb071542f250c9e22c3edc --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..ad11204f654af4843d39f7d5d770b72f561ac14e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..c23a7b7f0cc345188c9b657207cc89382e13986b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield * readFile(); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..712569e48c5a14c65b8a8984f20c52647c48ecba --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield * iterable; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next.js b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next.js new file mode 100644 index 0000000000000000000000000000000000000000..82e7173c804195c0fc05f2e4048f74b59d7764ff --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-promise-reject-next.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-multiple.js b/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..9afb0c202cbc01f96e547926a7f13226e1f19e37 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-single.js b/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..65b38368fcb5355b06523b8738274f955ed87e2e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-spread-arr-single.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, 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(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-spread-obj.js b/test/language/statements/class/async-gen-private-method-static-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..d1b3e0cde0a572ad552e66966394a21481c70204 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-spread-obj.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-static-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-async-next.js b/test/language/statements/class/async-gen-private-method-static-yield-star-async-next.js new file mode 100644 index 0000000000000000000000000000000000000000..4bbfbf19cb37151b0880f49d21ebdae04bc58636 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-async-next.js @@ -0,0 +1,234 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-async-return.js b/test/language/statements/class/async-gen-private-method-static-yield-star-async-return.js new file mode 100644 index 0000000000000000000000000000000000000000..40a6dbd162ba90ae4396eac178dbb2e13bd685d9 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-async-return.js @@ -0,0 +1,250 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-async-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-async-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..599b769a67fae670f85d1e6a03ed4ea6d5e0a221 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-async-throw.js @@ -0,0 +1,258 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-expr-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-expr-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..010fc74aa99e27d41526caa784203e4e2a94102d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-expr-abrupt.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..814a3dbe44d1ceb36d82eb4c49c34fc7e000227b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..869f0dc7e26a453116346873a38e2bce5b1075db --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..14bcb7efd878726903c201d8b161a77c5a844ac2 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3f7abcc65b45991e4682689384757a4f24e42815 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6cfb8a4df7444036a272f207432a71059ca84940 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8bb318a9302994ae0b63030f1b9459f48c975b47 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..aa3675cc6cab8b64881764a7334156d770443248 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..40d1767aa3c49462d85a5ed8281bbd084f616ec5 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b894abee47cd0a77930169d445e5e67acf781934 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e1db3157f49e58dc9e734e469c3bc8867c47a830 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..5bdbd206dbb887edd845bbfa5665176beefa9d97 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..fc5a242226fca5fd5683e1365a9fa29c0dc9d891 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..5184d164af300b811f3ffc18913b7d43c9317f3b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..cbd9051214abc031a0ed4f86d1f1178b06c26456 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..d5ae0228d6ae7036d423bf64665f3093c6ea3a10 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..4a3b6833e2a28ffeb42e1200b786dbc527c87d77 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..586f102679339bac184964afbaefc877c4314db6 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..afeb7d1bf1ab93cc4497b7905cfcd11fae30ec70 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3469bde3d1800b914930bb3e1ff1757489e93d99 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..55e93371bb9852d18782a68560d65630f3ea16a2 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7be72a8781ec08456ff8ca6c437355d990b15962 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..6cea12d4f37304d0ea080e833596e50e7b3c5ceb --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..fb0db49602907321b5f8fc849147e0ed9d422499 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..1dc68438c745b61a9b1a8e65d13d67bbc52730fc --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8f56fcc6356929dbf32115a149b76f07b1b07c21 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..50b6c634ef0e291fabad769051b6472f8ab72d89 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..bf9751618f4d474fa99a2912ca25334de11cd7f4 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..dd69e462fbfe15d8c9b54e25c05e444db9036de4 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..448b27f2830ca4102c35e288c280c686ada926eb --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting done (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..3344319b332a98d3c042881af7e2105ec09d43db --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while calling next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..23a841463b03804374b85d86ba6f912b1d5858e8 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting value (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..adfa30012d2528ad005cadc92e23f861b62530de --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-get-abrupt.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Abrupt completion while getting next (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..b7fbed1b811e9c82a7aaabb60ecd9b594d5718ff --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0cc0d61c69e5482a379b1fc0308286e5e7dd9548 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..bcd563916fbf7e57063956a0cb0e7a5bc236a1aa --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8bd63d143463fc319ec689e273feea463f553627 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b9914dde4a3d97ad4538a923b89f92a02340dd8f --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..d4ebf97b048f78ea5fb8f26f7ce12446d497f21e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4056be6d84ab9e3d90f7756dcaffd7393414a949 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..34491a0131299f46caf9ef99c4fa8f2d6d9cc90e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..f400b14753528449094ec4a02cae44d2c908eb1d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-get-abrupt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Return abrupt after getting next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fa7ff154c41f70ab4eda9c6c87cf1018fabf6be0 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..209664ebd3f0230d6978b9e45c35e7c28abc0c1d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..d19224cfb557866d2b5f738168f51e178eed07f8 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..e954d41755c2f335dba05dff30041ac74f8c4964 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..93397d93267e709566c9b5b863c306e37e919970 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..4bbf2789a4e7d9a9cfdc5ac006108a8afedcd2ff --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..d277cf12b94a220900beb2dcd0b47dc11cbc6ba7 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..1a4fbb2685ebc52d13296947affb10050a9fd892 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: Return abrupt after calling next().then (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-sync-next.js b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-next.js new file mode 100644 index 0000000000000000000000000000000000000000..db0fc1dd8663090f11db715c1537e88dd50fe08f --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-next.js @@ -0,0 +1,237 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-sync-return.js b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-return.js new file mode 100644 index 0000000000000000000000000000000000000000..9ce50f885175e953074137ce464298a95e71c2f5 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-return.js @@ -0,0 +1,212 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-static-yield-star-sync-throw.js b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..71d0c8bec3dc1d04ac0b37daafa4925f85eae99d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-static-yield-star-sync-throw.js @@ -0,0 +1,218 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-static-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Static async generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-static-methods-private] +flags: [generated, async] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..0ab8b943db7500c574994ba6c12280e1588c4793 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + var yi\u0065ld; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier.js b/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..dd54f5cbc6cd2a3393beb86bd2731fa7a13cc751 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-binding-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + var yield; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference-escaped.js b/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..734eaee5194d0dc9425605694bc6d206b62faf47 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + void yi\u0065ld; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference.js b/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..5d5862028562e16e6c672e2d356b7a93f6e31b32 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-identifier-reference.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + void yield; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-as-label-identifier-escaped.js b/test/language/statements/class/async-gen-private-method-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..4118dd4ee8696e66bdaa63a4d85d96552c409861 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier-escaped.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + yi\u0065ld: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-as-label-identifier.js b/test/language/statements/class/async-gen-private-method-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..1df5909bd0e1c6b805ae7505c47aa1da07c3e0c9 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-as-label-identifier.case +// - src/async-generators/syntax/async-class-decl-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async Generator private method as a ClassDeclaration element) +esid: prod-AsyncGeneratorMethod +features: [async-iteration, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Yield] parameter and + StringValue of Identifier is "yield". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async *#gen() { + yield: ; +}} diff --git a/test/language/statements/class/async-gen-private-method-yield-identifier-spread-strict.js b/test/language/statements/class/async-gen-private-method-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..756d8f60eb533a901e4e3ff4547a7044db3f124e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-identifier-spread-strict.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-spread-strict.case +// - src/async-generators/default/async-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. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +class C { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-identifier-strict.js b/test/language/statements/class/async-gen-private-method-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..7a355b0acd5d9246b411917f86bec37388b64a9a --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-identifier-strict.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-identifier-strict.case +// - src/async-generators/default/async-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. (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + + +var callCount = 0; + +class C { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-catch.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..0645b12531532fa169323acc2d5e2b8f5e23c88e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-catch.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-catch.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}).catch(rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..a54e16178fb4afcde1452a998cac74cde649cc8e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-async-iterator.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * [Promise.reject(value)] is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + for await (let line of readFile()) { + yield line; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..330f52b535e8a9b94ee70a4af559998f5d480922 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-for-await-of-sync-iterator.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-for-await-of-sync-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) in for-await-of is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + for await (let value of iterable) { + yield value; + } + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..f084b8cc966a13f203509e751b6232604abd096a --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-async-iterator.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +async function * readFile() { + yield Promise.reject(error); + yield "unreachable"; +} + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield * readFile(); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}, $DONE).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js new file mode 100644 index 0000000000000000000000000000000000000000..4dad592f1a78bb19cceb62e77c7e90805062ac63 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next-yield-star-sync-iterator.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield * (async iterator) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); +let iterable = [ + Promise.reject(error), + "unreachable" +]; + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield * iterable; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-promise-reject-next.js b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next.js new file mode 100644 index 0000000000000000000000000000000000000000..935f74824b40a05693c5b5c641898adc70f3b741 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-promise-reject-next.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-promise-reject-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: yield Promise.reject(value) is treated as throw value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + +---*/ +let error = new Error(); + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield Promise.reject(error); + yield "unreachable"; + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error("Promise incorrectly resolved."); +}, rejectValue => { + // yield Promise.reject(error); + assert.sameValue(rejectValue, error); + + iter.next().then(({done, value}) => { + // iter is closed now. + assert.sameValue(done, true, "The value of IteratorResult.done is `true`"); + assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-spread-arr-multiple.js b/test/language/statements/class/async-gen-private-method-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..45644af5dae422fd20ed00f81e8fa9d69bbeaf07 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-spread-arr-multiple.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-multiple.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; +var item; + + +var callCount = 0; + +class C { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(false); +item = iter.next(['a', 'b', 'c']); + +item.then(({ done, value }) => { + item = iter.next(value); + + item.then(({ done, value }) => { + assert(compareArray(value, arr)); + assert.sameValue(done, false); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-spread-arr-single.js b/test/language/statements/class/async-gen-private-method-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..9fa18d3ab1800ec7c1f1e9869bf29677ba0b88ba --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-spread-arr-single.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-arr-single.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Array Initializer + + SpreadElement[Yield, Await]: + ...AssignmentExpression[+In, ?Yield, ?Await] + +---*/ +var arr = ['a', 'b', 'c']; + + +var callCount = 0; + +class C { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(false); +var item = iter.next(arr); + +item.then(({ done, 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(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-spread-obj.js b/test/language/statements/class/async-gen-private-method-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..124b85a011f79c5de7c2d97a1e066331e5b858b1 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-spread-obj.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-spread-obj.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Use yield value in a object spread position (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [object-spread, async-iteration, class-methods-private] +flags: [generated, async] +includes: [compareArray.js] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + + +var callCount = 0; + +class C { + async *#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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next(); +iter.next({ x: 42 }); +iter.next({ x: 'lol' }); +var item = iter.next({ y: 39 }); + +item.then(({ done, value }) => { + assert.sameValue(value.x, 42); + assert.sameValue(value.y, 39); + assert.sameValue(Object.keys(value).length, 2); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-async-next.js b/test/language/statements/class/async-gen-private-method-yield-star-async-next.js new file mode 100644 index 0000000000000000000000000000000000000000..43967f080e5cc789deaa61fc8f770dfd9eb79d8c --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-async-next.js @@ -0,0 +1,238 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Execution order for yield* with async iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ name: "get [Symbol.iterator]" }); + }, + get [Symbol.asyncIterator]() { + log.push({ + name: "get [Symbol.asyncIterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.asyncIterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-promise-1", + get then() { + log.push({ + name: "get next then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "next-promise-2", + get then() { + log.push({ + name: "get next then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call next then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + assert.sameValue(log[1].thisValue, obj, "get [Symbol.asyncIterator] thisValue"); + + assert.sameValue(log[2].name, "call [Symbol.asyncIterator]"); + assert.sameValue(log[2].thisValue, obj, "[Symbol.asyncIterator] thisValue"); + assert.sameValue(log[2].args.length, 0, "[Symbol.asyncIterator] args.length"); + + assert.sameValue(log[3].name, "get next"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "get next thisValue"); + + assert.sameValue(log[4].name, "call next"); + assert.sameValue(log[4].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[4].args.length, 1, "next args.length"); + assert.sameValue(log[4].args[0], undefined, "next args[0]"); + + assert.sameValue(log[5].name, "get next then (1)"); + assert.sameValue(log[5].thisValue.name, "next-promise-1", "get next then thisValue"); + + assert.sameValue(log[6].name, "call next then (1)"); + assert.sameValue(log[6].thisValue.name, "next-promise-1", "next then thisValue"); + assert.sameValue(log[6].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[6].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[6].args[1], "function", "next then args[1]"); + + assert.sameValue(log[7].name, "get next done (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[8].name, "get next value (1)"); + assert.sameValue(log[8].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 9, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[9].name, "call next"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "next thisValue"); + assert.sameValue(log[9].args.length, 1, "next args.length"); + assert.sameValue(log[9].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[10].name, "get next then (2)"); + assert.sameValue(log[10].thisValue.name, "next-promise-2", "get next then thisValue"); + + assert.sameValue(log[11].name, "call next then (2)"); + assert.sameValue(log[11].thisValue.name, "next-promise-2", "next then thisValue"); + assert.sameValue(log[11].args.length, 2, "next then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "next then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "next then args[1]"); + + assert.sameValue(log[12].name, "get next done (2)"); + assert.sameValue(log[12].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[13].name, "get next value (2)"); + assert.sameValue(log[13].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-async-return.js b/test/language/statements/class/async-gen-private-method-yield-star-async-return.js new file mode 100644 index 0000000000000000000000000000000000000000..238c2c94b03ce41973bed6a6a89e4cfed3f15fc9 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-async-return.js @@ -0,0 +1,254 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-return.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with async iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. If generatorKind is async, then set value to ? Await(value). + 3. Return Completion{[[Type]]: return, [[Value]]: value, [[Target]]: empty}. + ix. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var returnCount = 0; + return { + name: 'asyncIterator', + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-promise-1", + get then() { + log.push({ + name: "get return then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "return-promise-2", + get then() { + log.push({ + name: "get return then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call return then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return then (1)"); + assert.sameValue(log[4].thisValue.name, "return-promise-1", "get return then thisValue"); + + assert.sameValue(log[5].name, "call return then (1)"); + assert.sameValue(log[5].thisValue.name, "return-promise-1", "return then thisValue"); + assert.sameValue(log[5].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "return then args[1]"); + + assert.sameValue(log[6].name, "get return done (1)"); + assert.sameValue(log[6].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[7].name, "get return value (1)"); + assert.sameValue(log[7].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[8].name, "get return"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get return thisValue"); + + assert.sameValue(log[9].name, "call return"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "return thisValue"); + assert.sameValue(log[9].args.length, 1, "return args.length"); + assert.sameValue(log[9].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[10].name, "get return then (2)"); + assert.sameValue(log[10].thisValue.name, "return-promise-2", "get return then thisValue"); + + assert.sameValue(log[11].name, "call return then (2)"); + assert.sameValue(log[11].thisValue.name, "return-promise-2", "return then thisValue"); + assert.sameValue(log[11].args.length, 2, "return then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "return then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "return then args[1]"); + + assert.sameValue(log[12].name, "get return done (2)"); + assert.sameValue(log[12].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[13].name, "get return value (2)"); + assert.sameValue(log[13].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 14, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-async-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-async-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..04b10c0efb5b8118a82d29be35d6baa1babf2099 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-async-throw.js @@ -0,0 +1,262 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-async-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with async iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Let resultValue be Return ? IteratorValue(innerResult). + b. If generatorKind is async, then set resultValue to ? Await(resultValue). + c. Return resultValue. + 7. If generatorKind is async, then let received be AsyncGeneratorYield(? IteratorValue(innerResult)). + ... + + AsyncGeneratorYield ( value ) + + ... + 8. Return ! AsyncGeneratorResolve(generator, value, false). + ... + +---*/ +var log = []; +var obj = { + [Symbol.asyncIterator]() { + var throwCount = 0; + return { + name: "asyncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-promise-1", + get then() { + log.push({ + name: "get throw then (1)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (1)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }); + }; + } + }; + } + + return { + name: "throw-promise-2", + get then() { + log.push({ + name: "get throw then (2)", + thisValue: this + }); + return function(resolve) { + log.push({ + name: "call throw then (2)", + thisValue: this, + args: [...arguments] + }); + + resolve({ + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }); + }; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw then (1)"); + assert.sameValue(log[4].thisValue.name, "throw-promise-1", "get throw thisValue"); + + assert.sameValue(log[5].name, "call throw then (1)"); + assert.sameValue(log[5].thisValue.name, "throw-promise-1", "throw thisValue"); + assert.sameValue(log[5].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[5].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[5].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[6].name, "get throw done (1)"); + assert.sameValue(log[6].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[7].name, "get throw value (1)"); + assert.sameValue(log[7].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[8].name, "get throw"); + assert.sameValue(log[8].thisValue.name, "asyncIterator", "get throw thisValue"); + + assert.sameValue(log[9].name, "call throw"); + assert.sameValue(log[9].thisValue.name, "asyncIterator", "throw thisValue"); + assert.sameValue(log[9].args.length, 1, "throw args.length"); + assert.sameValue(log[9].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[10].name, "get throw then (2)"); + assert.sameValue(log[10].thisValue.name, "throw-promise-2", "get throw thisValue"); + + assert.sameValue(log[11].name, "call throw then (2)"); + assert.sameValue(log[11].thisValue.name, "throw-promise-2", "throw thisValue"); + assert.sameValue(log[11].args.length, 2, "throw then args.length"); + assert.sameValue(typeof log[11].args[0], "function", "throw then args[0]"); + assert.sameValue(typeof log[11].args[1], "function", "throw then args[1]"); + + assert.sameValue(log[12].name, "get throw done (2)"); + assert.sameValue(log[12].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[13].name, "get throw value (2)"); + assert.sameValue(log[13].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[14].name, "after yield*"); + assert.sameValue(log[14].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 15, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-expr-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-expr-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..c127cd49bee7a2a954ee178fab00082127bc068e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-expr-abrupt.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-expr-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting yield* operand (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + ... + +---*/ +var obj = {}; +var abrupt = function() { + throw obj; +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* abrupt(); + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, obj, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..30377f190475d91ce82c6e951bf824bcb9078015 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-get-abrupt.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + get [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c97e0a7c6a0a7a5b1a9f13dd40637d39beff6d18 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-boolean-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: false +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..b20a4ec8074ee5df6d80e5b6f6a21089f78dc490 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-number-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: 0 +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..ec534bfa255f5057e8d33c3cf26c9e4b1727c5c6 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-object-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: {} +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..db0de0d8d8d203539f0810e20c1dc0da08a5dcaf --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-string-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: '' +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..62a4e8a25a46ec47ee86c84e8c5195b4baae037e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-not-callable-symbol-throw.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.asyncIterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]: Symbol.asyncIterator +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..11eaa74d754b6b911bffbb60077158014c83bc48 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-null-sync-get-abrupt.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-null-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after null @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..1601390cfb63e71a683e6cb60b337f9024d3b7c7 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-abrupt.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.asyncIterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6dd829922e5c5a20f24203363b2a4a560dd167ab --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-boolean-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..949be2e3edf07283b379f19a95dfff595eba6461 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-null-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..088ba42b003f4681c1ca6ef93a1f665b6b6be5d7 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-number-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return 42; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..c28b7879e9e0c46e56bf54e375f2ac6972ab8213 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-string-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return '42'; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8e3b8ecdb4ef759a8043230a15aeb3fc4fbdae83 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-symbol-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return Symbol.asyncIterator; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..d8dbe61b856ec0fb96e91a4443e339cc12671284 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-returns-undefined-throw.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.asyncIterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + ... + 6. Let iterator be ? Call(method, obj). + 7. If Type(iterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..6024371e554d400fc4a5b897e5821683462d194a --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-async-undefined-sync-get-abrupt.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-async-undefined-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting @@iterator after undefined @@asyncIterator (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var calls = 0; +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + }, + get [Symbol.asyncIterator]() { + calls += 1; + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + assert.sameValue(calls, 1); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..3d9f03d6f69e5828d6ee2eab84df2c2ef4c31251 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-get-abrupt.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..529b311723fabb24b58a159fab02478aa199c7b5 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-boolean-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: false +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6223dac04a3f713f0669e44e0ee471bb2911169e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-number-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: 0 +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..648a198d40f73e999e5ee91fc0d8250c5811808b --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-object-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: {} +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..3c0259c76e30d9da0e2410323c944c68c37349ac --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-string-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: '' +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..f13a60e1eee306aee25c80c5632650fb70be967c --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-not-callable-symbol-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Throws a TypeError on a non-callable [Symbol.iterator] (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + ... + 4. If IsCallable(func) is false, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]: Symbol.iterator +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..02dcbbffcb39237f28ef30366e8b32b9f464e77e --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-abrupt.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling [Symbol.iterator] (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + ... + +---*/ +var reason = {}; +var obj = { + [Symbol.iterator]() { + throw reason; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..310d51984c401a9ab5d02199a63d41bdbfd876e6 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-boolean-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return true; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..991fea247b8ae27833dfc5c0a70a3cf1db60210f --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-null-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..8b2fec004ec2e8fc7b309afb47ec2116826d80e8 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-number-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return 0; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..4c3dc320d4c27d588e2675037eebd4bc6cef97c8 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-string-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return ''; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e6b1f6823c4605a44a1b78e1b59df3a6206ce1e3 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-symbol-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return Symbol.iterator; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..580d1a2f653ba79b769b24a85825642940f8a65a --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-getiter-sync-returns-undefined-throw.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-getiter-sync-returns-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Non object returned by [Symbol.iterator]() - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + 1. Let exprRef be the result of evaluating AssignmentExpression. + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + CreateAsyncFromSyncIterator(syncIterator) + + 1. If Type(syncIterator) is not Object, throw a TypeError exception. + ... + +---*/ +var obj = { + [Symbol.iterator]() { + return undefined; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..82addf0c25446a2a9c380de82b985ebf6f18e25f --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-call-done-get-abrupt.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-done-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting done (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get done() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..06bac4e1dd034559d14f6a78cf8e07d9361b6a13 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-call-returns-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while calling next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] ÂÂ»). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..e37ab085d30ff49d68427b1512c6c3bb5191a9f8 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-call-value-get-abrupt.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-call-value-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting value (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + done: true, + get value() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..16009cdf23b2d08a4b36b0b062f934cdd7895fb3 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-get-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Abrupt completion while getting next (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + get next() { + throw reason; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, "reject reason"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js b/test/language/statements/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js new file mode 100644 index 0000000000000000000000000000000000000000..495150b0f346c72069cefcb7e91f73e5f155d240 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-non-object-ignores-then.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-non-object-ignores-then.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: If next() value is not-object, do not access respective then property (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + +---*/ +Number.prototype.then = function() { + throw new Test262Error('Number#then should not be used'); +}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return 42; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, 'TypeError'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..0fd699817c70727c4c8ac069a5c8ed2820bba7c5 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-boolean-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-boolean-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - boolean (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: true + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..6c02881f707d505a4500ed81f02db099ec294cc4 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-null-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-null-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - null (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: null + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..d4365fbc0abe05bb4c418f3e7d52e1046d5e6dd2 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-number-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-number-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - number (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: 42 + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..7f10b18a14576a9cdde32ca48ab381824fcda721 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-object-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-object-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - object (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: {} + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..a5c9a87aa468f81ed939406828bbf79742c52af1 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-string-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-string-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - string (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: '' + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..9cb1506bade66dede750fca0fcff8ad287ae7f3d --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-symbol-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-symbol-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: Symbol('oi') + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..e942797ef5d8590a756e8c0699a2e29d4f033714 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-not-callable-undefined-throw.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-not-callable-undefined-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Not-callable next value in a yield star position - undefined (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next: undefined + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v.constructor, TypeError, "TypeError"); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-get-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-get-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..8fe629fe3becd6c654c56876b90f330c10aa2398 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-get-abrupt.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-get-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Return abrupt after getting next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + get then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..7a9ebad34bb6b2dfbe38484e07873e81392b0624 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-boolean-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-boolean-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (boolean) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: true, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..3e7d5b6f830fa0a0186768dbf3bc749a5642930c --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-null-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-null-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (null) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: null, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fda8feef3926d1d6eea201095f97ccce4e1c46e5 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-number-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-number-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (number) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: 39, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..2048f1f95f650bea030adc2220f1cea95b1dd2b0 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-object-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-object-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (object) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: {}, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..6a06b3bc7d07eb2197f96f354f47c0a44cd36d17 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-string-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-string-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (string) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: '', + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..17b7a22dcf2527c75a6507cd712a91936bca3011 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-symbol-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-symbol-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (symbol) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: Symbol('oi'), + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js new file mode 100644 index 0000000000000000000000000000000000000000..fc7f9ca147af5e565e7b92ee70b675b013397706 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-non-callable-undefined-fulfillpromise.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-non-callable-undefined-fulfillpromise.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: FulfillPromise if next().then is not-callable (undefined) (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + iv. If Type(innerResult) is not Object, throw a TypeError exception. + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 7. If Type(resolution) is not Object, then + a. Return FulfillPromise(promise, resolution). + 8. Let then be Get(resolution, "then"). + ... + 11. If IsCallable(thenAction) is false, then + a. Return FulfillPromise(promise, resolution). + ... + +---*/ +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then: undefined, + value: 42, + done: false + } + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(({ value, done }) => { + assert.sameValue(value, 42); + assert.sameValue(done, false); +}).then($DONE, $DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js b/test/language/statements/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js new file mode 100644 index 0000000000000000000000000000000000000000..9844b94a2d990f25c86c4b9062325e764364b4c6 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-next-then-returns-abrupt.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-next-then-returns-abrupt.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: Return abrupt after calling next().then (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + ... + 6. Repeat + a. If received.[[Type]] is normal, then + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + + Await + + ... + 2. Let promiseCapability be ! NewPromiseCapability(%Promise%). + 3. Perform ! Call(promiseCapability.[[Resolve]], undefined, « promise »). + ... + + Promise Resolve Functions + + ... + 8. Let then be Get(resolution, "then"). + ... + 10. Get thenAction be then.[[Value]]. + ... + 12. Perform EnqueueJob("PromiseJobs", PromiseResolveThenableJob, « promise, + resolution, thenAction »). + ... + +---*/ +var reason = {}; +var obj = { + get [Symbol.iterator]() { + throw new Test262Error('it should not get Symbol.iterator'); + }, + [Symbol.asyncIterator]() { + return { + next() { + return { + then() { + throw reason; + } + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + yield* obj; + throw new Test262Error('abrupt completion closes iter'); + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +iter.next().then(() => { + throw new Test262Error('Promise incorrectly fulfilled.'); +}, v => { + assert.sameValue(v, reason, 'reject reason'); + + iter.next().then(({ done, value }) => { + assert.sameValue(done, true, 'the iterator is completed'); + assert.sameValue(value, undefined, 'value is undefined'); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-sync-next.js b/test/language/statements/class/async-gen-private-method-yield-star-sync-next.js new file mode 100644 index 0000000000000000000000000000000000000000..3b4d9817cebb9ea84345fe762c24766186934bab --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-sync-next.js @@ -0,0 +1,241 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-next.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and next() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 2. Let value be ? GetValue(exprRef). + 3. Let generatorKind be ! GetGeneratorKind(). + 4. Let iterator be ? GetIterator(value, generatorKind). + 5. Let received be NormalCompletion(undefined). + 6. Repeat + a. If received.[[Type]] is normal, then + i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). + ii. Let innerResult be ? Invoke(iterator, "next", + « received.[[Value]] »). + iii. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + v. Let done be ? IteratorComplete(innerResult). + vi. If done is true, then + 1. Return ? IteratorValue(innerResult). + vii. Let received be GeneratorYield(innerResult). + ... + + GetIterator ( obj [ , hint ] ) + + ... + 3. If hint is async, + a. Set method to ? GetMethod(obj, @@asyncIterator). + b. If method is undefined, + i. Let syncMethod be ? GetMethod(obj, @@iterator). + ii. Let syncIterator be ? Call(syncMethod, obj). + iii. Return ? CreateAsyncFromSyncIterator(syncIterator). + ... + + %AsyncFromSyncIteratorPrototype%.next ( value ) + + ... + 5. Let nextResult be IteratorNext(syncIterator, value). + ... + 7. Let nextValue be IteratorValue(nextResult). + ... + 9. Let nextDone be IteratorComplete(nextResult). + ... + 12. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « nextValue »). + ... + 14. Set onFulfilled.[[Done]] to nextDone. + 15. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + + Async Iterator Value Unwrap Functions + + 1. Return ! CreateIterResultObject(value, F.[[Done]]). + +---*/ +var log = []; +var obj = { + get [Symbol.iterator]() { + log.push({ + name: "get [Symbol.iterator]", + thisValue: this + }); + return function() { + log.push({ + name: "call [Symbol.iterator]", + thisValue: this, + args: [...arguments] + }); + var nextCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ + name: "get next", + thisValue: this + }); + return function() { + log.push({ + name: "call next", + thisValue: this, + args: [...arguments] + }); + + nextCount++; + if (nextCount == 1) { + return { + name: "next-result-1", + get value() { + log.push({ + name: "get next value (1)", + thisValue: this + }); + return "next-value-1"; + }, + get done() { + log.push({ + name: "get next done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "next-result-2", + get value() { + log.push({ + name: "get next value (2)", + thisValue: this + }); + return "next-value-2"; + }, + get done() { + log.push({ + name: "get next done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + }; + }, + get [Symbol.asyncIterator]() { + log.push({ name: "get [Symbol.asyncIterator]" }); + return null; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next("next-arg-1").then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get [Symbol.asyncIterator]"); + + assert.sameValue(log[2].name, "get [Symbol.iterator]"); + assert.sameValue(log[2].thisValue, obj, "get [Symbol.iterator] thisValue"); + + assert.sameValue(log[3].name, "call [Symbol.iterator]"); + assert.sameValue(log[3].thisValue, obj, "[Symbol.iterator] thisValue"); + assert.sameValue(log[3].args.length, 0, "[Symbol.iterator] args.length"); + + assert.sameValue(log[4].name, "get next"); + assert.sameValue(log[4].thisValue.name, "syncIterator", "get next thisValue"); + + assert.sameValue(log[5].name, "call next"); + assert.sameValue(log[5].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[5].args.length, 1, "next args.length"); + assert.sameValue(log[5].args[0], undefined, "next args[0]"); + + assert.sameValue(log[6].name, "get next done (1)"); + assert.sameValue(log[6].thisValue.name, "next-result-1", "get next done thisValue"); + + assert.sameValue(log[7].name, "get next value (1)"); + assert.sameValue(log[7].thisValue.name, "next-result-1", "get next value thisValue"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 8, "log.length"); + + iter.next("next-arg-2").then(v => { + assert.sameValue(log[8].name, "call next"); + assert.sameValue(log[8].thisValue.name, "syncIterator", "next thisValue"); + assert.sameValue(log[8].args.length, 1, "next args.length"); + assert.sameValue(log[8].args[0], "next-arg-2", "next args[0]"); + + assert.sameValue(log[9].name, "get next done (2)"); + assert.sameValue(log[9].thisValue.name, "next-result-2", "get next done thisValue"); + + assert.sameValue(log[10].name, "get next value (2)"); + assert.sameValue(log[10].thisValue.name, "next-result-2", "get next value thisValue"); + + assert.sameValue(log[11].name, "after yield*"); + assert.sameValue(log[11].value, "next-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 12, "log.length"); + }).then($DONE, $DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-sync-return.js b/test/language/statements/class/async-gen-private-method-yield-star-sync-return.js new file mode 100644 index 0000000000000000000000000000000000000000..c2f7f41ab382878420dfa107d28649ed213e5cc7 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-sync-return.js @@ -0,0 +1,216 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-return.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and return() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, Symbol.asyncIterator, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + c. Else, + i. Assert: received.[[Type]] is return. + ii. Let return be ? GetMethod(iterator, "return"). + iii. If return is undefined, return Completion(received). + iv. Let innerReturnResult be ? Call(return, iterator, + « received.[[Value]] »). + v. If generatorKind is async, then set innerReturnResult to + ? Await(innerReturnResult). + ... + vii. Let done be ? IteratorComplete(innerReturnResult). + viii. If done is true, then + 1. Let value be ? IteratorValue(innerReturnResult). + 2. Return Completion{[[Type]]: return, [[Value]]: value, + [[Target]]: empty}. + ix. Let received be GeneratorYield(innerResult). + + %AsyncFromSyncIteratorPrototype%.return ( value ) + + 5. Let return be GetMethod(syncIterator, "return"). + ... + ... + 8. Let returnResult be Call(return, syncIterator, « value »). + ... + 11. Let returnValue be IteratorValue(returnResult). + .. + 13. Let returnDone be IteratorComplete(returnResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « returnValue »). + ... + 18. Set onFulfilled.[[Done]] to returnDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var returnCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get return() { + log.push({ + name: "get return", + thisValue: this + }); + return function() { + log.push({ + name: "call return", + thisValue: this, + args: [...arguments] + }); + + returnCount++; + if (returnCount == 1) { + return { + name: "return-result-1", + get value() { + log.push({ + name: "get return value (1)", + thisValue: this + }); + return "return-value-1"; + }, + get done() { + log.push({ + name: "get return done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "return-result-2", + get value() { + log.push({ + name: "get return value (2)", + thisValue: this + }); + return "return-value-2"; + }, + get done() { + log.push({ + name: "get return done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + yield* obj; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.return("return-arg-1").then(v => { + assert.sameValue(log[2].name, "get return"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[3].name, "call return"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "return thisValue"); + assert.sameValue(log[3].args.length, 1, "return args.length"); + assert.sameValue(log[3].args[0], "return-arg-1", "return args[0]"); + + assert.sameValue(log[4].name, "get return done (1)"); + assert.sameValue(log[4].thisValue.name, "return-result-1", "get return done thisValue"); + + assert.sameValue(log[5].name, "get return value (1)"); + assert.sameValue(log[5].thisValue.name, "return-result-1", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.return("return-arg-2").then(v => { + assert.sameValue(log[6].name, "get return"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get return thisValue"); + + assert.sameValue(log[7].name, "call return"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "get return thisValue"); + assert.sameValue(log[7].args.length, 1, "return args.length"); + assert.sameValue(log[7].args[0], "return-arg-2", "return args[0]"); + + assert.sameValue(log[8].name, "get return done (2)"); + assert.sameValue(log[8].thisValue.name, "return-result-2", "get return done thisValue"); + + assert.sameValue(log[9].name, "get return value (2)"); + assert.sameValue(log[9].thisValue.name, "return-result-2", "get return value thisValue"); + + assert.sameValue(v.value, "return-value-2"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 10, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-gen-private-method-yield-star-sync-throw.js b/test/language/statements/class/async-gen-private-method-yield-star-sync-throw.js new file mode 100644 index 0000000000000000000000000000000000000000..28722834f8ca54b57160cc9ded43b7de7f53fbc3 --- /dev/null +++ b/test/language/statements/class/async-gen-private-method-yield-star-sync-throw.js @@ -0,0 +1,222 @@ +// This file was procedurally generated from the following sources: +// - src/async-generators/yield-star-sync-throw.case +// - src/async-generators/default/async-class-decl-private-method.template +/*--- +description: execution order for yield* with sync iterator and throw() (Async Generator method as a ClassDeclaration element) +esid: prod-AsyncGeneratorPrivateMethod +features: [Symbol.iterator, async-iteration, class-methods-private] +flags: [generated, async] +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } + + + YieldExpression: yield * AssignmentExpression + + ... + 6. Repeat + ... + b. Else if received.[[Type]] is throw, then + i. Let throw be ? GetMethod(iterator, "throw"). + ii. If throw is not undefined, then + 1. Let innerResult be ? Call(throw, iterator, « received.[[Value]] »). + 2. If generatorKind is async, then set innerResult to + ? Await(innerResult). + ... + 5. Let done be ? IteratorComplete(innerResult). + 6. If done is true, then + a. Return ? IteratorValue(innerResult). + 7. Let received be GeneratorYield(innerResult). + ... + + %AsyncFromSyncIteratorPrototype%.throw ( value ) + + ... + 5. Let throw be GetMethod(syncIterator, "throw"). + ... + 8. Let throwResult be Call(throw, syncIterator, « value »). + ... + 11. Let throwValue be IteratorValue(throwResult). + ... + 13. Let throwDone be IteratorComplete(throwResult). + ... + 16. Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, + « throwValue »). + ... + 18. Set onFulfilled.[[Done]] to throwDone. + 19. Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], + onFulfilled, undefined, promiseCapability). + ... + +---*/ +var log = []; +var obj = { + [Symbol.iterator]() { + var throwCount = 0; + return { + name: "syncIterator", + get next() { + log.push({ name: "get next" }); + return function() { + return { + value: "next-value-1", + done: false + }; + }; + }, + get throw() { + log.push({ + name: "get throw", + thisValue: this + }); + return function() { + log.push({ + name: "call throw", + thisValue: this, + args: [...arguments] + }); + + throwCount++; + if (throwCount == 1) { + return { + name: "throw-result-1", + get value() { + log.push({ + name: "get throw value (1)", + thisValue: this + }); + return "throw-value-1"; + }, + get done() { + log.push({ + name: "get throw done (1)", + thisValue: this + }); + return false; + } + }; + } + + return { + name: "throw-result-2", + get value() { + log.push({ + name: "get throw value (2)", + thisValue: this + }); + return "throw-value-2"; + }, + get done() { + log.push({ + name: "get throw done (2)", + thisValue: this + }); + return true; + } + }; + }; + } + }; + } +}; + + + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + log.push({ name: "before yield*" }); + var v = yield* obj; + log.push({ + name: "after yield*", + value: v + }); + return "return-value"; + + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +assert.sameValue(log.length, 0, "log.length"); + +iter.next().then(v => { + assert.sameValue(log[0].name, "before yield*"); + + assert.sameValue(log[1].name, "get next"); + + assert.sameValue(v.value, "next-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 2, "log.length"); + + iter.throw("throw-arg-1").then(v => { + assert.sameValue(log[2].name, "get throw"); + assert.sameValue(log[2].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[3].name, "call throw"); + assert.sameValue(log[3].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[3].args.length, 1, "throw args.length"); + assert.sameValue(log[3].args[0], "throw-arg-1", "throw args[0]"); + + assert.sameValue(log[4].name, "get throw done (1)"); + assert.sameValue(log[4].thisValue.name, "throw-result-1", "get throw done thisValue"); + + assert.sameValue(log[5].name, "get throw value (1)"); + assert.sameValue(log[5].thisValue.name, "throw-result-1", "get throw value thisValue"); + + assert.sameValue(v.value, "throw-value-1"); + assert.sameValue(v.done, false); + + assert.sameValue(log.length, 6, "log.length"); + + iter.throw("throw-arg-2").then(v => { + assert.sameValue(log[6].name, "get throw"); + assert.sameValue(log[6].thisValue.name, "syncIterator", "get throw thisValue"); + + assert.sameValue(log[7].name, "call throw"); + assert.sameValue(log[7].thisValue.name, "syncIterator", "throw thisValue"); + assert.sameValue(log[7].args.length, 1, "throw args.length"); + assert.sameValue(log[7].args[0], "throw-arg-2", "throw args[0]"); + + assert.sameValue(log[8].name, "get throw done (2)"); + assert.sameValue(log[8].thisValue.name, "throw-result-2", "get throw done thisValue"); + + assert.sameValue(log[9].name, "get throw value (2)"); + assert.sameValue(log[9].thisValue.name, "throw-result-2", "get throw value thisValue"); + + assert.sameValue(log[10].name, "after yield*"); + assert.sameValue(log[10].value, "throw-value-2"); + + assert.sameValue(v.value, "return-value"); + assert.sameValue(v.done, true); + + assert.sameValue(log.length, 11, "log.length"); + }).then($DONE, $DONE); + }).catch($DONE); +}).catch($DONE); + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/async-private-method-await-as-binding-identifier-escaped.js b/test/language/statements/class/async-private-method-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..07e0d484d540f60a700bff3453d70193bd8eb6a0 --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + var \u0061wait; +}} diff --git a/test/language/statements/class/async-private-method-await-as-binding-identifier.js b/test/language/statements/class/async-private-method-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..00964e33d7501b08c6db97190cb84dae5dba5579 --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + var await; +}} diff --git a/test/language/statements/class/async-private-method-await-as-identifier-reference-escaped.js b/test/language/statements/class/async-private-method-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..0770c691d4e3cefddf8c5e0db6a94b2a6228fba2 --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + void \u0061wait; +}} diff --git a/test/language/statements/class/async-private-method-await-as-identifier-reference.js b/test/language/statements/class/async-private-method-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..61a5506e1550bfd256cc89e1743aa58c4922ef6a --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + void await; +}} diff --git a/test/language/statements/class/async-private-method-await-as-label-identifier-escaped.js b/test/language/statements/class/async-private-method-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..d685ae6b2212d6391d5a01f2541acc4c6f3e748e --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + \u0061wait: ; +}} diff --git a/test/language/statements/class/async-private-method-await-as-label-identifier.js b/test/language/statements/class/async-private-method-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..0dd120090038bea0656a24bef71a5921b518709e --- /dev/null +++ b/test/language/statements/class/async-private-method-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { async #method() { + await: ; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-binding-identifier-escaped.js b/test/language/statements/class/async-private-method-static-await-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..baa630e65f6682c5ea7cfef831f96e64f20546e9 --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-binding-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + var \u0061wait; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-binding-identifier.js b/test/language/statements/class/async-private-method-static-await-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..cff0e244021fbee828c127377560c34589ebb32b --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-binding-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-binding-identifier.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + BindingIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + var await; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-identifier-reference-escaped.js b/test/language/statements/class/async-private-method-static-await-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e8ff8d02c8abeccc1146230f828767ba81e2a642 --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-identifier-reference-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + void \u0061wait; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-identifier-reference.js b/test/language/statements/class/async-private-method-static-await-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..6de3d749134307bdefda107c07ffc5462a40cb0e --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-identifier-reference.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-identifier-reference.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + IdentifierReference : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + void await; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-label-identifier-escaped.js b/test/language/statements/class/async-private-method-static-await-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..2eae7d949d2c1566cdb652aae0f3911e59b87489 --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-label-identifier-escaped.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier-escaped.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + \u0061wait: ; +}} diff --git a/test/language/statements/class/async-private-method-static-await-as-label-identifier.js b/test/language/statements/class/async-private-method-static-await-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..c90b33963a4fe63cae245005c4eb228a1db40fb6 --- /dev/null +++ b/test/language/statements/class/async-private-method-static-await-as-label-identifier.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/async-functions/await-as-label-identifier.case +// - src/async-functions/syntax/async-class-decl-static-private-method.template +/*--- +description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static async private method as a ClassDeclaration element) +esid: prod-AsyncMethod +features: [async-functions, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + + LabelIdentifier : Identifier + + It is a Syntax Error if this production has a [Await] parameter and + StringValue of Identifier is "await". + +---*/ +throw "Test262: This statement should not be evaluated."; + + +class C { static async #method() { + await: ; +}} diff --git a/test/language/statements/class/gen-method-yield-identifier-spread-strict.js b/test/language/statements/class/gen-method-yield-identifier-spread-strict.js index 007629c9b2f5df88e6a23556f8e70ea268ae891b..594be88f44aff7364155d57d66bb61d81557b286 100644 --- a/test/language/statements/class/gen-method-yield-identifier-spread-strict.js +++ b/test/language/statements/class/gen-method-yield-identifier-spread-strict.js @@ -1,17 +1,17 @@ // This file was procedurally generated from the following sources: // - src/generators/yield-identifier-spread-strict.case -// - src/generators/default/class-decl-method.template +// - 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. (Geenerator method as a ClassDeclaration element) -esid: prod-GeneratorMethod -features: [object-spread, generators] +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 : - MethodDefinition + PrivateMethodDefinition MethodDefinition : GeneratorMethod @@ -33,20 +33,33 @@ throw "Test262: This statement should not be evaluated."; var callCount = 0; -class C { *gen() { - callCount += 1; - return { - ...(function() { - var yield; - throw new Test262Error(); - }()), - } -}} +class C { + *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + get gen() { return this.#gen; } +} -var gen = C.prototype.gen; +const c = new C(); -var iter = gen(); +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/gen-method-yield-identifier-strict.js b/test/language/statements/class/gen-method-yield-identifier-strict.js index 411de49e3b72bbdd72da5941423c2a5b72af1296..95ab5b41491713b006454291e1358f2afdc507b0 100644 --- a/test/language/statements/class/gen-method-yield-identifier-strict.js +++ b/test/language/statements/class/gen-method-yield-identifier-strict.js @@ -1,17 +1,17 @@ // This file was procedurally generated from the following sources: // - src/generators/yield-identifier-strict.case -// - src/generators/default/class-decl-method.template +// - 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. (Geenerator method as a ClassDeclaration element) -esid: prod-GeneratorMethod -features: [generators] +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 : - MethodDefinition + PrivateMethodDefinition MethodDefinition : GeneratorMethod @@ -26,18 +26,31 @@ throw "Test262: This statement should not be evaluated."; var callCount = 0; -class C { *gen() { - callCount += 1; - (function() { - var yield; - throw new Test262Error(); - }()) -}} +class C { + *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + get gen() { return this.#gen; } +} -var gen = C.prototype.gen; +const c = new C(); -var iter = gen(); +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/gen-method-yield-spread-arr-multiple.js b/test/language/statements/class/gen-method-yield-spread-arr-multiple.js index a2e10a8ce2cce36d543936fd09b3e04c01bc78b0..1725a9b35c7f4a96d714d20958a3568410737397 100644 --- a/test/language/statements/class/gen-method-yield-spread-arr-multiple.js +++ b/test/language/statements/class/gen-method-yield-spread-arr-multiple.js @@ -1,15 +1,15 @@ // This file was procedurally generated from the following sources: // - src/generators/yield-spread-arr-multiple.case -// - src/generators/default/class-decl-method.template +// - src/generators/default/class-decl-private-method.template /*--- -description: Use yield value in a array spread position (Geenerator method as a ClassDeclaration element) -esid: prod-GeneratorMethod -features: [generators] +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 : - MethodDefinition + PrivateMethodDefinition MethodDefinition : GeneratorMethod @@ -31,14 +31,22 @@ var item; var callCount = 0; -class C { *gen() { - callCount += 1; - yield [...yield yield]; -}} +class C { + *#gen() { + callCount += 1; + yield [...yield yield]; + } + get gen() { return this.#gen; } +} -var gen = C.prototype.gen; +const c = new C(); -var iter = gen(); +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); iter.next(false); item = iter.next(['a', 'b', 'c']); @@ -48,3 +56,8 @@ 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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/gen-method-yield-spread-arr-single.js b/test/language/statements/class/gen-method-yield-spread-arr-single.js index 4e94ae41a71790a560d7ea96efdef0824dc6ee58..c1801eb476f09a5d90c310f060edd3c643814cf4 100644 --- a/test/language/statements/class/gen-method-yield-spread-arr-single.js +++ b/test/language/statements/class/gen-method-yield-spread-arr-single.js @@ -1,14 +1,14 @@ // This file was procedurally generated from the following sources: // - src/generators/yield-spread-arr-single.case -// - src/generators/default/class-decl-method.template +// - src/generators/default/class-decl-private-method.template /*--- -description: Use yield value in a array spread position (Geenerator method as a ClassDeclaration element) -esid: prod-GeneratorMethod -features: [generators] +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 : - MethodDefinition + PrivateMethodDefinition MethodDefinition : GeneratorMethod @@ -28,14 +28,22 @@ var arr = ['a', 'b', 'c']; var callCount = 0; -class C { *gen() { - callCount += 1; - yield [...yield]; -}} +class C { + *#gen() { + callCount += 1; + yield [...yield]; + } + get gen() { return this.#gen; } +} -var gen = C.prototype.gen; +const c = new C(); -var iter = gen(); +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); iter.next(false); var item = iter.next(arr); @@ -50,3 +58,8 @@ 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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/gen-method-yield-spread-obj.js b/test/language/statements/class/gen-method-yield-spread-obj.js index 0636efd83d8c14926ef28c6ad7493f828173e87d..93e1824cebbcba3f723343b42f96f291cbf6554e 100644 --- a/test/language/statements/class/gen-method-yield-spread-obj.js +++ b/test/language/statements/class/gen-method-yield-spread-obj.js @@ -1,15 +1,15 @@ // This file was procedurally generated from the following sources: // - src/generators/yield-spread-obj.case -// - src/generators/default/class-decl-method.template +// - src/generators/default/class-decl-private-method.template /*--- -description: Use yield value in a object spread position (Geenerator method as a ClassDeclaration element) -esid: prod-GeneratorMethod -features: [object-spread, generators] +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] includes: [compareArray.js] info: | ClassElement : - MethodDefinition + PrivateMethodDefinition MethodDefinition : GeneratorMethod @@ -30,18 +30,26 @@ info: | var callCount = 0; -class C { *gen() { - callCount += 1; - yield { - ...yield, - y: 1, - ...yield yield, - }; -}} +class C { + *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + get gen() { return this.#gen; } +} -var gen = C.prototype.gen; +const c = new C(); -var iter = gen(); +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); iter.next(); iter.next({ x: 42 }); @@ -54,3 +62,8 @@ 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.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier-escaped.js b/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e5da74e8715cbc9526e48dd444380a122bfe7d2b --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + var yi\u0065ld; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier.js b/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..9d08e191b8cd7a0112761163e54fe8f7ffc39dde --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-binding-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-binding-identifier.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + var yield; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference-escaped.js b/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..271ca3a4f7f3bd9f28822ee8771930f7fa0f5f16 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + void yi\u0065ld; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference.js b/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..349b6bae3c680102568ca9d5d29e4ace50ad4ec3 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-identifier-reference.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-identifier-reference.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + void yield; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-as-label-identifier-escaped.js b/test/language/statements/class/gen-private-method-static-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..b7d8e31040cbbe86c6017b97c6b7b20ebe712153 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-label-identifier-escaped.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier-escaped.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + yi\u0065ld: ; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-as-label-identifier.js b/test/language/statements/class/gen-private-method-static-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..4921370252175f8a5f2e09b35dc6705ef1337e2f --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-as-label-identifier.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-as-label-identifier.case +// - src/generators/syntax/class-decl-static-private-method.template +/*--- +description: yield is a reserved keyword within generator function bodies and may not be used as a label identifier. (Static generator method as a ClassDeclaration element) +esid: prod-GeneratorMethod +features: [generators, class-static-methods-private] +flags: [generated] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C {static *#gen() { + yield: ; +}} diff --git a/test/language/statements/class/gen-private-method-static-yield-identifier-spread-strict.js b/test/language/statements/class/gen-private-method-static-yield-identifier-spread-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..a6001d19ecfe76d86a3e2405ccf967e2f8a37030 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-identifier-spread-strict.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-spread-strict.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + return { + ...(function() { + var yield; + throw new Test262Error(); + }()), + } + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-static-yield-identifier-strict.js b/test/language/statements/class/gen-private-method-static-yield-identifier-strict.js new file mode 100644 index 0000000000000000000000000000000000000000..fe63c8a453df25e54dcd3d9082e9e00f3711ca4d --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-identifier-strict.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-identifier-strict.case +// - src/generators/default/class-decl-static-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. (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated, onlyStrict] +negative: + phase: parse + type: SyntaxError +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + +---*/ +throw "Test262: This statement should not be evaluated."; + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + (function() { + var yield; + throw new Test262Error(); + }()) + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + + + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-static-yield-spread-arr-multiple.js b/test/language/statements/class/gen-private-method-static-yield-spread-arr-multiple.js new file mode 100644 index 0000000000000000000000000000000000000000..c8f989297d00098e5af7946f289af05b336c3241 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-spread-arr-multiple.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-multiple.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static 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 { + static *#gen() { + callCount += 1; + yield [...yield yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-static-yield-spread-arr-single.js b/test/language/statements/class/gen-private-method-static-yield-spread-arr-single.js new file mode 100644 index 0000000000000000000000000000000000000000..fc071f30ae8440c07130f44d724648c1981e3077 --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-spread-arr-single.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-arr-single.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a array spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [generators, class-static-methods-private] +flags: [generated] +info: | + ClassElement : + static 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 { + static *#gen() { + callCount += 1; + yield [...yield]; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-static-yield-spread-obj.js b/test/language/statements/class/gen-private-method-static-yield-spread-obj.js new file mode 100644 index 0000000000000000000000000000000000000000..7ca80d67d4a27a771ce1f2588d5d1102a5b0af2f --- /dev/null +++ b/test/language/statements/class/gen-private-method-static-yield-spread-obj.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/generators/yield-spread-obj.case +// - src/generators/default/class-decl-static-private-method.template +/*--- +description: Use yield value in a object spread position (Static generator private method as a ClassDeclaration element) +esid: prod-GeneratorPrivateMethod +features: [object-spread, generators, class-static-methods-private] +flags: [generated] +includes: [compareArray.js] +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } + + + Spread Properties + + PropertyDefinition[Yield]: + (...) + ...AssignmentExpression[In, ?Yield] + +---*/ + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + yield { + ...yield, + y: 1, + ...yield yield, + }; + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +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 before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/test/language/statements/class/gen-private-method-yield-as-binding-identifier-escaped.js b/test/language/statements/class/gen-private-method-yield-as-binding-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..cd751f623207ded0a1ba2974e6bd8e0ffec61646 --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-binding-identifier-escaped.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + var yi\u0065ld; +}} diff --git a/test/language/statements/class/gen-private-method-yield-as-binding-identifier.js b/test/language/statements/class/gen-private-method-yield-as-binding-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..00ae3247b2f7b0e5cd7bb04331ddd4bff855bada --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-binding-identifier.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + var yield; +}} diff --git a/test/language/statements/class/gen-private-method-yield-as-identifier-reference-escaped.js b/test/language/statements/class/gen-private-method-yield-as-identifier-reference-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..e6123cf404ed91448332a040dd21326f058800ac --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-identifier-reference-escaped.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + void yi\u0065ld; +}} diff --git a/test/language/statements/class/gen-private-method-yield-as-identifier-reference.js b/test/language/statements/class/gen-private-method-yield-as-identifier-reference.js new file mode 100644 index 0000000000000000000000000000000000000000..63b3d73ade49d86c9c3089bc009cd52897bb5b21 --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-identifier-reference.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + void yield; +}} diff --git a/test/language/statements/class/gen-private-method-yield-as-label-identifier-escaped.js b/test/language/statements/class/gen-private-method-yield-as-label-identifier-escaped.js new file mode 100644 index 0000000000000000000000000000000000000000..fe4fa8049f5c045a9e867522e54afe1852af1fe2 --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-label-identifier-escaped.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + yi\u0065ld: ; +}} diff --git a/test/language/statements/class/gen-private-method-yield-as-label-identifier.js b/test/language/statements/class/gen-private-method-yield-as-label-identifier.js new file mode 100644 index 0000000000000000000000000000000000000000..32321d68f12ea7648ff3bf9f69ca4c1440171bc1 --- /dev/null +++ b/test/language/statements/class/gen-private-method-yield-as-label-identifier.js @@ -0,0 +1,35 @@ +// 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". + +---*/ +throw "Test262: This statement should not be evaluated."; + +class C { *#gen() { + yield: ; +}}