diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/compress/directives.js | 95 | ||||
-rw-r--r-- | test/compress/functions.js | 51 | ||||
-rw-r--r-- | test/mocha/directives.js | 12 | ||||
-rw-r--r-- | test/mocha/number-literal.js | 10 |
4 files changed, 110 insertions, 58 deletions
diff --git a/test/compress/directives.js b/test/compress/directives.js new file mode 100644 index 00000000..590d1623 --- /dev/null +++ b/test/compress/directives.js @@ -0,0 +1,95 @@ +simple_statement_is_not_a_directive: { + input: { + "use strict" + .split(" ") + .forEach(function(s) { + console.log(s); + }); + console.log(!this); // is strict mode? + (function() { + "directive" + "" + "use strict" + "hello world" + .split(" ") + .forEach(function(s) { + console.log(s); + }); + console.log(!this); // is strict mode? + })(); + } + expect: { + "use strict".split(" ").forEach(function(s) { + console.log(s); + }); + console.log(!this); + (function() { + "directive"; + ""; + "use strict"; + "hello world".split(" ").forEach(function(s) { + console.log(s); + }); + console.log(!this); + })(); + } + expect_stdout: [ + "use", + "strict", + "false", + "hello", + "world", + "true", + ] +} + +drop_lone_use_strict: { + options = { + directives: true, + side_effects: true, + } + input: { + function f1() { + "use strict"; + } + function f2() { + "use strict"; + function f3() { + "use strict"; + } + } + (function f4() { + "use strict"; + })(); + } + expect: { + function f1() { + } + function f2() { + "use strict"; + function f3() { + } + } + } +} + +issue_3166: { + options = { + directives: true, + } + input: { + "foo"; + "use strict"; + function f() { + "use strict"; + "bar"; + "use asm"; + } + } + expect: { + "use strict"; + function f() { + "use asm"; + } + } +} diff --git a/test/compress/functions.js b/test/compress/functions.js index 8795afb1..4fea42dc 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2004,57 +2004,6 @@ deduplicate_parenthesis: { expect_exact: "({}).a=b;({}.a=b)();(function(){}).a=b;(function(){}.a=b)();" } -drop_lone_use_strict: { - options = { - directives: true, - side_effects: true, - } - input: { - function f1() { - "use strict"; - } - function f2() { - "use strict"; - function f3() { - "use strict"; - } - } - (function f4() { - "use strict"; - })(); - } - expect: { - function f1() { - } - function f2() { - "use strict"; - function f3() { - } - } - } -} - -issue_3166: { - options = { - directives: true, - } - input: { - "foo"; - "use strict"; - function f() { - "use strict"; - "bar"; - "use asm"; - } - } - expect: { - "use strict"; - function f() { - "use asm"; - } - } -} - issue_3016_1: { options = { inline: true, diff --git a/test/mocha/directives.js b/test/mocha/directives.js index 74660dc6..e872747a 100644 --- a/test/mocha/directives.js +++ b/test/mocha/directives.js @@ -54,8 +54,8 @@ describe("Directives", function() { [ [ '"use strict"\n', - [ "use strict"], - [ "use asm"] + [ "use strict" ], + [ "use asm" ] ], [ '"use\\\nstrict";', @@ -80,8 +80,8 @@ describe("Directives", function() { [ // no ; or newline '"use strict"', - [], - [ "use strict", "use\nstrict", "use \nstrict", "use asm" ] + [ "use strict" ], + [ "use\nstrict", "use \nstrict", "use asm" ] ], [ ';"use strict"', @@ -116,8 +116,8 @@ describe("Directives", function() { ], [ 'var foo = function() {"use strict"', // no ; or newline - [], - [ "use strict", "use\nstrict", "use \nstrict", "use asm" ] + [ "use strict" ], + [ "use\nstrict", "use \nstrict", "use asm" ] ], [ 'var foo = function() {;"use strict"', diff --git a/test/mocha/number-literal.js b/test/mocha/number-literal.js index c7560eb5..b87c88bb 100644 --- a/test/mocha/number-literal.js +++ b/test/mocha/number-literal.js @@ -2,10 +2,18 @@ var assert = require("assert"); var UglifyJS = require("../node"); describe("Number literals", function() { + it("Should allow legacy octal literals in non-strict mode", function() { + [ + "'use strict'\n.slice()\n00", + '"use strict"\n.slice()\nvar foo = 00', + ].forEach(function(input) { + UglifyJS.parse(input); + }); + }); it("Should not allow legacy octal literals in strict mode", function() { var inputs = [ '"use strict";00;', - '"use strict"; var foo = 00;' + '"use strict"; var foo = 00;', ]; var test = function(input) { return function() { |