mirror of https://github.com/tc39/test262.git
add templates for async generators
This commit is contained in:
parent
e2bf6f63dc
commit
5a6bfb0e93
|
@ -0,0 +1,50 @@
|
|||
// Copyright (C) 2018 Jaideep Bhoosreddy. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/statements/class/async-gen-private-method-
|
||||
name: Async Generator method as a ClassDeclaration element
|
||||
esid: prod-AsyncGeneratorPrivateMethod
|
||||
info: |
|
||||
ClassElement :
|
||||
PrivateMethodDefinition
|
||||
|
||||
MethodDefinition :
|
||||
AsyncGeneratorMethod
|
||||
|
||||
Async Generator Function Definitions
|
||||
|
||||
AsyncGeneratorMethod :
|
||||
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
|
||||
features: [async-iteration, class-methods-private]
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
|
||||
class C {
|
||||
async *#gen() {
|
||||
callCount += 1;
|
||||
/*{ body }*/
|
||||
}
|
||||
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, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
||||
|
||||
var iter = c.gen();
|
||||
|
||||
/*{ assertions }*/
|
||||
|
||||
assert.sameValue(callCount, 1);
|
||||
|
||||
// Test the private fields do not appear as properties after set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2018 Jaideep Bhoosreddy. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/statements/class/async-gen-private-method-static-
|
||||
name: Static async generator method as a ClassDeclaration element
|
||||
esid: prod-AsyncGeneratorPrivateMethod
|
||||
info: |
|
||||
ClassElement :
|
||||
static PrivateMethodDefinition
|
||||
|
||||
MethodDefinition :
|
||||
AsyncGeneratorMethod
|
||||
|
||||
Async Generator Function Definitions
|
||||
|
||||
AsyncGeneratorMethod :
|
||||
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
|
||||
features: [async-iteration, class-methods-private]
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
|
||||
class C {
|
||||
static async *#gen() {
|
||||
callCount += 1;
|
||||
/*{ body }*/
|
||||
}
|
||||
static gen() {
|
||||
return C.#gen();
|
||||
}
|
||||
}
|
||||
|
||||
// Test the private fields do not appear as properties before set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
||||
|
||||
var iter = C.gen();
|
||||
|
||||
/*{ assertions }*/
|
||||
|
||||
assert.sameValue(callCount, 1);
|
||||
|
||||
// Test the private fields do not appear as properties after set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (C) 2018 Jaideep Bhoosreddy. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/class/async-gen-private-method-
|
||||
name: Async generator method as a ClassExpression element
|
||||
esid: prod-AsyncGeneratorPrivateMethod
|
||||
info: |
|
||||
ClassElement :
|
||||
PrivateMethodDefinition
|
||||
|
||||
MethodDefinition :
|
||||
AsyncGeneratorMethod
|
||||
|
||||
Async Generator Function Definitions
|
||||
|
||||
AsyncGeneratorMethod :
|
||||
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
|
||||
features: [async-iteration, class-methods-private]
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
|
||||
var C = class {
|
||||
async *#gen() {
|
||||
callCount += 1;
|
||||
/*{ body }*/
|
||||
}
|
||||
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, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
||||
|
||||
var iter = c.gen();
|
||||
|
||||
/*{ assertions }*/
|
||||
|
||||
assert.sameValue(callCount, 1);
|
||||
|
||||
// Test the private fields do not appear as properties after set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright (C) 2018 Jaideep Bhoosreddy. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
path: language/expressions/class/async-gen-private-method-static-
|
||||
name: Static async generator method as a ClassExpression element
|
||||
esid: prod-AsyncGeneratorPrivateMethod
|
||||
info: |
|
||||
ClassElement :
|
||||
static PrivateMethodDefinition
|
||||
|
||||
MethodDefinition :
|
||||
AsyncGeneratorMethod
|
||||
|
||||
Async Generator Function Definitions
|
||||
|
||||
AsyncGeneratorMethod :
|
||||
async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
|
||||
features: [async-iteration, class-methods-private]
|
||||
---*/
|
||||
|
||||
var callCount = 0;
|
||||
|
||||
var C = class {
|
||||
static async *#gen() {
|
||||
callCount += 1;
|
||||
/*{ body }*/
|
||||
}
|
||||
static gen() {
|
||||
return C.#gen();
|
||||
}
|
||||
}
|
||||
|
||||
// Test the private fields do not appear as properties before set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
||||
|
||||
var iter = C.gen();
|
||||
|
||||
/*{ assertions }*/
|
||||
|
||||
assert.sameValue(callCount, 1);
|
||||
|
||||
// Test the private fields do not appear as properties after set to value
|
||||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, "test 1");
|
||||
assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, "test 2");
|
||||
assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, "test 3");
|
Loading…
Reference in New Issue