aboutsummaryrefslogtreecommitdiff
path: root/test/compress/negate-iife.js
blob: 89c3f0646a316f47a2a8fe25b9e3a721e78f8994 (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
negate_iife_1: {
    options = {
        negate_iife: true
    };
    input: {
        (function(){ stuff() })();
    }
    expect: {
        !function(){ stuff() }();
    }
}

negate_iife_2: {
    options = {
        negate_iife: true
    };
    input: {
        (function(){ return {} })().x = 10; // should not transform this one
    }
    expect: {
        (function(){ return {} })().x = 10;
    }
}

negate_iife_3: {
    options = {
        negate_iife: true,
    };
    input: {
        (function(){ return true })() ? console.log(true) : console.log(false);
    }
    expect: {
        !function(){ return true }() ? console.log(false) : console.log(true);
    }
}

negate_iife_3: {
    options = {
        negate_iife: true,
        sequences: true
    };
    input: {
        (function(){ return true })() ? console.log(true) : console.log(false);
        (function(){
            console.log("something");
        })();
    }
    expect: {
        !function(){ return true }() ? console.log(false) : console.log(true), function(){
            console.log("something");
        }();
    }
}

negate_iife_4: {
    options = {
        negate_iife: true,
        sequences: true,
        conditionals: true,
    };
    input: {
        if ((function(){ return true })()) {
            foo(true);
        } else {
            bar(false);
        }
        (function(){
            console.log("something");
        })();
    }
    expect: {
        !function(){ return true }() ? bar(false) : foo(true), function(){
            console.log("something");
        }();
    }
}