aboutsummaryrefslogtreecommitdiff
path: root/test/compress/arrays.js
blob: 77ef761a1b1655281972810bdfe912887a678ca6 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
holes_and_undefined: {
    input: {
        w = [1,,];
        x = [1, 2, undefined];
        y = [1, , 2, ];
        z = [1, undefined, 3];
    }
    expect: {
        w=[1,,];
        x=[1,2,void 0];
        y=[1,,2];
        z=[1,void 0,3];
    }
}

constant_join: {
    options = {
        unsafe   : true,
        evaluate : true
    };
    input: {
        var a = [ "foo", "bar", "baz" ].join("");
        var a1 = [ "foo", "bar", "baz" ].join();
        var b = [ "foo", 1, 2, 3, "bar" ].join("");
        var c = [ boo(), "foo", 1, 2, 3, "bar", bar() ].join("");
        var c1 = [ boo(), bar(), "foo", 1, 2, 3, "bar", bar() ].join("");
        var c2 = [ 1, 2, "foo", "bar", baz() ].join("");
        var d = [ "foo", 1 + 2 + "bar", "baz" ].join("-");
        var e = [].join(foo + bar);
        var f = [].join("");
        var g = [].join("foo");
    }
    expect: {
        var a = "foobarbaz";
        var a1 = "foo,bar,baz";
        var b = "foo123bar";
        var c = boo() + "foo123bar" + bar();
        var c1 = "" + boo() + bar() + "foo123bar" + bar();
        var c2 = "12foobar" + baz();
        var d = "foo-3bar-baz";
        var e = [].join(foo + bar);
        var f = "";
        var g = "";
    }
}

constant_join_2: {
    options = {
        unsafe   : true,
        evaluate : true
    };
    input: {
        var a = [ "foo", "bar", boo(), "baz", "x", "y" ].join("");
        var b = [ "foo", "bar", boo(), "baz", "x", "y" ].join("-");
        var c = [ "foo", "bar", boo(), "baz", "x", "y" ].join("really-long-separator");
        var d = [ "foo", "bar", boo(),
                  [ "foo", 1, 2, 3, "bar" ].join("+"),
                  "baz", "x", "y" ].join("-");
        var e = [ "foo", "bar", boo(),
                  [ "foo", 1, 2, 3, "bar" ].join("+"),
                  "baz", "x", "y" ].join("really-long-separator");
        var f = [ "str", "str" + variable, "foo", "bar", "moo" + foo ].join("");
    }
    expect: {
        var a = "foobar" + boo() + "bazxy";
        var b = [ "foo-bar", boo(), "baz-x-y" ].join("-");
        var c = [ "foo", "bar", boo(), "baz", "x", "y" ].join("really-long-separator");
        var d = [ "foo-bar", boo(), "foo+1+2+3+bar-baz-x-y" ].join("-");
        var e = [ "foo", "bar", boo(),
                  "foo+1+2+3+bar",
                  "baz", "x", "y" ].join("really-long-separator");
        var f = "strstr" + variable + "foobarmoo" + foo;
    }
}

