diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Class/methDefnGen.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Class/methDefnGen.js')
-rw-r--r-- | js/src/tests/ecma_6/Class/methDefnGen.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Class/methDefnGen.js b/js/src/tests/ecma_6/Class/methDefnGen.js new file mode 100644 index 000000000..3165ed448 --- /dev/null +++ b/js/src/tests/ecma_6/Class/methDefnGen.js @@ -0,0 +1,83 @@ +var BUGNUMBER = 924672; +var summary = 'Method Definitions - Generators' + +print(BUGNUMBER + ": " + summary); + +// Function definitions. +function syntaxError (script) { + try { + Function(script); + } catch (e) { + if (e instanceof SyntaxError) { + return; + } + } + throw new Error('Expected syntax error: ' + script); +} + + +// Tests begin. + +syntaxError("{*a(){}}"); +syntaxError("b = {*(){}"); +syntaxError("b = {*{}"); +syntaxError("b = {*){}"); +syntaxError("b = {*({}"); +syntaxError("b = {*(){"); +syntaxError("b = {*()}"); +syntaxError("b = {*a("); +syntaxError("b = {*a)"); +syntaxError("b = {*a(}"); +syntaxError("b = {*a)}"); +syntaxError("b = {*a()"); +syntaxError("b = {*a()}"); +syntaxError("b = {*a(){}"); +syntaxError("b = {*a){}"); +syntaxError("b = {*a}}"); +syntaxError("b = {*a{}}"); +syntaxError("b = {*a({}}"); +syntaxError("b = {*a@(){}}"); +syntaxError("b = {*@(){}}"); +syntaxError("b = {*get a(){}}"); +syntaxError("b = {get *a(){}}"); +syntaxError("b = {get a*(){}}"); +syntaxError("b = {*set a(c){}}"); +syntaxError("b = {set *a(c){}}"); +syntaxError("b = {set a*(c){}}"); +syntaxError("b = {*a : 1}"); +syntaxError("b = {a* : 1}"); +syntaxError("b = {a :* 1}"); +syntaxError("b = {a*(){}}"); + +// Generator methods. +b = { * g() { + var a = { [yield 1]: 2, [yield 2]: 3}; + return a; +} } +var it = b.g(); +var next = it.next(); +assertEq(next.done, false); +assertEq(next.value, 1); +next = it.next("hello"); +assertEq(next.done, false); +assertEq(next.value, 2); +next = it.next("world"); +assertEq(next.done, true); +assertEq(next.value.hello, 2); +assertEq(next.value.world, 3); + +// prototype property +assertEq(b.g.hasOwnProperty("prototype"), true); + +// Strict mode +a = {*b(c){"use strict";yield c;}}; +assertEq(a.b(1).next().value, 1); +a = {*["b"](c){"use strict";return c;}}; +assertEq(a.b(1).next().value, 1); + +// Generators should not have [[Construct]] +a = {*g() { yield 1; }} +assertThrowsInstanceOf(() => { new a.g }, TypeError); + +if (typeof reportCompare === 'function') + reportCompare(0, 0, "ok"); |