aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/let.js
blob: 23909986556ea2ed3e69fc8d54ca3892a128fb7d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var Uglify = require('../../');
var assert = require("assert");

describe("let", function() {
    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 = '"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
        [
            "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 variable name still exist
        // to show the test generated enough symbols.
        [
            "to", "eo",
            "eet", "fet",
            "rar", "oar",
        ].forEach(function(name) {
            assert.ok(result.code.indexOf("var " + name + "=") >= 0);
        });

        done();
    });
});