From a821b2249be197493ce5088086f1519d1018cf5c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 26 Jan 2015 15:52:39 +1100 Subject: [PATCH] add class tests to optional async transformers --- .../async-to-generator/async/actual.js | 5 +++++ .../async-to-generator/async/expected.js | 22 +++++++++++++++++++ .../bluebird-coroutines/class/actual.js | 5 +++++ .../bluebird-coroutines/class/expected.js | 22 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 test/fixtures/transformation/async-to-generator/async/actual.js create mode 100644 test/fixtures/transformation/async-to-generator/async/expected.js create mode 100644 test/fixtures/transformation/bluebird-coroutines/class/actual.js create mode 100644 test/fixtures/transformation/bluebird-coroutines/class/expected.js diff --git a/test/fixtures/transformation/async-to-generator/async/actual.js b/test/fixtures/transformation/async-to-generator/async/actual.js new file mode 100644 index 0000000000..74c9331b37 --- /dev/null +++ b/test/fixtures/transformation/async-to-generator/async/actual.js @@ -0,0 +1,5 @@ +class Foo { + async foo() { + var wat = await bar(); + } +} diff --git a/test/fixtures/transformation/async-to-generator/async/expected.js b/test/fixtures/transformation/async-to-generator/async/expected.js new file mode 100644 index 0000000000..1fff5870ec --- /dev/null +++ b/test/fixtures/transformation/async-to-generator/async/expected.js @@ -0,0 +1,22 @@ +"use strict"; + +var _asyncToGenerator = function (fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(gen.next); var callThrow = step.bind(gen["throw"]); function step(arg) { try { var info = this(arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; }; + +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + +var Foo = (function () { + function Foo() {} + + _prototypeProperties(Foo, null, { + foo: { + value: _asyncToGenerator(function* () { + var wat = yield bar(); + }), + writable: true, + enumerable: true, + configurable: true + } + }); + + return Foo; +})(); diff --git a/test/fixtures/transformation/bluebird-coroutines/class/actual.js b/test/fixtures/transformation/bluebird-coroutines/class/actual.js new file mode 100644 index 0000000000..74c9331b37 --- /dev/null +++ b/test/fixtures/transformation/bluebird-coroutines/class/actual.js @@ -0,0 +1,5 @@ +class Foo { + async foo() { + var wat = await bar(); + } +} diff --git a/test/fixtures/transformation/bluebird-coroutines/class/expected.js b/test/fixtures/transformation/bluebird-coroutines/class/expected.js new file mode 100644 index 0000000000..b7f24fc421 --- /dev/null +++ b/test/fixtures/transformation/bluebird-coroutines/class/expected.js @@ -0,0 +1,22 @@ +"use strict"; + +var _bluebird = require("bluebird"); + +var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + +var Foo = (function () { + function Foo() {} + + _prototypeProperties(Foo, null, { + foo: { + value: _bluebird.coroutine(function* () { + var wat = yield bar(); + }), + writable: true, + enumerable: true, + configurable: true + } + }); + + return Foo; +})();