aboutsummaryrefslogtreecommitdiff
path: root/test/compress/bigint.js
blob: b417268c3d36296e964e960d475a3a7c79cc45f5 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
arithmetic: {
    input: {
        console.log(((1n + 0x2n) * (0o3n - -4n)) >> (5n - 6n));
    }
    expect_exact: "console.log((1n+0x2n)*(0o3n- -4n)>>5n-6n);"
    expect_stdout: "42n"
    node_version: ">=10"
}

minus_dot: {
    input: {
        console.log(typeof -42n.toString(), typeof (-42n).toString());
    }
    expect_exact: "console.log(typeof-42n.toString(),typeof(-42n).toString());"
    expect_stdout: "number string"
    node_version: ">=10"
}

evaluate: {
    options = {
        evaluate: true,
        unsafe: true,
    }
    input: {
        console.log((0xDEAD_BEEFn).toString(16));
    }
    expect: {
        console.log(0xdeadbeefn.toString(16));
    }
    expect_stdout: "deadbeef"
    node_version: ">=10"
}

Number: {
    options = {
        unsafe: true,
    }
    input: {
        console.log(Number(-0xfeed_dead_beef_badn));
    }
    expect: {
        console.log(+("" + -0xfeed_dead_beef_badn));
    }
    expect_stdout: "-1148098955808013200"
    node_version: ">=10"
}

issue_4590: {
    options = {
        collapse_vars: true,
    }
    input: {
        A = 1;
        0n || console.log("PASS");
    }
    expect: {
        A = 1;
        0n || console.log("PASS");
    }
    expect_stdout: "PASS"
    node_version: ">=10"
}

issue_4801: {
    options = {
        booleans: true,
        collapse_vars: true,
        reduce_vars: true,
        unused: true,
    }
    input: {
        try {
            (function(a) {
                A = 42;
                a || A;
            })(!(0 == 42 >> 0o644n));
        } catch (e) {
            console.log("PASS");
        }
    }
    expect: {
        try {
            (function(a) {
                0 != (A = 42) >> 0o644n || A;
            })();
        } catch (e) {
            console.log("PASS");
        }
    }
    expect_stdout: "PASS"
    node_version: ">=10"
}