From 539071570537b662e83f472dca11264d9cc09557 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 25 Mar 2015 20:20:51 +1100 Subject: [PATCH] update tests to latest experimental changes --- .../async-to-generator/async/expected.js | 15 +- .../bluebird-coroutines/class/expected.js | 22 +-- .../bluebird-coroutines/class/options.json | 3 + .../instance-getter-and-setter/actual.js | 4 +- .../instance-getter-and-setter/expected.js | 19 ++- .../es6-classes/instance-getter/expected.js | 13 +- .../es6-classes/instance-method/expected.js | 13 +- .../es6-classes/instance-setter/expected.js | 13 +- .../es6-classes/statement/expected.js | 11 +- .../super-class-anonymous/actual.js | 11 +- .../super-class-anonymous/expected.js | 145 +++++++++--------- .../es6-spread/new-expression/expected.js | 4 +- .../escape-quotes/expected.js | 2 +- .../functions/expected.js | 2 +- .../multiple/expected.js | 2 +- .../es6-template-literals/only/expected.js | 2 +- .../es6-template-literals/single/expected.js | 2 +- .../statement/expected.js | 2 +- .../fixtures/transformation/flow/options.json | 2 +- .../source-maps/class/expected.js | 20 +-- .../spec-function-name/all/actual.js | 2 +- .../spec-function-name/all/expected.js | 6 +- .../spec-proto-to-assign/class/expected.js | 6 +- 23 files changed, 151 insertions(+), 170 deletions(-) create mode 100644 test/fixtures/transformation/bluebird-coroutines/class/options.json diff --git a/test/fixtures/transformation/async-to-generator/async/expected.js b/test/fixtures/transformation/async-to-generator/async/expected.js index 7ff4ac6f79..a10142ea35 100644 --- a/test/fixtures/transformation/async-to-generator/async/expected.js +++ b/test/fixtures/transformation/async-to-generator/async/expected.js @@ -5,12 +5,11 @@ var Foo = (function () { babelHelpers.classCallCheck(this, Foo); } - babelHelpers.createClass(Foo, { - foo: { - value: babelHelpers.asyncToGenerator(function* () { - var wat = yield bar(); - }) - } - }); + babelHelpers.createClass(Foo, [{ + key: "foo", + value: babelHelpers.asyncToGenerator(function* () { + var wat = yield bar(); + }) + }]); return Foo; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/bluebird-coroutines/class/expected.js b/test/fixtures/transformation/bluebird-coroutines/class/expected.js index 25d962f60c..b08077911d 100644 --- a/test/fixtures/transformation/bluebird-coroutines/class/expected.js +++ b/test/fixtures/transformation/bluebird-coroutines/class/expected.js @@ -2,22 +2,16 @@ var _bluebird = require("bluebird"); -var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - var Foo = (function () { function Foo() { - _classCallCheck(this, Foo); + babelHelpers.classCallCheck(this, Foo); } - _createClass(Foo, { - foo: { - value: _bluebird.coroutine(function* () { - var wat = yield bar(); - }) - } - }); - + babelHelpers.createClass(Foo, [{ + key: "foo", + value: _bluebird.coroutine(function* () { + var wat = yield bar(); + }) + }]); return Foo; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/bluebird-coroutines/class/options.json b/test/fixtures/transformation/bluebird-coroutines/class/options.json new file mode 100644 index 0000000000..7d6e6cda1c --- /dev/null +++ b/test/fixtures/transformation/bluebird-coroutines/class/options.json @@ -0,0 +1,3 @@ +{ + "externalHelpers": true +} diff --git a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/actual.js b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/actual.js index d89f8ca733..52503296ec 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/actual.js +++ b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/actual.js @@ -1,8 +1,8 @@ class Test { get test() { - return 5 + 5; + return 5 + 5; } set test(val) { - this._test = val; + this._test = val; } } diff --git a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js index 50667d62ca..c7b50e3e3c 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter-and-setter/expected.js @@ -5,15 +5,14 @@ var Test = (function () { babelHelpers.classCallCheck(this, Test); } - babelHelpers.createClass(Test, { - test: { - get: function () { - return 5 + 5; - }, - set: function (val) { - this._test = val; - } + babelHelpers.createClass(Test, [{ + key: "test", + get: function () { + return 5 + 5; + }, + set: function (val) { + this._test = val; } - }); + }]); return Test; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-classes/instance-getter/expected.js b/test/fixtures/transformation/es6-classes/instance-getter/expected.js index 474c1e5e86..69d2cd1a38 100644 --- a/test/fixtures/transformation/es6-classes/instance-getter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-getter/expected.js @@ -5,12 +5,11 @@ var Test = (function () { babelHelpers.classCallCheck(this, Test); } - babelHelpers.createClass(Test, { - test: { - get: function () { - return 5 + 5; - } + babelHelpers.createClass(Test, [{ + key: "test", + get: function () { + return 5 + 5; } - }); + }]); return Test; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-classes/instance-method/expected.js b/test/fixtures/transformation/es6-classes/instance-method/expected.js index a62877a971..4b94d9ccc7 100644 --- a/test/fixtures/transformation/es6-classes/instance-method/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-method/expected.js @@ -5,12 +5,11 @@ var Test = (function () { babelHelpers.classCallCheck(this, Test); } - babelHelpers.createClass(Test, { - test: { - value: function test() { - return 5 + 5; - } + babelHelpers.createClass(Test, [{ + key: "test", + value: function test() { + return 5 + 5; } - }); + }]); return Test; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-classes/instance-setter/expected.js b/test/fixtures/transformation/es6-classes/instance-setter/expected.js index 98f8bcfadb..777679d4c2 100644 --- a/test/fixtures/transformation/es6-classes/instance-setter/expected.js +++ b/test/fixtures/transformation/es6-classes/instance-setter/expected.js @@ -5,12 +5,11 @@ var Test = (function () { babelHelpers.classCallCheck(this, Test); } - babelHelpers.createClass(Test, { - test: { - set: function (val) { - this._test = val; - } + babelHelpers.createClass(Test, [{ + key: "test", + set: function (val) { + this._test = val; } - }); + }]); return Test; -})(); \ No newline at end of file +})(); diff --git a/test/fixtures/transformation/es6-classes/statement/expected.js b/test/fixtures/transformation/es6-classes/statement/expected.js index 9c68a820dd..08a1f01343 100644 --- a/test/fixtures/transformation/es6-classes/statement/expected.js +++ b/test/fixtures/transformation/es6-classes/statement/expected.js @@ -21,12 +21,11 @@ var BaseView = (function () { babelHelpers.classCallCheck(this, _class2); }; - babelHelpers.createClass(_class2, { - foo: { - value: function foo() { - this.autoRender = true; - } + babelHelpers.createClass(_class2, [{ + key: "foo", + value: function foo() { + this.autoRender = true; } - }); + }]); return _class2; })(); \ No newline at end of file diff --git a/test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js b/test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js index bacf04fbc4..a6f77cafb3 100644 --- a/test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js +++ b/test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js @@ -8,13 +8,12 @@ class TestMethodOnly extends (class { method() {} }) { } class TestConstructorAndMethod extends (class { - constructor() {} - method() {} + constructor() {} + method() {} }) { } class TestMultipleMethods extends (class { - m1() {} - m2() {} -}) { -} + m1() {} + m2() {} +}) {} diff --git a/test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js b/test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js index 73c9d147a6..bde3fbe766 100644 --- a/test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js +++ b/test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js @@ -1,114 +1,111 @@ "use strict"; var TestEmpty = (function (_ref) { - function TestEmpty() { - babelHelpers.classCallCheck(this, TestEmpty); + function TestEmpty() { + babelHelpers.classCallCheck(this, TestEmpty); - if (_ref != null) { - _ref.apply(this, arguments); - } + if (_ref != null) { + _ref.apply(this, arguments); } + } - babelHelpers.inherits(TestEmpty, _ref); - return TestEmpty; + babelHelpers.inherits(TestEmpty, _ref); + return TestEmpty; })((function () { - var _class = function () { - babelHelpers.classCallCheck(this, _class); - }; + var _class = function () { + babelHelpers.classCallCheck(this, _class); + }; - return _class; + return _class; })()); var TestConstructorOnly = (function (_ref2) { - function TestConstructorOnly() { - babelHelpers.classCallCheck(this, TestConstructorOnly); + function TestConstructorOnly() { + babelHelpers.classCallCheck(this, TestConstructorOnly); - if (_ref2 != null) { - _ref2.apply(this, arguments); - } + if (_ref2 != null) { + _ref2.apply(this, arguments); } + } - babelHelpers.inherits(TestConstructorOnly, _ref2); - return TestConstructorOnly; + babelHelpers.inherits(TestConstructorOnly, _ref2); + return TestConstructorOnly; })((function () { - var _class2 = function () { - babelHelpers.classCallCheck(this, _class2); - }; + var _class2 = function () { + babelHelpers.classCallCheck(this, _class2); + }; - return _class2; + return _class2; })()); var TestMethodOnly = (function (_ref3) { - function TestMethodOnly() { - babelHelpers.classCallCheck(this, TestMethodOnly); + function TestMethodOnly() { + babelHelpers.classCallCheck(this, TestMethodOnly); - if (_ref3 != null) { - _ref3.apply(this, arguments); - } + if (_ref3 != null) { + _ref3.apply(this, arguments); } + } - babelHelpers.inherits(TestMethodOnly, _ref3); - return TestMethodOnly; + babelHelpers.inherits(TestMethodOnly, _ref3); + return TestMethodOnly; })((function () { - var _class3 = function () { - babelHelpers.classCallCheck(this, _class3); - }; + var _class3 = function () { + babelHelpers.classCallCheck(this, _class3); + }; - babelHelpers.createClass(_class3, { - method: { - value: function method() {} - } - }); - return _class3; + babelHelpers.createClass(_class3, [{ + key: "method", + value: function method() {} + }]); + return _class3; })()); var TestConstructorAndMethod = (function (_ref4) { - function TestConstructorAndMethod() { - babelHelpers.classCallCheck(this, TestConstructorAndMethod); + function TestConstructorAndMethod() { + babelHelpers.classCallCheck(this, TestConstructorAndMethod); - if (_ref4 != null) { - _ref4.apply(this, arguments); - } + if (_ref4 != null) { + _ref4.apply(this, arguments); } + } - babelHelpers.inherits(TestConstructorAndMethod, _ref4); - return TestConstructorAndMethod; + babelHelpers.inherits(TestConstructorAndMethod, _ref4); + return TestConstructorAndMethod; })((function () { - var _class4 = function () { - babelHelpers.classCallCheck(this, _class4); - }; + var _class4 = function () { + babelHelpers.classCallCheck(this, _class4); + }; - babelHelpers.createClass(_class4, { - method: { - value: function method() {} - } - }); - return _class4; + babelHelpers.createClass(_class4, [{ + key: "method", + value: function method() {} + }]); + return _class4; })()); var TestMultipleMethods = (function (_ref5) { - function TestMultipleMethods() { - babelHelpers.classCallCheck(this, TestMultipleMethods); + function TestMultipleMethods() { + babelHelpers.classCallCheck(this, TestMultipleMethods); - if (_ref5 != null) { - _ref5.apply(this, arguments); - } + if (_ref5 != null) { + _ref5.apply(this, arguments); } + } - babelHelpers.inherits(TestMultipleMethods, _ref5); - return TestMultipleMethods; + babelHelpers.inherits(TestMultipleMethods, _ref5); + return TestMultipleMethods; })((function () { - var _class5 = function () { - babelHelpers.classCallCheck(this, _class5); - }; + var _class5 = function () { + babelHelpers.classCallCheck(this, _class5); + }; - babelHelpers.createClass(_class5, { - m1: { - value: function m1() {} - }, - m2: { - value: function m2() {} - } - }); - return _class5; -})()); \ No newline at end of file + babelHelpers.createClass(_class5, [{ + key: "m1", + value: function m1() {} + }, { + key: "m2", + value: function m2() {} + }]); + return _class5; +})()); diff --git a/test/fixtures/transformation/es6-spread/new-expression/expected.js b/test/fixtures/transformation/es6-spread/new-expression/expected.js index 6f963d42dd..dce34bd1a3 100644 --- a/test/fixtures/transformation/es6-spread/new-expression/expected.js +++ b/test/fixtures/transformation/es6-spread/new-expression/expected.js @@ -1,4 +1,4 @@ "use strict"; -babelHelpers.applyConstructor(Numbers, babelHelpers.toConsumableArray(nums)); -babelHelpers.applyConstructor(Numbers, [1].concat(babelHelpers.toConsumableArray(nums))); +new (babelHelpers.bind.apply(Numbers, babelHelpers.toConsumableArray(nums)))(); +new (babelHelpers.bind.apply(Numbers, [1].concat(babelHelpers.toConsumableArray(nums))))(); diff --git a/test/fixtures/transformation/es6-template-literals/escape-quotes/expected.js b/test/fixtures/transformation/es6-template-literals/escape-quotes/expected.js index b13235af59..c34ee53b93 100644 --- a/test/fixtures/transformation/es6-template-literals/escape-quotes/expected.js +++ b/test/fixtures/transformation/es6-template-literals/escape-quotes/expected.js @@ -1,3 +1,3 @@ "use strict"; -var t = "'" + foo + "' \"" + bar + "\""; +var t = "'" + String(foo) + "' \"" + String(bar) + "\""; diff --git a/test/fixtures/transformation/es6-template-literals/functions/expected.js b/test/fixtures/transformation/es6-template-literals/functions/expected.js index 83df73bd85..20228e55fb 100644 --- a/test/fixtures/transformation/es6-template-literals/functions/expected.js +++ b/test/fixtures/transformation/es6-template-literals/functions/expected.js @@ -1,3 +1,3 @@ "use strict"; -var foo = "test " + _.test(foo) + " " + bar; +var foo = "test " + String(_.test(foo)) + " " + String(bar); diff --git a/test/fixtures/transformation/es6-template-literals/multiple/expected.js b/test/fixtures/transformation/es6-template-literals/multiple/expected.js index 664df108b0..47b9641c7b 100644 --- a/test/fixtures/transformation/es6-template-literals/multiple/expected.js +++ b/test/fixtures/transformation/es6-template-literals/multiple/expected.js @@ -1,3 +1,3 @@ "use strict"; -var foo = "test " + foo + " " + bar; +var foo = "test " + String(foo) + " " + String(bar); diff --git a/test/fixtures/transformation/es6-template-literals/only/expected.js b/test/fixtures/transformation/es6-template-literals/only/expected.js index 7fa1c086e7..1515a86363 100644 --- a/test/fixtures/transformation/es6-template-literals/only/expected.js +++ b/test/fixtures/transformation/es6-template-literals/only/expected.js @@ -1,3 +1,3 @@ "use strict"; -var foo = "" + test; +var foo = "" + String(test); diff --git a/test/fixtures/transformation/es6-template-literals/single/expected.js b/test/fixtures/transformation/es6-template-literals/single/expected.js index 1acf0454aa..971b630db3 100644 --- a/test/fixtures/transformation/es6-template-literals/single/expected.js +++ b/test/fixtures/transformation/es6-template-literals/single/expected.js @@ -1,3 +1,3 @@ "use strict"; -var foo = "test " + foo; +var foo = "test " + String(foo); diff --git a/test/fixtures/transformation/es6-template-literals/statement/expected.js b/test/fixtures/transformation/es6-template-literals/statement/expected.js index ee58935944..abddef1a72 100644 --- a/test/fixtures/transformation/es6-template-literals/statement/expected.js +++ b/test/fixtures/transformation/es6-template-literals/statement/expected.js @@ -1,3 +1,3 @@ "use strict"; -var foo = "test " + (foo + bar); +var foo = "test " + String(foo + bar); diff --git a/test/fixtures/transformation/flow/options.json b/test/fixtures/transformation/flow/options.json index 34b40c76e9..d19f6a5598 100644 --- a/test/fixtures/transformation/flow/options.json +++ b/test/fixtures/transformation/flow/options.json @@ -1,4 +1,4 @@ { - "whitelist": ["flow", "es7.asyncFunctions"], + "whitelist": ["flow", "es7.asyncFunctions", "es7.classProperties"], "noCheckAst": true } diff --git a/test/fixtures/transformation/source-maps/class/expected.js b/test/fixtures/transformation/source-maps/class/expected.js index 8b485be2b3..25517b3e99 100644 --- a/test/fixtures/transformation/source-maps/class/expected.js +++ b/test/fixtures/transformation/source-maps/class/expected.js @@ -1,24 +1,18 @@ "use strict"; -var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - -var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - var Test = (function () { function Test() { - _classCallCheck(this, Test); + babelHelpers.classCallCheck(this, Test); } - _createClass(Test, { - bar: { - get: function () { - throw new Error("wow"); - } + babelHelpers.createClass(Test, [{ + key: "bar", + get: function () { + throw new Error("wow"); } - }); - + }]); return Test; })(); var test = new Test(); -test.bar; \ No newline at end of file +test.bar; diff --git a/test/fixtures/transformation/spec-function-name/all/actual.js b/test/fixtures/transformation/spec-function-name/all/actual.js index 540cdd2db6..cba195bf78 100644 --- a/test/fixtures/transformation/spec-function-name/all/actual.js +++ b/test/fixtures/transformation/spec-function-name/all/actual.js @@ -44,5 +44,5 @@ var i = function () { // assignment to self var j = function () { - ({ j }) = 5; + ({ j } = 5); }; diff --git a/test/fixtures/transformation/spec-function-name/all/expected.js b/test/fixtures/transformation/spec-function-name/all/expected.js index 59673b095e..c10af5c4a8 100644 --- a/test/fixtures/transformation/spec-function-name/all/expected.js +++ b/test/fixtures/transformation/spec-function-name/all/expected.js @@ -74,6 +74,6 @@ var i = (function (_i) { // assignment to self var j = function j() { - var _ref = 5; - j = _ref.j; -}; + var _ = 5; + j = _.j; +}; \ No newline at end of file diff --git a/test/fixtures/transformation/spec-proto-to-assign/class/expected.js b/test/fixtures/transformation/spec-proto-to-assign/class/expected.js index df9e06b8ea..24e3490941 100644 --- a/test/fixtures/transformation/spec-proto-to-assign/class/expected.js +++ b/test/fixtures/transformation/spec-proto-to-assign/class/expected.js @@ -2,10 +2,10 @@ var _defaults = function (obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }; -var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) _defaults(subClass, superClass); }; - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; +var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) _defaults(subClass, superClass); }; + var Foo = (function (_Bar) { function Foo() { _classCallCheck(this, Foo); @@ -18,4 +18,4 @@ var Foo = (function (_Bar) { _inherits(Foo, _Bar); return Foo; -})(Bar); \ No newline at end of file +})(Bar);