add decorator tests

This commit is contained in:
Sebastian McKenzie
2015-03-29 19:30:41 +11:00
parent 0dd32e7d9c
commit e27e7facac
22 changed files with 215 additions and 10 deletions

View File

@@ -1,6 +0,0 @@
@foo
class Foo {}
@foo
@bar
class Bar {}

View File

@@ -1,4 +0,0 @@
{
"externalHelpers": true,
"optional": ["es7.decorators"]
}

View File

@@ -0,0 +1,11 @@
class Foo {
@bar
get foo() {
}
@foo
set foo(bar) {
}
}

View File

@@ -0,0 +1,15 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
decorators: [bar, foo],
get: function () {},
set: function (bar) {}
}]);
return Foo;
})();

View File

@@ -0,0 +1,6 @@
class Foo {
@bar
get foo() {
}
}

View File

@@ -0,0 +1,14 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
decorators: [bar],
get: function () {}
}]);
return Foo;
})();

View File

@@ -0,0 +1,4 @@
class Foo {
@bar
foo = "Bar";
}

View File

@@ -0,0 +1,20 @@
"use strict";
var Foo = (function () {
var _instanceInitializers = {};
function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.foo = _instanceInitializers.foo.call(this);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
enumerable: true,
decorators: [bar],
initializer: function () {
return "Bar";
}
}], null, _instanceInitializers);
return Foo;
})();

View File

@@ -0,0 +1,4 @@
class Foo {
@bar
static foo = "Bar";
}

View File

@@ -0,0 +1,20 @@
"use strict";
var Foo = (function () {
var _staticInitializers = {};
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, null, [{
key: "foo",
enumerable: true,
decorators: [bar],
initializer: function () {
return "Bar";
}
}], null, _staticInitializers);
Foo.foo = _staticInitializers.foo.call(Foo);
return Foo;
})();

View File

@@ -0,0 +1,6 @@
class Foo {
@bar
foo() {
}
}

View File

@@ -0,0 +1,14 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
decorators: [bar],
value: function foo() {}
}]);
return Foo;
})();

View File

@@ -0,0 +1,4 @@
class Foo {
@bar
foo;
}

View File

@@ -0,0 +1,18 @@
"use strict";
var Foo = (function () {
var _instanceInitializers = {};
function Foo() {
babelHelpers.classCallCheck(this, Foo);
this.foo = _instanceInitializers.foo.call(this);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
enumerable: true,
decorators: [bar],
initializer: function () {}
}], null, _instanceInitializers);
return Foo;
})();

View File

@@ -0,0 +1,4 @@
class Foo {
@bar
static foo;
}

View File

@@ -0,0 +1,18 @@
"use strict";
var Foo = (function () {
var _staticInitializers = {};
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, null, [{
key: "foo",
enumerable: true,
decorators: [bar],
initializer: function () {}
}], null, _staticInitializers);
Foo.foo = _staticInitializers.foo.call(Foo);
return Foo;
})();

View File

@@ -0,0 +1,6 @@
class Foo {
@bar
set foo(arg) {
}
}

View File

@@ -0,0 +1,14 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createDecoratedClass(Foo, [{
key: "foo",
decorators: [bar],
set: function (arg) {}
}]);
return Foo;
})();

View File

@@ -0,0 +1,14 @@
@foo
class Foo {}
@foo
@bar
class Bar {}
var Foo2 = @bar class Foo {
};
var Bar2 = @foo @bar class Bar {
};

View File

@@ -18,3 +18,22 @@ var Bar = (function () {
Bar = bar(Bar) || Bar;
return Bar;
})();
var Foo2 = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
Foo = bar(Foo) || Foo;
return Foo;
})();
var Bar2 = (function () {
function Bar() {
babelHelpers.classCallCheck(this, Bar);
}
Bar = foo(Bar) || Bar;
Bar = bar(Bar) || Bar;
return Bar;
})();

View File

@@ -0,0 +1,4 @@
{
"externalHelpers": true,
"optional": ["es7.decorators", "es7.classProperties"]
}