aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/number-literal.js
blob: b87c88bb472e860b246c978eb81f9be8e9dede06 (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
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;',
        ];
        var test = function(input) {
            return function() {
                UglifyJS.parse(input);
            }
        };
        var error = function(e) {
            return e instanceof UglifyJS.JS_Parse_Error
                && e.message === "Legacy octal literals are not allowed in strict mode";
        };
        for (var i = 0; i < inputs.length; i++) {
            assert.throws(test(inputs[i]), error, inputs[i]);
        }
    });
});