Throw error for generator function class constructor (#3489)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-01-07 14:52:01 +01:00
committed by GitHub
parent 22e52e45af
commit 003694d259
4 changed files with 40 additions and 4 deletions
+22
View File
@@ -56,6 +56,7 @@ must_throw("class X {}; var o = {}; Object.defineProperty(o, 'p', { get: X, set:
must_throw("var a = new A; class A {};");
must_throw("class A { g\\u0065t e() {} }");
must_throw('class A { "static" e() {} }');
must_throw('class A { *constructor() {} }');
assert(eval("class A {}") === undefined);
assert(eval("var a = class A {}") === undefined);
@@ -64,6 +65,22 @@ assert(eval("class A { ; ; ; ;;;;;;;;;;;; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;; }") ===
assert(eval('class A {"constructor"() {} }') === undefined);
assert(isNaN (eval('switch(1) { default: (class A{} % 1) }')));
class A1 {
["constructor"]() {
return 5;
}
}
assert ((new A1).constructor() === 5);
class A2 {
*["constructor"]() {
yield 5;
}
}
assert ((new A2).constructor().next().value === 5);
class B {
}
@@ -90,6 +107,10 @@ class C {
return() {
return 43;
}
static *constructor() {
return 44;
}
}
var c = new C;
@@ -99,6 +120,7 @@ assert (c["3"]() === 3);
assert (c.super() === 42);
assert (c.return() === 43);
assert (c.constructor === C);
assert (C.constructor().next().value === 44);
class D {
constructor(d) {