From 9cce72def062e44c35ad59e530ace09e108aa89b Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Fri, 13 Feb 2015 17:04:18 +1100 Subject: [PATCH] update tests that use the toSlicedArray helper --- .../transformation/es6-destructuring/array/expected.js | 4 ++-- .../es6-destructuring/assignment-expression/expected.js | 4 ++-- .../es6-destructuring/assignment-statement/expected.js | 4 ++-- .../transformation/es6-destructuring/empty/expected.js | 4 ++-- .../transformation/es6-destructuring/for-in/expected.js | 4 ++-- .../transformation/es6-destructuring/for-of/expected.js | 4 ++-- .../es6-destructuring/member-expression/expected.js | 2 +- .../transformation/es6-destructuring/mixed/expected.js | 4 ++-- .../transformation/es6-destructuring/parameters/expected.js | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/fixtures/transformation/es6-destructuring/array/expected.js b/test/fixtures/transformation/es6-destructuring/array/expected.js index bd98c5b8db..80f0f225e7 100644 --- a/test/fixtures/transformation/es6-destructuring/array/expected.js +++ b/test/fixtures/transformation/es6-destructuring/array/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; var _ref = ["hello", [", ", "junk"], ["world"]]; @@ -11,4 +11,4 @@ var b = _ref$1[0]; var _ref$2 = _slicedToArray(_ref[2], 1); var c = _ref$2[0]; -var d = _ref[3]; \ No newline at end of file +var d = _ref[3]; diff --git a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js index 79c3a0d98c..dc77a31667 100644 --- a/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js +++ b/test/fixtures/transformation/es6-destructuring/assignment-expression/expected.js @@ -1,6 +1,6 @@ "use strict"; var _temp, _temp2; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; -console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp)); \ No newline at end of file +console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp)); diff --git a/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js b/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js index c0f9d340ed..858f09bbdc 100644 --- a/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js +++ b/test/fixtures/transformation/es6-destructuring/assignment-statement/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; var _ref = f(); @@ -8,4 +8,4 @@ var _ref2 = _slicedToArray(_ref, 2); a = _ref2[0]; b = _ref2[1]; -; \ No newline at end of file +; diff --git a/test/fixtures/transformation/es6-destructuring/empty/expected.js b/test/fixtures/transformation/es6-destructuring/empty/expected.js index 2d612a2e44..1d65a1a529 100644 --- a/test/fixtures/transformation/es6-destructuring/empty/expected.js +++ b/test/fixtures/transformation/es6-destructuring/empty/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; var _ref = ["foo", "hello", [", ", "junk"], ["world"]]; @@ -11,4 +11,4 @@ var b = _ref$2[0]; var _ref$3 = _slicedToArray(_ref[3], 1); var c = _ref$3[0]; -var d = _ref[4]; \ No newline at end of file +var d = _ref[4]; diff --git a/test/fixtures/transformation/es6-destructuring/for-in/expected.js b/test/fixtures/transformation/es6-destructuring/for-in/expected.js index 0e8d711009..f745b66aaf 100644 --- a/test/fixtures/transformation/es6-destructuring/for-in/expected.js +++ b/test/fixtures/transformation/es6-destructuring/for-in/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; for (var _ref in obj) { var _ref2 = _slicedToArray(_ref, 2); @@ -8,4 +8,4 @@ for (var _ref in obj) { var name = _ref2[0]; var value = _ref2[1]; print("Name: " + name + ", Value: " + value); -} \ No newline at end of file +} diff --git a/test/fixtures/transformation/es6-destructuring/for-of/expected.js b/test/fixtures/transformation/es6-destructuring/for-of/expected.js index 665973916b..0153f013e7 100644 --- a/test/fixtures/transformation/es6-destructuring/for-of/expected.js +++ b/test/fixtures/transformation/es6-destructuring/for-of/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { var _step$value = _slicedToArray(_step.value, 3); @@ -8,4 +8,4 @@ for (var _iterator = test.expectation.registers[Symbol.iterator](), _step; !(_st var name = _step$value[0]; var before = _step$value[1]; var after = _step$value[2]; -} \ No newline at end of file +} diff --git a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js index 2d2f0982f9..bde82a9e06 100644 --- a/test/fixtures/transformation/es6-destructuring/member-expression/expected.js +++ b/test/fixtures/transformation/es6-destructuring/member-expression/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; var _ref = [1, 2]; diff --git a/test/fixtures/transformation/es6-destructuring/mixed/expected.js b/test/fixtures/transformation/es6-destructuring/mixed/expected.js index cd4e7a9e82..b350be4d80 100644 --- a/test/fixtures/transformation/es6-destructuring/mixed/expected.js +++ b/test/fixtures/transformation/es6-destructuring/mixed/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; var _rect$topLeft = _slicedToArray(rect.topLeft, 2); @@ -9,4 +9,4 @@ var y1 = _rect$topLeft[1]; var _rect$bottomRight = _slicedToArray(rect.bottomRight, 2); var x2 = _rect$bottomRight[0]; -var y2 = _rect$bottomRight[1]; \ No newline at end of file +var y2 = _rect$bottomRight[1]; diff --git a/test/fixtures/transformation/es6-destructuring/parameters/expected.js b/test/fixtures/transformation/es6-destructuring/parameters/expected.js index e6fbfa2e0a..e1332ba704 100644 --- a/test/fixtures/transformation/es6-destructuring/parameters/expected.js +++ b/test/fixtures/transformation/es6-destructuring/parameters/expected.js @@ -1,6 +1,6 @@ "use strict"; -var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; +var _slicedToArray = function (arr, i) { if (!arr || !arr[Symbol.iterator]) { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } else if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } }; function somethingAdvanced(_ref) { var _ref$topLeft = _ref.topLeft; @@ -33,4 +33,4 @@ var unpackArray = function (_ref, _ref3) { return a + b + c; }; -console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3])); \ No newline at end of file +console.log(unpackArray(["hello", ", ", "world"], [1, 2, 3]));