for_loop: {
    options = {
        unsafe      : true,
        unused      : true,
        evaluate    : true,
        reduce_vars : true
    };
    input: {
        function f0() {
            var a = [1, 2, 3];
            for (var i = 0; i < a.length; i++) {
                console.log(a[i]);
            }
        }

        function f1() {
            var a = [1, 2, 3];
            for (var i = 0, len = a.length; i < len; i++) {
                console.log(a[i]);
            }
        }

        function f2() {
            var a = [1, 2, 3];
            for (var i = 0; i < a.length; i++) {
                a[i]++;
            }
        }
    }
    expect: {
        function f0() {
            var a = [1, 2, 3];
            for (var i = 0; i < 3; i++)
                console.log(a[i]);
        }

        function f1() {
            var a = [1, 2, 3];
            for (var i = 0; i < 3; i++)
                console.log(a[i]);
        }

        function f2() {
            var a = [1, 2, 3];
            for (var i = 0; i < a.length; i++)
                a[i]++;
        }
    }
}
d>Ludovic Courtès 2013-09-07doc: Add "Data Types and Pattern Matching" to the Coding Style....* HACKING (Data Types and Pattern Matching): New section. Ludovic Courtès 2013-08-30doc: Add note about .dir-locals.el....* HACKING (Coding Style): Mention special indentation rules and .dir-locals.el. Ludovic Courtès 2013-08-30doc: Add a "Coding Style" section in 'HACKING'....* HACKING (Coding Style): New section. Ludovic Courtès 2013-08-30doc: Remove "Adding new packages" from `HACKING'....* HACKING (Adding new packages): Remove since it's now in the manual. Ludovic Courtès 2013-08-26doc: Change `HACKING' to refer to guix-devel@gnu.org....Reported by Alex Sassmannshausen <alex.sassmannshausen@gmail.com>. * HACKING: Replace "bug-guix" by "guix-devel". Ludovic Courtès 2013-07-19doc: Improve build instructions in README and HACKING....* README (Requirements): Remove Nixpkgs. Remove mentions of building from Git. (Installation): Refer to the manual. * HACKING: List requirements for when building from Git. Remove the `dot: Command not found' error. Ludovic Courtès 2013-07-13doc: Add "Building from Git" to 'HACKING'.Nikita Karetnikov 2013-07-07doc: Move the packaging guidelines to the manual....* HACKING (Packaging Guidelines): Remove. * doc/guix.texi (Packaging Guidelines): New node. Ludovic Courtès 2013-07-07doc: Add a "Porting" section....* HACKING (Porting the Guix distro on a new platform): Remove. * doc/guix.texi (Porting): New node. Describe cross-compilation as the only approach. Ludovic Courtès 2013-06-10doc: Mention copyright/license auditing in `HACKING'.Ludovic Courtès 2013-06-09doc: Update bootstrap-related info in `HACKING'.Ludovic Courtès 2013-06-04doc: Write about patch submission and packaging guidelines....* HACKING: Update the command names from `guix-build' to `guix build' & co. (Submitting Patches, Packaging Guidelines): New sections. * doc/guix.texi (Contributing): New section. Ludovic Courtès 2013-02-12doc: Add the commit policy to HACKING....* HACKING (Commit Access): New section. Ludovic Courtès 2013-01-22doc: Add "The Perfect Setup" in 'HACKING'....* HACKING (The Perfect Setup): New section. Ludovic Courtès 2013-01-21Update 'HACKING'....* HACKING (When the platform is supported by Nixpkgs): Update the example. Nikita Karetnikov 2013-01-18Update `HACKING'....* HACKING: Capitalize the title. (Running Guix before it is installed): New section. (Adding new packages): Update example. Ludovic Courtès 2013-01-08doc: Update porting instructions in `HACKING'....* HACKING (When the platform is supported by Nixpkgs): Update instructions. Ludovic Courtès 2012-11-21doc: Document basic package definitions....* doc/guix.texi (Programming Interface): Add introduction. (Defining Packages): Populate. Ludovic Courtès 2012-11-18Turn Guix into "GNU Guix"....* configure.ac: Change package name to "GNU Guix", and bug-report address to `gnu-system-discuss@gnu.org'. * doc/guix.texi: Replace "Guix" by "GNU Guix" in some places. (Top, Introduction): Mention "for the GNU system". * HACKING, README: Use "GNU Guix" instead of "Guix" in some places. Ludovic Courtès 2012-11-04distro: Move bootstrap packages to (distro packages bootstrap)....* distro/packages/base.scm (glibc-dynamic-linker, %bootstrap-guile, bootstrap-origin, package-from-tarball, %bootstrap-base-url, %bootstrap-coreutils&co, %bootstrap-binutils, %bootstrap-glibc, %bootstrap-gcc, %bootstrap-inputs, package-with-bootstrap-guile): Move to ... * distro/packages/bootstrap.scm: ... here. New file. * Makefile.am (MODULES): Add it. * tests/builders.scm: Use (distro packages bootstrap). (%bootstrap-guile): Remove. * tests/packages.scm: Likewise. * tests/union.scm: Likewise, and remove @@ to access %bootstrap-inputs. * tests/derivations.scm: Use (distro packages bootstrap) and remove @@ to access %bootstrap-coreutils&co. * HACKING (When the platform is supported by Nixpkgs): Update accordingly. Ludovic Courtès 2012-11-04doc: Add "Adding new packages" in `HACKING'....* HACKING (Adding new packages): New section. Ludovic Courtès 2012-10-25doc: Add `HACKING'....* HACKING: New file. * Makefile.am (EXTRA_DIST): Add it. Ludovic Courtès