diff options
Diffstat (limited to 'test/mocha/let.js')
-rw-r--r-- | test/mocha/let.js | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/test/mocha/let.js b/test/mocha/let.js index f41fd59b..23909986 100644 --- a/test/mocha/let.js +++ b/test/mocha/let.js @@ -2,29 +2,37 @@ var Uglify = require('../../'); var assert = require("assert"); describe("let", function() { - it("Should not produce `let` as a variable name in mangle", function(done) { + it("Should not produce reserved keywords as variable name in mangle", function(done) { this.timeout(10000); // Produce a lot of variables in a function and run it through mangle. - var s = '"use strict"; function foo() {'; - for (var i = 0; i < 21000; ++i) { + var s = '"dddddeeeeelllllooooottttt"; function foo() {'; + for (var i = 0; i < 18000; i++) { s += "var v" + i + "=0;"; } s += '}'; var result = Uglify.minify(s, {compress: false}); // Verify that select keywords and reserved keywords not produced - assert.strictEqual(result.code.indexOf("var let="), -1); - assert.strictEqual(result.code.indexOf("var do="), -1); - assert.strictEqual(result.code.indexOf("var var="), -1); + [ + "do", + "let", + "var", + ].forEach(function(name) { + assert.strictEqual(result.code.indexOf("var " + name + "="), -1); + }); // Verify that the variable names that appeared immediately before - // and after the erroneously generated `let` variable name still exist + // and after the erroneously generated variable name still exist // to show the test generated enough symbols. - assert(result.code.indexOf("var ket=") >= 0); - assert(result.code.indexOf("var met=") >= 0); + [ + "to", "eo", + "eet", "fet", + "rar", "oar", + ].forEach(function(name) { + assert.ok(result.code.indexOf("var " + name + "=") >= 0); + }); done(); }); }); - |