[class] Test that fields are initialized before calling the base constructor

Bug: v8:5367
Change-Id: If10539597c07a497d0e9c89af9529ae90f92ddf3
Reviewed-on: https://chromium-review.googlesource.com/794470
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49711}
This commit is contained in:
Sathya Gunasekaran 2017-11-28 20:52:05 +01:00 committed by Commit Bot
parent f55286c6cd
commit 278981d73b

View File

@ -649,3 +649,28 @@ x();
assertEquals(1, obj.x);
assertEquals(2, klass.x);
}
{
new class {
t = 1;
constructor(t = this.t) {
assertEquals(1, t);
}
}
new class extends class {} {
t = 1;
constructor(t = (super(), this.t)) {
assertEquals(1, t);
}
}
assertThrows(() => {
new class extends class {} {
t = 1;
constructor(t = this.t) {
super();
}
}
}, ReferenceError);
}