summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction')
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js33
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js48
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js40
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js31
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js0
-rw-r--r--js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js40
7 files changed, 192 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/browser.js
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js
new file mode 100644
index 0000000000..f5d17fe131
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-length.js
@@ -0,0 +1,33 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 25.2.4.1
+description: >
+ Subclassed GeneratorFunction instances `length` property
+info: |
+ 25.2.4.1 length
+
+ The value of the length property is an integer that indicates the typical
+ number of arguments expected by the GeneratorFunction. However, the language
+ permits the function to be invoked with some other number of arguments. The
+ behaviour of a GeneratorFunction when invoked on a number of arguments other
+ than the number specified by its length property depends on the function.
+
+ This property has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+ [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
+
+class GFn extends GeneratorFunction {}
+
+var gfn = new GFn('a', 'b', 'return a + b');
+
+assert.sameValue(gfn.length, 2);
+
+verifyNotEnumerable(gfn, 'length');
+verifyNotWritable(gfn, 'length');
+verifyConfigurable(gfn, 'length');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js
new file mode 100644
index 0000000000..69be80c2e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-name.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 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: Subclassed GeneratorFunction instances `name` property
+info: |
+ 25.2.4.2 name
+
+ The specification for the name property of Function instances given in
+ 19.2.4.2 also applies to GeneratorFunction instances.
+
+ 19.2.4.2 name
+
+ The value of the name property is an String that is descriptive of the
+ function. The name has no semantic significance but is typically a variable or
+ property name that is used to refer to the function at its point of definition
+ in ECMAScript code. This property has the attributes { [[Writable]]: false,
+ [[Enumerable]]: false, [[Configurable]]: true }.
+
+ Anonymous functions objects that do not have a contextual name associated with
+ them by this specification do not have a name own property but inherit the
+ name property of %FunctionPrototype%.
+
+ 19.2.1.1.1 RuntimeSemantics: CreateDynamicFunction(constructor, newTarget,
+ kind, args)
+
+ ...
+ 29. Perform SetFunctionName(F, "anonymous").
+ ...
+includes: [propertyHelper.js]
+---*/
+
+var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
+
+class GFn extends GeneratorFunction {}
+
+var gfn = new GFn('a', 'b', 'return a + b');
+
+assert.sameValue(
+ gfn.name, 'anonymous',
+ 'Dynamic Functions are called anonymous'
+);
+
+verifyNotEnumerable(gfn, 'name');
+verifyNotWritable(gfn, 'name');
+verifyConfigurable(gfn, 'name');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js
new file mode 100644
index 0000000000..3b4029adcd
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/instance-prototype.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 25.2.4.3
+description: >
+ Subclassed GeneratorFunction instances `prototype` property
+info: |
+ 25.2.4.3 prototype
+
+ Whenever a GeneratorFunction instance is created another ordinary object is
+ also created and is the initial value of the generator function’s prototype
+ property. The value of the prototype property is used to initialize the
+ [[Prototype]] internal slot of a newly created Generator object when the
+ generator function object is invoked using either [[Call]] or [[Construct]].
+
+ This property has the attributes { [[Writable]]: true, [[Enumerable]]: false,
+ [[Configurable]]: false }.
+includes: [propertyHelper.js]
+---*/
+
+var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
+
+class GFn extends GeneratorFunction {}
+
+var gfn = new GFn(';');
+
+assert.sameValue(
+ Object.keys(gfn.prototype).length, 0,
+ 'prototype is a new ordinary object'
+);
+assert.sameValue(
+ gfn.prototype.hasOwnProperty('constructor'), false,
+ 'prototype has no constructor reference'
+);
+
+verifyNotEnumerable(gfn, 'prototype');
+verifyWritable(gfn, 'prototype');
+verifyNotConfigurable(gfn, 'prototype');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js
new file mode 100644
index 0000000000..55a8c2ded5
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/regular-subclassing.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 25.2.1
+description: Subclassing GeneratorFunction
+info: |
+ 25.2.1 The GeneratorFunction Constructor
+
+ ...
+
+ GeneratorFunction is designed to be subclassable. It may be used as the value
+ of an extends clause of a class definition. Subclass constructors that intend
+ to inherit the specified GeneratorFunction behaviour must include a super call
+ to the GeneratorFunction constructor to create and initialize subclass
+ instances with the internal slots necessary for built-in GeneratorFunction
+ behaviour.
+ ...
+---*/
+
+var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
+
+class Gfn extends GeneratorFunction {}
+
+var gfn = new Gfn('a', 'yield a; yield a * 2;');
+
+var iter = gfn(42);
+
+assert.sameValue(iter.next().value, 42);
+assert.sameValue(iter.next().value, 84);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/shell.js
diff --git a/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js
new file mode 100644
index 0000000000..6d3aa6004d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/class/subclass/builtin-objects/GeneratorFunction/super-must-be-called.js
@@ -0,0 +1,40 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+es6id: 25.2.1
+description: >
+ super must be called to initialize GeneratorFunction internal slots
+info: |
+ 25.2.1 The GeneratorFunction Constructor
+
+ ...
+
+ GeneratorFunction is designed to be subclassable. It may be used as the value
+ of an extends clause of a class definition. Subclass constructors that intend
+ to inherit the specified GeneratorFunction behaviour must include a super call
+ to the GeneratorFunction constructor to create and initialize subclass
+ instances with the internal slots necessary for built-in GeneratorFunction
+ behaviour.
+ ...
+---*/
+
+var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor;
+
+class GFn1 extends GeneratorFunction {
+ constructor() {}
+}
+
+assert.throws(ReferenceError, function() {
+ new GFn1();
+});
+
+class GFn2 extends GeneratorFunction {
+ constructor() {
+ super();
+ }
+}
+
+var fn = new GFn2();
+assert(fn instanceof GeneratorFunction);
+
+reportCompare(0, 0);