From 2cf2fd544b8d59bd01529c58f05e021bc57971d3 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Wed, 4 Jul 2018 16:06:58 -0700 Subject: [PATCH] Ensure that we don't get unexpected output files for tests that throw. (#8208) --- packages/babel-helper-fixtures/src/index.js | 19 +++++++ .../private-loose/native-classes/output.js | 18 ------ .../non-block-arrow-func/output.mjs | 25 --------- .../private-loose/reevaluated/output.js | 18 ------ .../private-loose/static-export/output.mjs | 21 ------- .../private-loose/static-infer-name/output.js | 8 --- .../private-loose/static-inherited/output.js | 55 ------------------- .../private-loose/static-undefined/output.js | 11 ---- .../fixtures/private-loose/static/output.js | 28 ---------- .../fixtures/private/native-classes/output.js | 14 ----- .../private/non-block-arrow-func/output.mjs | 22 -------- .../fixtures/private/reevaluated/output.js | 15 ----- .../private/regression-T2983/output.mjs | 16 ------ .../private/regression-T6719/output.js | 22 -------- .../fixtures/private/static-export/output.mjs | 18 ------ .../private/static-infer-name/output.js | 5 -- .../private/static-inherited/output.js | 51 ----------------- .../private/static-undefined/output.js | 9 --- .../test/fixtures/private/static/output.js | 26 --------- .../output.js | 9 --- 20 files changed, 19 insertions(+), 391 deletions(-) delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/native-classes/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/non-block-arrow-func/output.mjs delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/reevaluated/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-export/output.mjs delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-infer-name/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-inherited/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-undefined/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/non-block-arrow-func/output.mjs delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T2983/output.mjs delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T6719/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-export/output.mjs delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-infer-name/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-inherited/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-undefined/output.js delete mode 100644 packages/babel-plugin-proposal-class-properties/test/fixtures/private/static/output.js delete mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/output.js diff --git a/packages/babel-helper-fixtures/src/index.js b/packages/babel-helper-fixtures/src/index.js index 91284ecd0d..29a1543365 100644 --- a/packages/babel-helper-fixtures/src/index.js +++ b/packages/babel-helper-fixtures/src/index.js @@ -189,6 +189,25 @@ export default function get(entryLoc): Array { if (fs.existsSync(inputMapLoc)) { test.inputSourceMap = JSON.parse(readFile(inputMapLoc)); } + + if (taskOpts.throws) { + if (test.expect.code) { + throw new Error( + "Test cannot throw and also return output code: " + expectLoc, + ); + } + if (test.sourceMappings) { + throw new Error( + "Test cannot throw and also return sourcemappings: " + + sourceMappingsLoc, + ); + } + if (test.sourceMap) { + throw new Error( + "Test cannot throw and also return sourcemaps: " + sourceMapLoc, + ); + } + } } } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/native-classes/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/native-classes/output.js deleted file mode 100644 index b5e753c186..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/native-classes/output.js +++ /dev/null @@ -1,18 +0,0 @@ -var _foo, _bar; - -class Foo { - constructor() { - Object.defineProperty(this, _bar, { - writable: true, - value: "bar" - }); - } - -} - -_foo = babelHelpers.classPrivateFieldKey("foo"); -Object.defineProperty(Foo, _foo, { - writable: true, - value: "foo" -}); -_bar = babelHelpers.classPrivateFieldKey("bar"); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/non-block-arrow-func/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/non-block-arrow-func/output.mjs deleted file mode 100644 index 784e0909f5..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/non-block-arrow-func/output.mjs +++ /dev/null @@ -1,25 +0,0 @@ -export default (param => { - var _props, _class, _temp; - - return _temp = _class = - /*#__PURE__*/ - function () { - function App() { - babelHelpers.classCallCheck(this, App); - } - - babelHelpers.createClass(App, [{ - key: "getParam", - value: function getParam() { - return param; - } - }]); - return App; - }(), _props = babelHelpers.classPrivateFieldKey("props"), Object.defineProperty(_class, _props, { - writable: true, - value: { - prop1: 'prop1', - prop2: 'prop2' - } - }), _temp; -}); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/reevaluated/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/reevaluated/output.js deleted file mode 100644 index 87651fcca8..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/reevaluated/output.js +++ /dev/null @@ -1,18 +0,0 @@ -function classFactory() { - var _bar, _foo; - - var Foo = function Foo() { - babelHelpers.classCallCheck(this, Foo); - Object.defineProperty(this, _foo, { - writable: true, - value: "foo" - }); - }; - - _bar = babelHelpers.classPrivateFieldKey("bar"); - Object.defineProperty(Foo, _bar, { - writable: true, - value: "bar" - }); - _foo = babelHelpers.classPrivateFieldKey("foo"); -} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-export/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-export/output.mjs deleted file mode 100644 index 133132192b..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-export/output.mjs +++ /dev/null @@ -1,21 +0,0 @@ -var _property, _property2; - -export var MyClass = function MyClass() { - babelHelpers.classCallCheck(this, MyClass); -}; -_property = babelHelpers.classPrivateFieldKey("property"); -Object.defineProperty(MyClass, _property, { - writable: true, - value: value -}); - -var MyClass2 = function MyClass2() { - babelHelpers.classCallCheck(this, MyClass2); -}; - -_property2 = babelHelpers.classPrivateFieldKey("property"); -Object.defineProperty(MyClass2, _property2, { - writable: true, - value: value -}); -export { MyClass2 as default }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-infer-name/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-infer-name/output.js deleted file mode 100644 index 4b8ed2958b..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-infer-name/output.js +++ /dev/null @@ -1,8 +0,0 @@ -var _num, _class, _temp; - -var Foo = (_temp = _class = function Foo() { - babelHelpers.classCallCheck(this, Foo); -}, _num = babelHelpers.classPrivateFieldKey("num"), Object.defineProperty(_class, _num, { - writable: true, - value: 0 -}), _temp); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-inherited/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-inherited/output.js deleted file mode 100644 index 5510c2aa9e..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-inherited/output.js +++ /dev/null @@ -1,55 +0,0 @@ -var _foo, _foo2; - -var Base = -/*#__PURE__*/ -function () { - function Base() { - babelHelpers.classCallCheck(this, Base); - } - - babelHelpers.createClass(Base, null, [{ - key: "m", - value: function m() { - return babelHelpers.classPrivateFieldBase(this, _foo)[_foo]; - } - }]); - return Base; -}(); - -_foo = babelHelpers.classPrivateFieldKey("foo"); -Object.defineProperty(Base, _foo, { - writable: true, - value: 1 -}); - -var Sub1 = -/*#__PURE__*/ -function (_Base) { - babelHelpers.inherits(Sub1, _Base); - - function Sub1() { - babelHelpers.classCallCheck(this, Sub1); - return babelHelpers.possibleConstructorReturn(this, (Sub1.__proto__ || Object.getPrototypeOf(Sub1)).apply(this, arguments)); - } - - return Sub1; -}(Base); - -_foo2 = babelHelpers.classPrivateFieldKey("foo"); -Object.defineProperty(Sub1, _foo2, { - writable: true, - value: 2 -}); - -var Sub2 = -/*#__PURE__*/ -function (_Base2) { - babelHelpers.inherits(Sub2, _Base2); - - function Sub2() { - babelHelpers.classCallCheck(this, Sub2); - return babelHelpers.possibleConstructorReturn(this, (Sub2.__proto__ || Object.getPrototypeOf(Sub2)).apply(this, arguments)); - } - - return Sub2; -}(Base); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-undefined/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-undefined/output.js deleted file mode 100644 index 4db5076cd4..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static-undefined/output.js +++ /dev/null @@ -1,11 +0,0 @@ -var _bar; - -var Foo = function Foo() { - babelHelpers.classCallCheck(this, Foo); -}; - -_bar = babelHelpers.classPrivateFieldKey("bar"); -Object.defineProperty(Foo, _bar, { - writable: true, - value: void 0 -}); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static/output.js deleted file mode 100644 index 5ef62d69ad..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private-loose/static/output.js +++ /dev/null @@ -1,28 +0,0 @@ -var _bar; - -var Foo = -/*#__PURE__*/ -function () { - function Foo() { - babelHelpers.classCallCheck(this, Foo); - } - - babelHelpers.createClass(Foo, [{ - key: "test", - value: function test() { - return babelHelpers.classPrivateFieldBase(Foo, _bar)[_bar]; - } - }], [{ - key: "test", - value: function test() { - return babelHelpers.classPrivateFieldBase(Foo, _bar)[_bar]; - } - }]); - return Foo; -}(); - -_bar = babelHelpers.classPrivateFieldKey("bar"); -Object.defineProperty(Foo, _bar, { - writable: true, - value: "foo" -}); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js deleted file mode 100644 index f90dee5679..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js +++ /dev/null @@ -1,14 +0,0 @@ -var _foo, _bar; - -class Foo { - constructor() { - _bar.set(this, "bar"); - } - -} - -_foo = new WeakMap(); - -_foo.set(Foo, "foo"); - -_bar = new WeakMap(); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/non-block-arrow-func/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/non-block-arrow-func/output.mjs deleted file mode 100644 index e69c069b88..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/non-block-arrow-func/output.mjs +++ /dev/null @@ -1,22 +0,0 @@ -export default (param => { - var _props, _class, _temp; - - return _temp = _class = - /*#__PURE__*/ - function () { - function App() { - babelHelpers.classCallCheck(this, App); - } - - babelHelpers.createClass(App, [{ - key: "getParam", - value: function getParam() { - return param; - } - }]); - return App; - }(), _props = new WeakMap(), _props.set(_class, { - prop1: 'prop1', - prop2: 'prop2' - }), _temp; -}); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js deleted file mode 100644 index abfb86e72f..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js +++ /dev/null @@ -1,15 +0,0 @@ -function classFactory() { - var _bar, _foo; - - var Foo = function Foo() { - babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, "foo"); - }; - - _bar = new WeakMap(); - - _bar.set(Foo, "bar"); - - _foo = new WeakMap(); -} diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T2983/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T2983/output.mjs deleted file mode 100644 index ea8020b0be..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T2983/output.mjs +++ /dev/null @@ -1,16 +0,0 @@ -var _test, _class, _temp, _test2; - -call((_temp = _class = function _class() { - babelHelpers.classCallCheck(this, _class); -}, _test = new WeakMap(), _test.set(_class, true), _temp)); - -var _default = function _default() { - babelHelpers.classCallCheck(this, _default); -}; - -_test2 = new WeakMap(); - -_test2.set(_default, true); - -export { _default as default }; -; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T6719/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T6719/output.js deleted file mode 100644 index 553fcaf28a..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T6719/output.js +++ /dev/null @@ -1,22 +0,0 @@ -function withContext(ComposedComponent) { - var _propTypes, _class, _temp; - - return _temp = _class = - /*#__PURE__*/ - function (_Component) { - babelHelpers.inherits(WithContext, _Component); - - function WithContext() { - babelHelpers.classCallCheck(this, WithContext); - return babelHelpers.possibleConstructorReturn(this, (WithContext.__proto__ || Object.getPrototypeOf(WithContext)).apply(this, arguments)); - } - - return WithContext; - }(Component), _propTypes = new WeakMap(), _propTypes.set(_class, { - context: PropTypes.shape({ - addCss: PropTypes.func, - setTitle: PropTypes.func, - setMeta: PropTypes.func - }) - }), _temp; -} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-export/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-export/output.mjs deleted file mode 100644 index 39d6c7cdd5..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-export/output.mjs +++ /dev/null @@ -1,18 +0,0 @@ -var _property, _property2; - -export var MyClass = function MyClass() { - babelHelpers.classCallCheck(this, MyClass); -}; -_property = new WeakMap(); - -_property.set(MyClass, value); - -var MyClass2 = function MyClass2() { - babelHelpers.classCallCheck(this, MyClass2); -}; - -_property2 = new WeakMap(); - -_property2.set(MyClass2, value); - -export { MyClass2 as default }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-infer-name/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-infer-name/output.js deleted file mode 100644 index 16272497af..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-infer-name/output.js +++ /dev/null @@ -1,5 +0,0 @@ -var _num, _class, _temp; - -var Foo = (_temp = _class = function Foo() { - babelHelpers.classCallCheck(this, Foo); -}, _num = new WeakMap(), _num.set(_class, 0), _temp); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-inherited/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-inherited/output.js deleted file mode 100644 index e395c0915f..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-inherited/output.js +++ /dev/null @@ -1,51 +0,0 @@ -var _foo, _foo2; - -var Base = -/*#__PURE__*/ -function () { - function Base() { - babelHelpers.classCallCheck(this, Base); - } - - babelHelpers.createClass(Base, null, [{ - key: "m", - value: function m() { - return babelHelpers.classPrivateFieldGet(this, _foo); - } - }]); - return Base; -}(); - -_foo = new WeakMap(); - -_foo.set(Base, 1); - -var Sub1 = -/*#__PURE__*/ -function (_Base) { - babelHelpers.inherits(Sub1, _Base); - - function Sub1() { - babelHelpers.classCallCheck(this, Sub1); - return babelHelpers.possibleConstructorReturn(this, (Sub1.__proto__ || Object.getPrototypeOf(Sub1)).apply(this, arguments)); - } - - return Sub1; -}(Base); - -_foo2 = new WeakMap(); - -_foo2.set(Sub1, 2); - -var Sub2 = -/*#__PURE__*/ -function (_Base2) { - babelHelpers.inherits(Sub2, _Base2); - - function Sub2() { - babelHelpers.classCallCheck(this, Sub2); - return babelHelpers.possibleConstructorReturn(this, (Sub2.__proto__ || Object.getPrototypeOf(Sub2)).apply(this, arguments)); - } - - return Sub2; -}(Base); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-undefined/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-undefined/output.js deleted file mode 100644 index 1891916984..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static-undefined/output.js +++ /dev/null @@ -1,9 +0,0 @@ -var _bar; - -var Foo = function Foo() { - babelHelpers.classCallCheck(this, Foo); -}; - -_bar = new WeakMap(); - -_bar.set(Foo, void 0); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static/output.js deleted file mode 100644 index 47430af8af..0000000000 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/static/output.js +++ /dev/null @@ -1,26 +0,0 @@ -var _bar; - -var Foo = -/*#__PURE__*/ -function () { - function Foo() { - babelHelpers.classCallCheck(this, Foo); - } - - babelHelpers.createClass(Foo, [{ - key: "test", - value: function test() { - return babelHelpers.classPrivateFieldGet(Foo, _bar); - } - }], [{ - key: "test", - value: function test() { - return babelHelpers.classPrivateFieldGet(Foo, _bar); - } - }]); - return Foo; -}(); - -_bar = new WeakMap(); - -_bar.set(Foo, "foo"); diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/output.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/output.js deleted file mode 100644 index 66c3162cc8..0000000000 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/output.js +++ /dev/null @@ -1,9 +0,0 @@ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -let Foo = function Foo() { - "use strict"; - - _classCallCheck(this, Foo); - - super(); -};