Justin Ridgewell 628061c501 Add new.target transform (#5906)
* Add new.target transform

* Catch new.target under only an arrow function

* More unsupported reflect.construct cases

* Fix node 4 test

* Do not transform Methods

* More tests

* Properly setup function inheritance test

* Tests tests tests

* Fix ES6 class's new.target

* Remove expected output thats supposed to throw.
2017-07-07 14:28:19 -04:00

28 lines
443 B
JavaScript

const targets = [];
class Foo {
constructor() {
targets.push(new.target);
}
}
class Bar extends Foo {
}
class Baz {
}
Reflect.construct(Foo, []);
Reflect.construct(Foo, [], Bar);
Reflect.construct(Bar, []);
Reflect.construct(Bar, [], Baz);
Reflect.construct(Foo, [], Baz);
assert.equal(targets[0], Foo);
assert.equal(targets[1], Bar);
assert.equal(targets[2], Bar);
assert.equal(targets[3], Baz);
assert.equal(targets[4], Baz);