Add analogous tests

Introduce additional tests to increase parity in coverage between
generator expressions and generator statements.
This commit is contained in:
Mike Pennisi 2015-04-14 17:23:04 -04:00
parent 779a59f30c
commit 7b969ce65b
8 changed files with 123 additions and 0 deletions

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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');

View File

@ -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)
);

View File

@ -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 functions prototype
property.
---*/
assert.sameValue(typeof function*() {}.prototype, 'object');

View File

@ -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'
);

View File

@ -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);