diff --git a/test/form/unused-declarations-in-function/_config.js b/test/form/unused-declarations-in-function/_config.js new file mode 100644 index 0000000..21c7d2d --- /dev/null +++ b/test/form/unused-declarations-in-function/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'removes unused declarations and statements inside function (#1187)' +}; diff --git a/test/form/unused-declarations-in-function/_expected/amd.js b/test/form/unused-declarations-in-function/_expected/amd.js new file mode 100644 index 0000000..da2ca35 --- /dev/null +++ b/test/form/unused-declarations-in-function/_expected/amd.js @@ -0,0 +1,9 @@ +define(function () { 'use strict'; + + function foo() { + console.log("foo"); + } + + foo(); + +}); diff --git a/test/form/unused-declarations-in-function/_expected/cjs.js b/test/form/unused-declarations-in-function/_expected/cjs.js new file mode 100644 index 0000000..0aadb82 --- /dev/null +++ b/test/form/unused-declarations-in-function/_expected/cjs.js @@ -0,0 +1,7 @@ +'use strict'; + +function foo() { + console.log("foo"); +} + +foo(); diff --git a/test/form/unused-declarations-in-function/_expected/es.js b/test/form/unused-declarations-in-function/_expected/es.js new file mode 100644 index 0000000..343a59b --- /dev/null +++ b/test/form/unused-declarations-in-function/_expected/es.js @@ -0,0 +1,5 @@ +function foo() { + console.log("foo"); +} + +foo(); diff --git a/test/form/unused-declarations-in-function/_expected/iife.js b/test/form/unused-declarations-in-function/_expected/iife.js new file mode 100644 index 0000000..b1ac97f --- /dev/null +++ b/test/form/unused-declarations-in-function/_expected/iife.js @@ -0,0 +1,10 @@ +(function () { + 'use strict'; + + function foo() { + console.log("foo"); + } + + foo(); + +}()); diff --git a/test/form/unused-declarations-in-function/_expected/umd.js b/test/form/unused-declarations-in-function/_expected/umd.js new file mode 100644 index 0000000..2498f7e --- /dev/null +++ b/test/form/unused-declarations-in-function/_expected/umd.js @@ -0,0 +1,13 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + + function foo() { + console.log("foo"); + } + + foo(); + +}))); diff --git a/test/form/unused-declarations-in-function/main.js b/test/form/unused-declarations-in-function/main.js new file mode 100644 index 0000000..d7d2a56 --- /dev/null +++ b/test/form/unused-declarations-in-function/main.js @@ -0,0 +1,18 @@ +(function UnusedFunctionExpression() {}); +(class UnusedClassExpression {}); +var UnusedClassExpression = class UnusedClassExpression {}; +var unusedVar; +let unusedLet; +const unusedConst = 1; + +function foo() { + (function UnusedFunctionExpression() {}); + (class UnusedClassExpression {}); + var UnusedClassExpression = class UnusedClassExpression {}; + var unusedVar; + let unusedLet; + const unusedConst = 1; + console.log("foo"); +} + +foo();