move all plugin tests out of babel-core and into their appropriate folders
This commit is contained in:
@@ -18,5 +18,8 @@
|
||||
},
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
]
|
||||
],
|
||||
"devDependencies": {
|
||||
"babel-helper-plugin-test-runner": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/declaration-binding.js
vendored
Normal file
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/declaration-binding.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
bar() {
|
||||
return Foo;
|
||||
}
|
||||
}
|
||||
|
||||
var Bar = Foo;
|
||||
Foo = 5;
|
||||
assert.equal((new Bar).bar(), Bar);
|
||||
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/expression-binding.js
vendored
Normal file
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/expression-binding.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var Foo = class Foo {
|
||||
bar() {
|
||||
return Foo;
|
||||
}
|
||||
}
|
||||
|
||||
var Bar = Foo;
|
||||
Foo = 5;
|
||||
assert.equal((new Bar).bar(), Bar);
|
||||
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/options.json
vendored
Normal file
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-es2015-classes", "transform-es2015-block-scoping"]
|
||||
}
|
||||
11
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/retain-no-call-on-reassign.js
vendored
Normal file
11
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/retain-no-call-on-reassign.js
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
bar() {
|
||||
return Foo;
|
||||
}
|
||||
}
|
||||
|
||||
var Bar = Foo;
|
||||
Foo = 5;
|
||||
assert.throws(function () {
|
||||
Bar.call(6);
|
||||
}, /Cannot call a class as a function/);
|
||||
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/shadow-container.js
vendored
Normal file
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/shadow-container.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
function build(val) {
|
||||
return class {
|
||||
[this.key]() {
|
||||
return val;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var Class = build.call({ key: "foo" }, "bar");
|
||||
assert.equal(new Class().foo(), "bar");
|
||||
21
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/super-change-proto.js
vendored
Normal file
21
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/super-change-proto.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var log = '';
|
||||
|
||||
class Base {
|
||||
p() { log += '[Base]'; }
|
||||
}
|
||||
|
||||
class OtherBase {
|
||||
p() { log += '[OtherBase]'; }
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
p() {
|
||||
log += '[Derived]';
|
||||
super.p();
|
||||
Derived.prototype.__proto__ = OtherBase.prototype;
|
||||
super.p();
|
||||
}
|
||||
}
|
||||
|
||||
new Derived().p();
|
||||
assert.equal(log, '[Derived][Base][OtherBase]');
|
||||
14
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/super-return.js
vendored
Normal file
14
packages/babel-plugin-transform-es2015-classes/test/fixtures/exec/super-return.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
constructor() {
|
||||
return { i: 1 };
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor() {
|
||||
assert.equal(super().i, 1);
|
||||
assert.equal(this.i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
new Bar;
|
||||
@@ -0,0 +1,13 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
woops.super.test();
|
||||
super();
|
||||
super.test();
|
||||
|
||||
super(...arguments);
|
||||
super("test", ...arguments);
|
||||
|
||||
super.test(...arguments);
|
||||
super.test("test", ...arguments);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
var _Foo$prototype$test, _Foo$prototype$test2;
|
||||
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
woops.super.test();
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, _Foo.call(this));
|
||||
|
||||
_Foo.prototype.test.call(_this);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, _Foo.apply(this, arguments));
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, _Foo.call.apply(_Foo, [this, "test"].concat(Array.prototype.slice.call(arguments))));
|
||||
|
||||
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [_this].concat(Array.prototype.slice.call(arguments)));
|
||||
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [_this, "test"].concat(Array.prototype.slice.call(arguments)));
|
||||
return _this;
|
||||
}
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
super.test;
|
||||
super.test.whatever;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, _Foo.call(this));
|
||||
|
||||
_Foo.prototype.test;
|
||||
_Foo.prototype.test.whatever;
|
||||
return _this;
|
||||
}
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,11 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
super.test.whatever();
|
||||
super.test();
|
||||
}
|
||||
|
||||
static test() {
|
||||
return super.wow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, _Foo.call(this));
|
||||
|
||||
_Foo.prototype.test.whatever();
|
||||
_Foo.prototype.test.call(_this);
|
||||
return _this;
|
||||
}
|
||||
|
||||
Test.test = function test() {
|
||||
return _Foo.wow.call(this);
|
||||
};
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/constructor-order/actual.js
vendored
Normal file
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/constructor-order/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
class x {
|
||||
f() {
|
||||
1
|
||||
2
|
||||
3
|
||||
}
|
||||
|
||||
constructor() {
|
||||
4
|
||||
5
|
||||
6
|
||||
}
|
||||
}
|
||||
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/constructor-order/expected.js
vendored
Normal file
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/constructor-order/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var x = (function () {
|
||||
x.prototype.f = function f() {
|
||||
1;
|
||||
2;
|
||||
3;
|
||||
};
|
||||
|
||||
function x() {
|
||||
babelHelpers.classCallCheck(this, x);
|
||||
|
||||
4;
|
||||
5;
|
||||
6;
|
||||
}
|
||||
|
||||
return x;
|
||||
})();
|
||||
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/literal-key/actual.js
vendored
Normal file
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/literal-key/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
"bar"() {
|
||||
|
||||
}
|
||||
}
|
||||
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/literal-key/expected.js
vendored
Normal file
9
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/literal-key/expected.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
Foo.prototype["bar"] = function bar() {};
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/options.json
vendored
Normal file
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers-2", "transform-es2015-function-name", ["transform-es2015-classes", { "loose": true }], "transform-es2015-spread", "transform-es2015-block-scoping"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class BaseController extends Chaplin.Controller {
|
||||
|
||||
}
|
||||
|
||||
class BaseController2 extends Chaplin.Controller.Another {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
babelHelpers.inherits(BaseController, _Chaplin$Controller);
|
||||
|
||||
function BaseController() {
|
||||
babelHelpers.classCallCheck(this, BaseController);
|
||||
return babelHelpers.possibleConstructorReturn(this, _Chaplin$Controller.apply(this, arguments));
|
||||
}
|
||||
|
||||
return BaseController;
|
||||
})(Chaplin.Controller);
|
||||
|
||||
var BaseController2 = (function (_Chaplin$Controller$A) {
|
||||
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
|
||||
|
||||
function BaseController2() {
|
||||
babelHelpers.classCallCheck(this, BaseController2);
|
||||
return babelHelpers.possibleConstructorReturn(this, _Chaplin$Controller$A.apply(this, arguments));
|
||||
}
|
||||
|
||||
return BaseController2;
|
||||
})(Chaplin.Controller.Another);
|
||||
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/super-class/actual.js
vendored
Normal file
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/super-class/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class Test extends Foo { }
|
||||
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/super-class/expected.js
vendored
Normal file
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/loose/super-class/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
return babelHelpers.possibleConstructorReturn(this, _Foo.apply(this, arguments));
|
||||
}
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
constructor() {
|
||||
super.hasOwnProperty("test");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
Function.prototype.hasOwnProperty.call(this, "test");
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
woops.super.test();
|
||||
super();
|
||||
super.test();
|
||||
|
||||
super(...arguments);
|
||||
super("test", ...arguments);
|
||||
|
||||
super.test(...arguments);
|
||||
super.test("test", ...arguments);
|
||||
}
|
||||
|
||||
test() {
|
||||
super.test();
|
||||
super.test(...arguments);
|
||||
super.test("test", ...arguments);
|
||||
}
|
||||
|
||||
static foo() {
|
||||
super.foo();
|
||||
super.foo(...arguments);
|
||||
super.foo("test", ...arguments);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
var _Object$getPrototypeO;
|
||||
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
var _babelHelpers$get;
|
||||
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
woops.super.test();
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Test).call(this));
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this).call(_this);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Test).apply(this, arguments));
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(Test)).call.apply(_Object$getPrototypeO, [this, "test"].concat(Array.prototype.slice.call(arguments))));
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this).apply(_this, arguments);
|
||||
(_babelHelpers$get = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this)).call.apply(_babelHelpers$get, [_this, "test"].concat(Array.prototype.slice.call(arguments)));
|
||||
return _this;
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, [{
|
||||
key: "test",
|
||||
value: function test() {
|
||||
var _babelHelpers$get2;
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this).apply(this, arguments);
|
||||
(_babelHelpers$get2 = babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_babelHelpers$get2, [this, "test"].concat(Array.prototype.slice.call(arguments)));
|
||||
}
|
||||
}], [{
|
||||
key: "foo",
|
||||
value: function foo() {
|
||||
var _babelHelpers$get3;
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test), "foo", this).call(this);
|
||||
babelHelpers.get(Object.getPrototypeOf(Test), "foo", this).apply(this, arguments);
|
||||
(_babelHelpers$get3 = babelHelpers.get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_babelHelpers$get3, [this, "test"].concat(Array.prototype.slice.call(arguments)));
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,7 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
super.test;
|
||||
super.test.whatever;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Test).call(this));
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this);
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this).whatever;
|
||||
return _this;
|
||||
}
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,11 @@
|
||||
class Test extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
super.test.whatever();
|
||||
super.test();
|
||||
}
|
||||
|
||||
static test() {
|
||||
return super.wow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Test).call(this));
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this).whatever();
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "test", _this).call(_this);
|
||||
return _this;
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, null, [{
|
||||
key: "test",
|
||||
value: function test() {
|
||||
return babelHelpers.get(Object.getPrototypeOf(Test), "wow", this).call(this);
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})(Foo);
|
||||
6
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/actual.js
vendored
Normal file
6
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/actual.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
foo() {}
|
||||
"foo"() {}
|
||||
[bar]() {}
|
||||
[bar + "foo"]() {}
|
||||
}
|
||||
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/exec.js
vendored
Normal file
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/exec.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
const sym = Symbol();
|
||||
|
||||
class Foo {
|
||||
[sym] () {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
[sym] () {
|
||||
return super[sym]() + 2;
|
||||
}
|
||||
}
|
||||
|
||||
let i = new Bar();
|
||||
|
||||
assert.equal(i[sym](), 3);
|
||||
20
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/expected.js
vendored
Normal file
20
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/computed-methods/expected.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Foo, [{
|
||||
key: "foo",
|
||||
value: function foo() {}
|
||||
}, {
|
||||
key: "foo",
|
||||
value: function foo() {}
|
||||
}, {
|
||||
key: bar,
|
||||
value: function value() {}
|
||||
}, {
|
||||
key: bar + "foo",
|
||||
value: function value() {}
|
||||
}]);
|
||||
return Foo;
|
||||
})();
|
||||
@@ -0,0 +1,7 @@
|
||||
class Example {
|
||||
constructor() {
|
||||
var Example;
|
||||
}
|
||||
}
|
||||
|
||||
var t = new Example();
|
||||
@@ -0,0 +1,7 @@
|
||||
var Example = function Example() {
|
||||
babelHelpers.classCallCheck(this, Example);
|
||||
|
||||
var _Example;
|
||||
};
|
||||
|
||||
var t = new Example();
|
||||
21
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/constructor/actual.js
vendored
Normal file
21
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/constructor/actual.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
class Test {
|
||||
constructor() {
|
||||
this.state = "test";
|
||||
}
|
||||
}
|
||||
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = "test";
|
||||
}
|
||||
}
|
||||
|
||||
class ConstructorScoping {
|
||||
constructor(){
|
||||
let bar;
|
||||
{
|
||||
let bar;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/constructor/expected.js
vendored
Normal file
29
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/constructor/expected.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
var Foo = (function (_Bar) {
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
var _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Foo).call(this));
|
||||
|
||||
_this.state = "test";
|
||||
return _this;
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})(Bar);
|
||||
|
||||
var ConstructorScoping = function ConstructorScoping() {
|
||||
babelHelpers.classCallCheck(this, ConstructorScoping);
|
||||
|
||||
var bar = undefined;
|
||||
{
|
||||
var _bar = undefined;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
super(() => {
|
||||
this.test;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
var Foo = (function (_Bar) {
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
|
||||
function Foo() {
|
||||
var _this;
|
||||
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
return _this = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Foo).call(this, () => {
|
||||
_this.test;
|
||||
}));
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})(Bar);
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
var Foo = (function (_Bar) {
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
return Foo;
|
||||
})(Bar);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "missing super() call in constructor"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export default class extends A {}
|
||||
12
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/export-super-class/expected.js
vendored
Normal file
12
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/export-super-class/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var _class = (function (_A) {
|
||||
babelHelpers.inherits(_class, _A);
|
||||
|
||||
function _class() {
|
||||
babelHelpers.classCallCheck(this, _class);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments));
|
||||
}
|
||||
|
||||
return _class;
|
||||
})(A);
|
||||
|
||||
export default _class;
|
||||
@@ -0,0 +1 @@
|
||||
var o = { foo: class foo {} };
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = { foo: function foo() {
|
||||
babelHelpers.classCallCheck(this, foo);
|
||||
} };
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
get test() {
|
||||
return 5 + 5;
|
||||
}
|
||||
set test(val) {
|
||||
this._test = val;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, [{
|
||||
key: "test",
|
||||
get: function get() {
|
||||
return 5 + 5;
|
||||
},
|
||||
set: function set(val) {
|
||||
this._test = val;
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})();
|
||||
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-getter/actual.js
vendored
Normal file
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-getter/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
get test() {
|
||||
return 5 + 5;
|
||||
}
|
||||
}
|
||||
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-getter/expected.js
vendored
Normal file
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-getter/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, [{
|
||||
key: "test",
|
||||
get: function get() {
|
||||
return 5 + 5;
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})();
|
||||
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-method/actual.js
vendored
Normal file
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-method/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
test() {
|
||||
return 5 + 5;
|
||||
}
|
||||
}
|
||||
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-method/expected.js
vendored
Normal file
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-method/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, [{
|
||||
key: "test",
|
||||
value: function test() {
|
||||
return 5 + 5;
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})();
|
||||
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-setter/actual.js
vendored
Normal file
5
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-setter/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
set test(val) {
|
||||
this._test = val;
|
||||
}
|
||||
}
|
||||
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-setter/expected.js
vendored
Normal file
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/instance-setter/expected.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var Test = (function () {
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Test, [{
|
||||
key: "test",
|
||||
set: function set(val) {
|
||||
this._test = val;
|
||||
}
|
||||
}]);
|
||||
return Test;
|
||||
})();
|
||||
@@ -0,0 +1,7 @@
|
||||
import { a } from "./a";
|
||||
|
||||
class Foo {
|
||||
_a() {
|
||||
a();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var _a2 = require("./a");
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Foo, [{
|
||||
key: "_a",
|
||||
value: function _a() {
|
||||
(0, _a2.a)();
|
||||
}
|
||||
}]);
|
||||
return Foo;
|
||||
})();
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers-2", "transform-es2015-function-name", "transform-es2015-classes", "transform-es2015-spread", "transform-es2015-block-scoping", "transform-es2015-modules-commonjs"]
|
||||
}
|
||||
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/options.json
vendored
Normal file
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["external-helpers-2", "transform-es2015-function-name", "transform-es2015-classes", "transform-es2015-spread", "transform-es2015-block-scoping"]
|
||||
}
|
||||
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/plain-class/actual.js
vendored
Normal file
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/plain-class/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class Test { }
|
||||
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/plain-class/expected.js
vendored
Normal file
3
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/plain-class/expected.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
};
|
||||
22
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/preserves-directives/actual.js
vendored
Normal file
22
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/preserves-directives/actual.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
class MyCtrl {
|
||||
constructor(a) {
|
||||
"any directive prologue";
|
||||
foo;
|
||||
}
|
||||
}
|
||||
|
||||
class MyCtrl2 {
|
||||
constructor(a) {
|
||||
"a";
|
||||
"b";
|
||||
foo;
|
||||
}
|
||||
}
|
||||
|
||||
class MyCtrl3 {
|
||||
constructor(a) {
|
||||
"a";
|
||||
foo;
|
||||
"b";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
var MyCtrl = function MyCtrl(a) {
|
||||
"any directive prologue";
|
||||
|
||||
babelHelpers.classCallCheck(this, MyCtrl);
|
||||
foo;
|
||||
};
|
||||
|
||||
var MyCtrl2 = function MyCtrl2(a) {
|
||||
"a";
|
||||
"b";
|
||||
|
||||
babelHelpers.classCallCheck(this, MyCtrl2);
|
||||
foo;
|
||||
};
|
||||
|
||||
var MyCtrl3 = function MyCtrl3(a) {
|
||||
"a";
|
||||
|
||||
babelHelpers.classCallCheck(this, MyCtrl3);
|
||||
foo;
|
||||
"b";
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
// #1649
|
||||
|
||||
class Foo {
|
||||
[Symbol()]() {}
|
||||
[Symbol()]() {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// #1649
|
||||
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(Foo, [{
|
||||
key: Symbol(),
|
||||
value: function value() {}
|
||||
}, {
|
||||
key: Symbol(),
|
||||
value: function value() {}
|
||||
}]);
|
||||
return Foo;
|
||||
})();
|
||||
@@ -0,0 +1,26 @@
|
||||
class Foo {
|
||||
constructor() {
|
||||
return { x: 1 };
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Foo().x, 1);
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar().x, 1);
|
||||
|
||||
class Bar2 extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
assert.equal(this.x, 1);
|
||||
return { x: 2 };
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar2().x, 2);
|
||||
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/statement/actual.js
vendored
Normal file
17
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/statement/actual.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var BaseView = class BaseView {
|
||||
constructor() {
|
||||
this.autoRender = true;
|
||||
}
|
||||
}
|
||||
|
||||
var BaseView = class {
|
||||
constructor() {
|
||||
this.autoRender = true;
|
||||
}
|
||||
}
|
||||
|
||||
var BaseView = class {
|
||||
foo() {
|
||||
this.autoRender = true;
|
||||
}
|
||||
}
|
||||
25
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/statement/expected.js
vendored
Normal file
25
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/statement/expected.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
var BaseView = function BaseView() {
|
||||
babelHelpers.classCallCheck(this, BaseView);
|
||||
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
var BaseView = function BaseView() {
|
||||
babelHelpers.classCallCheck(this, BaseView);
|
||||
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
var BaseView = (function () {
|
||||
function BaseView() {
|
||||
babelHelpers.classCallCheck(this, BaseView);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(BaseView, [{
|
||||
key: "foo",
|
||||
value: function foo() {
|
||||
this.autoRender = true;
|
||||
}
|
||||
}]);
|
||||
return BaseView;
|
||||
})();
|
||||
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/static/actual.js
vendored
Normal file
13
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/static/actual.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
class A {
|
||||
static a() {
|
||||
|
||||
}
|
||||
|
||||
static get b(){
|
||||
|
||||
}
|
||||
|
||||
static set b(b){
|
||||
|
||||
}
|
||||
}
|
||||
15
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/static/expected.js
vendored
Normal file
15
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/static/expected.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var A = (function () {
|
||||
function A() {
|
||||
babelHelpers.classCallCheck(this, A);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(A, null, [{
|
||||
key: "a",
|
||||
value: function a() {}
|
||||
}, {
|
||||
key: "b",
|
||||
get: function get() {},
|
||||
set: function set(b) {}
|
||||
}]);
|
||||
return A;
|
||||
})();
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
var Foo = function Foo() {
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
Object.getPrototypeOf(Foo).call(this);
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "super() is only allowed in a derived constructor"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class TestEmpty extends (class {}) {
|
||||
}
|
||||
|
||||
class TestConstructorOnly extends (class { constructor() {} }) {
|
||||
}
|
||||
|
||||
class TestMethodOnly extends (class { method() {} }) {
|
||||
}
|
||||
|
||||
class TestConstructorAndMethod extends (class {
|
||||
constructor() {}
|
||||
method() {}
|
||||
}) {
|
||||
}
|
||||
|
||||
class TestMultipleMethods extends (class {
|
||||
m1() {}
|
||||
m2() {}
|
||||
}) {}
|
||||
@@ -0,0 +1,99 @@
|
||||
var TestEmpty = (function (_ref) {
|
||||
babelHelpers.inherits(TestEmpty, _ref);
|
||||
|
||||
function TestEmpty() {
|
||||
babelHelpers.classCallCheck(this, TestEmpty);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(TestEmpty).apply(this, arguments));
|
||||
}
|
||||
|
||||
return TestEmpty;
|
||||
})((function () {
|
||||
function _class() {
|
||||
babelHelpers.classCallCheck(this, _class);
|
||||
}
|
||||
|
||||
return _class;
|
||||
})());
|
||||
|
||||
var TestConstructorOnly = (function (_ref2) {
|
||||
babelHelpers.inherits(TestConstructorOnly, _ref2);
|
||||
|
||||
function TestConstructorOnly() {
|
||||
babelHelpers.classCallCheck(this, TestConstructorOnly);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(TestConstructorOnly).apply(this, arguments));
|
||||
}
|
||||
|
||||
return TestConstructorOnly;
|
||||
})((function () {
|
||||
function _class2() {
|
||||
babelHelpers.classCallCheck(this, _class2);
|
||||
}
|
||||
|
||||
return _class2;
|
||||
})());
|
||||
|
||||
var TestMethodOnly = (function (_ref3) {
|
||||
babelHelpers.inherits(TestMethodOnly, _ref3);
|
||||
|
||||
function TestMethodOnly() {
|
||||
babelHelpers.classCallCheck(this, TestMethodOnly);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(TestMethodOnly).apply(this, arguments));
|
||||
}
|
||||
|
||||
return TestMethodOnly;
|
||||
})((function () {
|
||||
function _class3() {
|
||||
babelHelpers.classCallCheck(this, _class3);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(_class3, [{
|
||||
key: "method",
|
||||
value: function method() {}
|
||||
}]);
|
||||
return _class3;
|
||||
})());
|
||||
|
||||
var TestConstructorAndMethod = (function (_ref4) {
|
||||
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
|
||||
|
||||
function TestConstructorAndMethod() {
|
||||
babelHelpers.classCallCheck(this, TestConstructorAndMethod);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(TestConstructorAndMethod).apply(this, arguments));
|
||||
}
|
||||
|
||||
return TestConstructorAndMethod;
|
||||
})((function () {
|
||||
function _class4() {
|
||||
babelHelpers.classCallCheck(this, _class4);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(_class4, [{
|
||||
key: "method",
|
||||
value: function method() {}
|
||||
}]);
|
||||
return _class4;
|
||||
})());
|
||||
|
||||
var TestMultipleMethods = (function (_ref5) {
|
||||
babelHelpers.inherits(TestMultipleMethods, _ref5);
|
||||
|
||||
function TestMultipleMethods() {
|
||||
babelHelpers.classCallCheck(this, TestMultipleMethods);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(TestMultipleMethods).apply(this, arguments));
|
||||
}
|
||||
|
||||
return TestMultipleMethods;
|
||||
})((function () {
|
||||
function _class5() {
|
||||
babelHelpers.classCallCheck(this, _class5);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(_class5, [{
|
||||
key: "m1",
|
||||
value: function m1() {}
|
||||
}, {
|
||||
key: "m2",
|
||||
value: function m2() {}
|
||||
}]);
|
||||
return _class5;
|
||||
})());
|
||||
@@ -0,0 +1,7 @@
|
||||
class BaseController extends Chaplin.Controller {
|
||||
|
||||
}
|
||||
|
||||
class BaseController2 extends Chaplin.Controller.Another {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
var BaseController = (function (_Chaplin$Controller) {
|
||||
babelHelpers.inherits(BaseController, _Chaplin$Controller);
|
||||
|
||||
function BaseController() {
|
||||
babelHelpers.classCallCheck(this, BaseController);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(BaseController).apply(this, arguments));
|
||||
}
|
||||
|
||||
return BaseController;
|
||||
})(Chaplin.Controller);
|
||||
|
||||
var BaseController2 = (function (_Chaplin$Controller$A) {
|
||||
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
|
||||
|
||||
function BaseController2() {
|
||||
babelHelpers.classCallCheck(this, BaseController2);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(BaseController2).apply(this, arguments));
|
||||
}
|
||||
|
||||
return BaseController2;
|
||||
})(Chaplin.Controller.Another);
|
||||
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/super-class/actual.js
vendored
Normal file
1
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/super-class/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
class Test extends Foo { }
|
||||
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/super-class/expected.js
vendored
Normal file
10
packages/babel-plugin-transform-es2015-classes/test/fixtures/spec/super-class/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
var Test = (function (_Foo) {
|
||||
babelHelpers.inherits(Test, _Foo);
|
||||
|
||||
function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
return babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Test).apply(this, arguments));
|
||||
}
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
constructor() {
|
||||
super.hasOwnProperty("test");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
var Test = function Test() {
|
||||
babelHelpers.classCallCheck(this, Test);
|
||||
|
||||
babelHelpers.get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
foo() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "super() outside of class constructor"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
super.foo();
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "'super.*' is not allowed before super()"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
super(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "'this' is not allowed before super()"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
this.foo = "bar";
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "'this' is not allowed before super()"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
require("babel-helper-plugin-test-runner")(__dirname);
|
||||
Reference in New Issue
Block a user