mirror of https://github.com/tc39/test262.git
Add analogous tests
Introduce additional tests to increase parity in coverage between generator expressions and generator statements.
This commit is contained in:
parent
779a59f30c
commit
7b969ce65b
|
@ -0,0 +1,13 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
A Generator object is an instance of a generator function.
|
||||
es6id: 25.3
|
||||
---*/
|
||||
|
||||
var g = function*() {};
|
||||
|
||||
assert(g() instanceof g, 'Instance created via function invocation');
|
||||
assert(new g() instanceof g, 'Instance created via constructor invocation');
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Generator objects should define a `length` property.
|
||||
includes: [propertyHelper.js]
|
||||
es6id: 25.2.4
|
||||
---*/
|
||||
|
||||
var g = function*() {};
|
||||
|
||||
assert.sameValue(g.length, 0);
|
||||
verifyNotEnumerable(g, 'length');
|
||||
verifyNotWritable(g, 'length');
|
||||
verifyConfigurable(g, 'length');
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Generator functions should define a `name` property.
|
||||
includes: [propertyHelper.js]
|
||||
es6id: 25.2.4
|
||||
---*/
|
||||
|
||||
var g = function*() {};
|
||||
|
||||
assert.sameValue(g.name, 'g');
|
||||
verifyNotEnumerable(g, 'name');
|
||||
verifyNotWritable(g, 'name');
|
||||
verifyConfigurable(g, 'name');
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Generator objects should define a `prototype` property.
|
||||
includes: [propertyHelper.js]
|
||||
es6id: 25.2.4
|
||||
---*/
|
||||
|
||||
var g = function*() {};
|
||||
|
||||
verifyNotEnumerable(g, 'prototype');
|
||||
verifyWritable(g, 'prototype');
|
||||
verifyNotConfigurable(g, 'prototype');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
The value of the [[Prototype]] internal slot of the GeneratorFunction
|
||||
prototype object is the FunctionPrototype intrinsic object.
|
||||
es6id: 25.2.2.2
|
||||
---*/
|
||||
|
||||
function f() {}
|
||||
var g = function*() {};
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Object.getPrototypeOf(g)),
|
||||
Object.getPrototypeOf(f)
|
||||
);
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.2.4.2
|
||||
description: >
|
||||
Whenever a GeneratorFunction instance is created another ordinary object is
|
||||
also created and is the initial value of the generator function’s prototype
|
||||
property.
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof function*() {}.prototype, 'object');
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Generator instances directly inherit properties from the object that is the
|
||||
value of the prototype property of the Generator function that created the
|
||||
instance.
|
||||
es6id: 25.3
|
||||
---*/
|
||||
|
||||
var g = function*() {};
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(g()),
|
||||
g.prototype,
|
||||
'Instance created via function invocation'
|
||||
);
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(new g()),
|
||||
g.prototype,
|
||||
'Instance created via constructor invocation'
|
||||
);
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2015 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
es6id: 25.2.4.2
|
||||
description: >
|
||||
The `prototype` property of GeneratorFunction instances are created as
|
||||
plain objects with no "own" properties.
|
||||
---*/
|
||||
|
||||
function* g() {}
|
||||
var ownProperties = Object.getOwnPropertyNames(g.prototype);
|
||||
assert.sameValue(ownProperties.length, 0);
|
Loading…
Reference in New Issue