diff --git a/test/language/expressions/generators/has-instance.js b/test/language/expressions/generators/has-instance.js new file mode 100644 index 0000000000..f4f8806eb9 --- /dev/null +++ b/test/language/expressions/generators/has-instance.js @@ -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'); diff --git a/test/language/expressions/generators/length-property-descriptor.js b/test/language/expressions/generators/length-property-descriptor.js new file mode 100644 index 0000000000..5a59808638 --- /dev/null +++ b/test/language/expressions/generators/length-property-descriptor.js @@ -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'); diff --git a/test/language/expressions/generators/name-property-descriptor.js b/test/language/expressions/generators/name-property-descriptor.js new file mode 100644 index 0000000000..02828c7b63 --- /dev/null +++ b/test/language/expressions/generators/name-property-descriptor.js @@ -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'); diff --git a/test/language/expressions/generators/prototype-property-descriptor.js b/test/language/expressions/generators/prototype-property-descriptor.js new file mode 100644 index 0000000000..9bef1294ed --- /dev/null +++ b/test/language/expressions/generators/prototype-property-descriptor.js @@ -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'); diff --git a/test/language/expressions/generators/prototype-relation-to-function.js b/test/language/expressions/generators/prototype-relation-to-function.js new file mode 100644 index 0000000000..9bb13afc00 --- /dev/null +++ b/test/language/expressions/generators/prototype-relation-to-function.js @@ -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) +); diff --git a/test/language/expressions/generators/prototype-typeof.js b/test/language/expressions/generators/prototype-typeof.js new file mode 100644 index 0000000000..737f566902 --- /dev/null +++ b/test/language/expressions/generators/prototype-typeof.js @@ -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'); diff --git a/test/language/expressions/generators/prototype-value.js b/test/language/expressions/generators/prototype-value.js new file mode 100644 index 0000000000..0d5066bca2 --- /dev/null +++ b/test/language/expressions/generators/prototype-value.js @@ -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' +); diff --git a/test/language/statements/generators/prototype-own-properties.js b/test/language/statements/generators/prototype-own-properties.js new file mode 100644 index 0000000000..736e412efd --- /dev/null +++ b/test/language/statements/generators/prototype-own-properties.js @@ -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);