From edb880f87c7f4a5d466c4648db70a53ea71bf101 Mon Sep 17 00:00:00 2001 From: Ondrej Kraus Date: Wed, 25 Feb 2015 14:26:28 +0100 Subject: [PATCH] add tests --- .../arrow-functions/actual.js | 3 ++- .../arrow-functions/expected.js | 7 ++--- .../es6-parameters.rest/deopt/actual.js | 15 +++++++++++ .../es6-parameters.rest/deopt/expected.js | 26 +++++++++++++++++++ .../es6-parameters.rest/multiple/actual.js | 8 ++++-- .../es6-parameters.rest/multiple/expected.js | 13 +++++----- .../es6-parameters.rest/pattern/actual.js | 1 - .../es6-parameters.rest/pattern/expected.js | 9 +++---- .../es6-parameters.rest/single/actual.js | 6 +++-- .../es6-parameters.rest/single/expected.js | 11 ++++---- 10 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 test/fixtures/transformation/es6-parameters.rest/deopt/actual.js create mode 100644 test/fixtures/transformation/es6-parameters.rest/deopt/expected.js diff --git a/test/fixtures/transformation/es6-parameters.rest/arrow-functions/actual.js b/test/fixtures/transformation/es6-parameters.rest/arrow-functions/actual.js index 4a130fad8d..854274b1e6 100644 --- a/test/fixtures/transformation/es6-parameters.rest/arrow-functions/actual.js +++ b/test/fixtures/transformation/es6-parameters.rest/arrow-functions/actual.js @@ -1,3 +1,4 @@ var concat = (...arrs) => { - + var x = arrs[0]; + var y = arrs[1]; }; diff --git a/test/fixtures/transformation/es6-parameters.rest/arrow-functions/expected.js b/test/fixtures/transformation/es6-parameters.rest/arrow-functions/expected.js index 4b72d8d4cf..96e011a7fc 100644 --- a/test/fixtures/transformation/es6-parameters.rest/arrow-functions/expected.js +++ b/test/fixtures/transformation/es6-parameters.rest/arrow-functions/expected.js @@ -1,7 +1,8 @@ "use strict"; +var _arguments = arguments; var concat = function () { - for (var _len = arguments.length, arrs = Array(_len), _key = 0; _key < _len; _key++) { - arrs[_key] = arguments[_key]; - } + var x = _arguments[0]; + var y = _arguments[1]; }; + diff --git a/test/fixtures/transformation/es6-parameters.rest/deopt/actual.js b/test/fixtures/transformation/es6-parameters.rest/deopt/actual.js new file mode 100644 index 0000000000..be0fc35ff7 --- /dev/null +++ b/test/fixtures/transformation/es6-parameters.rest/deopt/actual.js @@ -0,0 +1,15 @@ +var x = function (foo, ...bar) { + console.log(bar); +}; + +var y = function (foo, ...bar) { + var x = function z(bar) { + bar[1] = 5; + }; +}; + +var z = function (foo, ...bar) { + var x = function () { + bar[1] = 5; + }; +}; diff --git a/test/fixtures/transformation/es6-parameters.rest/deopt/expected.js b/test/fixtures/transformation/es6-parameters.rest/deopt/expected.js new file mode 100644 index 0000000000..28492a1560 --- /dev/null +++ b/test/fixtures/transformation/es6-parameters.rest/deopt/expected.js @@ -0,0 +1,26 @@ +"use strict"; + +var x = function x(foo) { + for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + bar[_key - 1] = arguments[_key]; + } + + console.log(bar); +}; + +var y = function y(foo) { + var x = function z(bar) { + bar[1] = 5; + }; +}; + +var z = function z(foo) { + for (var _len = arguments.length, bar = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + bar[_key - 1] = arguments[_key]; + } + + var x = function x() { + bar[1] = 5; + }; +}; + diff --git a/test/fixtures/transformation/es6-parameters.rest/multiple/actual.js b/test/fixtures/transformation/es6-parameters.rest/multiple/actual.js index 49d78b919e..59f2c222f8 100644 --- a/test/fixtures/transformation/es6-parameters.rest/multiple/actual.js +++ b/test/fixtures/transformation/es6-parameters.rest/multiple/actual.js @@ -1,7 +1,11 @@ var t = function (f, ...items) { - + var x = f; + x = items[0]; + x = items[1]; }; function t(f, ...items) { - + var x = f; + x = items[0]; + x = items[1]; } diff --git a/test/fixtures/transformation/es6-parameters.rest/multiple/expected.js b/test/fixtures/transformation/es6-parameters.rest/multiple/expected.js index 470cd17396..18fc23f505 100644 --- a/test/fixtures/transformation/es6-parameters.rest/multiple/expected.js +++ b/test/fixtures/transformation/es6-parameters.rest/multiple/expected.js @@ -1,13 +1,14 @@ "use strict"; var t = function t(f) { - for (var _len = arguments.length, items = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - items[_key - 1] = arguments[_key]; - } + var x = f; + x = arguments[1]; + x = arguments[2]; }; function t(f) { - for (var _len = arguments.length, items = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - items[_key - 1] = arguments[_key]; - } + var x = f; + x = arguments[1]; + x = arguments[2]; } + diff --git a/test/fixtures/transformation/es6-parameters.rest/pattern/actual.js b/test/fixtures/transformation/es6-parameters.rest/pattern/actual.js index 020ad4f8f7..d26dae5716 100644 --- a/test/fixtures/transformation/es6-parameters.rest/pattern/actual.js +++ b/test/fixtures/transformation/es6-parameters.rest/pattern/actual.js @@ -1,3 +1,2 @@ var foo = function (...[a, b]) { - }; diff --git a/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js b/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js index b3f2634c07..a52993a722 100644 --- a/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js +++ b/test/fixtures/transformation/es6-parameters.rest/pattern/expected.js @@ -1,10 +1,7 @@ "use strict"; var foo = function foo() { - for (var _len = arguments.length, _ref = Array(_len), _key = 0; _key < _len; _key++) { - _ref[_key] = arguments[_key]; - } - - var a = _ref[0]; - var b = _ref[1]; + var a = arguments[0], + b = arguments[1]; }; + diff --git a/test/fixtures/transformation/es6-parameters.rest/single/actual.js b/test/fixtures/transformation/es6-parameters.rest/single/actual.js index dc9fbe391a..8e81076ecc 100644 --- a/test/fixtures/transformation/es6-parameters.rest/single/actual.js +++ b/test/fixtures/transformation/es6-parameters.rest/single/actual.js @@ -1,7 +1,9 @@ var t = function (...items) { - + var x = items[0]; + var y = items[1]; } function t(...items) { - + var x = items[0]; + var y = items[1]; } diff --git a/test/fixtures/transformation/es6-parameters.rest/single/expected.js b/test/fixtures/transformation/es6-parameters.rest/single/expected.js index 101e2f256c..add403243b 100644 --- a/test/fixtures/transformation/es6-parameters.rest/single/expected.js +++ b/test/fixtures/transformation/es6-parameters.rest/single/expected.js @@ -1,13 +1,12 @@ "use strict"; var t = function t() { - for (var _len = arguments.length, items = Array(_len), _key = 0; _key < _len; _key++) { - items[_key] = arguments[_key]; - } + var x = arguments[0]; + var y = arguments[1]; }; function t() { - for (var _len = arguments.length, items = Array(_len), _key = 0; _key < _len; _key++) { - items[_key] = arguments[_key]; - } + var x = arguments[0]; + var y = arguments[1]; } +