2018-11-14 13:40:46 +03:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
test!(
|
2018-11-23 13:22:07 +03:00
|
|
|
Classes::default(),
|
|
|
|
basic,
|
|
|
|
r#"class Test {
|
2018-11-14 13:40:46 +03:00
|
|
|
constructor(name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
logger () {
|
|
|
|
console.log("Hello", this.name);
|
|
|
|
}
|
|
|
|
}"#,
|
2018-11-23 13:22:07 +03:00
|
|
|
r#"var Test = function () {
|
2018-11-14 13:40:46 +03:00
|
|
|
function Test(name) {
|
|
|
|
_classCallCheck(this, Test);
|
|
|
|
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Test, [{
|
|
|
|
key: "logger",
|
|
|
|
value: function logger() {
|
|
|
|
console.log("Hello", this.name);
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Test;
|
|
|
|
}();"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
2018-11-23 13:22:07 +03:00
|
|
|
Classes::default(),
|
|
|
|
method_hoisted,
|
|
|
|
r#"class Foo {
|
2018-11-14 13:40:46 +03:00
|
|
|
foo(){
|
|
|
|
}
|
|
|
|
constructor(s){
|
|
|
|
}
|
|
|
|
}"#,
|
2018-11-23 13:22:07 +03:00
|
|
|
r#"var Foo = function () {
|
2018-11-14 13:40:46 +03:00
|
|
|
function Foo(s) {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Foo, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}();"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
2018-11-23 13:22:07 +03:00
|
|
|
Classes::default(),
|
|
|
|
static_method,
|
|
|
|
r#"class Foo {
|
2018-11-14 13:40:46 +03:00
|
|
|
static st(){}
|
|
|
|
}"#,
|
2018-11-23 13:22:07 +03:00
|
|
|
r#"var Foo = function () {
|
2018-11-14 13:40:46 +03:00
|
|
|
function Foo() {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Foo, null, [{
|
|
|
|
key: "st",
|
|
|
|
value: function st() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}();"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
2018-11-23 13:22:07 +03:00
|
|
|
Classes::default(),
|
|
|
|
complex_with_consturctor,
|
|
|
|
r#"class Foo {
|
2018-11-14 13:40:46 +03:00
|
|
|
foo(){
|
|
|
|
}
|
|
|
|
constructor(s){
|
|
|
|
}
|
|
|
|
static st(){}
|
|
|
|
}"#,
|
2018-11-23 13:22:07 +03:00
|
|
|
r#"var Foo = function () {
|
2018-11-14 13:40:46 +03:00
|
|
|
function Foo(s) {
|
|
|
|
_classCallCheck(this, Foo);
|
|
|
|
}
|
|
|
|
_createClass(Foo, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {}
|
|
|
|
}], [{
|
|
|
|
key: "st",
|
|
|
|
value: function st() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Foo;
|
|
|
|
}();"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
Classes::default(),
|
|
|
|
super_access,
|
|
|
|
r#"class Parent {
|
|
|
|
foo(a){}
|
|
|
|
}
|
|
|
|
class Child extends Parent {
|
|
|
|
foo(a, b){
|
|
|
|
super.foo(a);
|
|
|
|
super.f;
|
|
|
|
super.f.f.f.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
bar(){
|
|
|
|
}
|
|
|
|
}"#,
|
|
|
|
r#"var Parent = function () {
|
|
|
|
function Parent() {
|
|
|
|
_classCallCheck(this, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Parent, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo(a) {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Parent;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Child = function (_Parent) {
|
|
|
|
_inherits(Child, _Parent);
|
|
|
|
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Child, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo(a, b) {
|
|
|
|
_get(Child.prototype.__proto__ || Object.getPrototypeOf(Child.prototype), "foo", this).call(this, a);
|
|
|
|
_get(Child.prototype.__proto__ || Object.getPrototypeOf(Child.prototype), "f", this);
|
|
|
|
_get(Child.prototype.__proto__ || Object.getPrototypeOf(Child.prototype), "f", this).f.f.f;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "bar",
|
|
|
|
value: function bar() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Child;
|
|
|
|
}(Parent);"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
Classes::default(),
|
|
|
|
method_override,
|
|
|
|
r#"class Parent {
|
|
|
|
foo(a){}
|
|
|
|
}
|
|
|
|
class Child extends Parent {
|
|
|
|
foo(a, b){
|
|
|
|
super.foo(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
bar(){
|
|
|
|
}
|
|
|
|
}"#,
|
|
|
|
r#"var Parent = function () {
|
|
|
|
function Parent() {
|
|
|
|
_classCallCheck(this, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Parent, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo(a) {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Parent;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Child = function (_Parent) {
|
|
|
|
_inherits(Child, _Parent);
|
|
|
|
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Child, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo(a, b) {
|
|
|
|
_get(Child.prototype.__proto__ || Object.getPrototypeOf(Child.prototype), "foo", this).call(this, a);
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "bar",
|
|
|
|
value: function bar() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Child;
|
|
|
|
}(Parent);"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(Classes::default(), inherit_constructor, r#"class Parent {
|
|
|
|
constructor(){
|
|
|
|
}
|
|
|
|
foo(){}
|
|
|
|
}
|
|
|
|
class Child extends Parent {
|
|
|
|
}"#, r#"var Parent = function () {
|
|
|
|
function Parent() {
|
|
|
|
_classCallCheck(this, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Parent, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Parent;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Child = function (_Parent) {
|
|
|
|
_inherits(Child, _Parent);
|
|
|
|
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).apply(this, arguments));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Child;
|
|
|
|
}(Parent);"#);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
Classes::default(),
|
|
|
|
custom_constructor,
|
|
|
|
r#"class Parent {
|
|
|
|
constructor(){
|
|
|
|
}
|
|
|
|
foo(){}
|
|
|
|
}
|
|
|
|
class Child extends Parent {
|
|
|
|
constructor(){
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
}"#,
|
|
|
|
r#"var Parent = function () {
|
|
|
|
function Parent() {
|
|
|
|
_classCallCheck(this, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Parent, [{
|
|
|
|
key: "foo",
|
|
|
|
value: function foo() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Parent;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Child = function (_Parent) {
|
|
|
|
_inherits(Child, _Parent);
|
|
|
|
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
|
|
|
|
return _possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
return Child;
|
|
|
|
}(Parent);"#
|
|
|
|
);
|
|
|
|
|
|
|
|
test!(
|
|
|
|
Classes::default(),
|
|
|
|
custom_constructor_super_order,
|
|
|
|
r#"class Parent {
|
|
|
|
constructor(){
|
|
|
|
}
|
|
|
|
foo(){}
|
|
|
|
}
|
|
|
|
class Child extends Parent {
|
|
|
|
constructor(){
|
|
|
|
console.log('foo');
|
|
|
|
super();
|
|
|
|
console.log('bar');
|
|
|
|
}
|
|
|
|
}"#,
|
|
|
|
r#"var Parent = function () {
|
|
|
|
function Parent() {
|
|
|
|
_classCallCheck(this, Parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(Parent, [{
|
|
|
|
key: 'foo',
|
|
|
|
value: function foo() {}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return Parent;
|
|
|
|
}();
|
|
|
|
|
|
|
|
var Child = function (_Parent) {
|
|
|
|
_inherits(Child, _Parent);
|
|
|
|
|
|
|
|
function Child() {
|
|
|
|
_classCallCheck(this, Child);
|
|
|
|
|
|
|
|
console.log('foo');
|
|
|
|
|
|
|
|
var _this = _possibleConstructorReturn(this, (Child.__proto__ || Object.getPrototypeOf(Child)).call(this));
|
|
|
|
|
|
|
|
console.log('bar');
|
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Child;
|
|
|
|
}(Parent);"#
|
|
|
|
);
|