aboutsummaryrefslogtreecommitdiff
path: root/test/compress/varify.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/compress/varify.js')
-rw-r--r--test/compress/varify.js236
1 files changed, 236 insertions, 0 deletions
diff --git a/test/compress/varify.js b/test/compress/varify.js
new file mode 100644
index 00000000..1286fc67
--- /dev/null
+++ b/test/compress/varify.js
@@ -0,0 +1,236 @@
+reduce_merge_const: {
+ options = {
+ merge_vars: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ const a = console;
+ console.log(typeof a);
+ var b = typeof a;
+ console.log(b);
+ }
+ expect: {
+ var b = console;
+ console.log(typeof b);
+ b = typeof b;
+ console.log(b);
+ }
+ expect_stdout: [
+ "object",
+ "object",
+ ]
+}
+
+reduce_merge_let: {
+ options = {
+ merge_vars: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ "use strict";
+ let a = console;
+ console.log(typeof a);
+ var b = typeof a;
+ console.log(b);
+ }
+ expect: {
+ "use strict";
+ var b = console;
+ console.log(typeof b);
+ b = typeof b;
+ console.log(b);
+ }
+ expect_stdout: [
+ "object",
+ "object",
+ ]
+ node_version: ">=4"
+}
+
+reduce_block_const: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ varify: true,
+ }
+ input: {
+ {
+ const a = typeof console;
+ console.log(a);
+ }
+ }
+ expect: {
+ var a = typeof console;
+ console.log(a);
+ }
+ expect_stdout: "object"
+}
+
+reduce_block_let: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ varify: true,
+ }
+ input: {
+ "use strict";
+ {
+ let a = typeof console;
+ console.log(a);
+ }
+ }
+ expect: {
+ "use strict";
+ var a = typeof console;
+ console.log(a);
+ }
+ expect_stdout: "object"
+ node_version: ">=4"
+}
+
+hoist_props_const: {
+ options = {
+ hoist_props: true,
+ passes: 2,
+ reduce_vars: true,
+ toplevel: true,
+ varify: true,
+ }
+ input: {
+ {
+ const o = {
+ p: "PASS",
+ };
+ console.log(o.p);
+ }
+ }
+ expect: {
+ var o_p = "PASS";
+ console.log(o_p);
+ }
+ expect_stdout: "PASS"
+}
+
+hoist_props_let: {
+ options = {
+ hoist_props: true,
+ passes: 2,
+ reduce_vars: true,
+ toplevel: true,
+ varify: true,
+ }
+ input: {
+ "use strict";
+ {
+ let o = {
+ p: "PASS",
+ };
+ console.log(o.p);
+ }
+ }
+ expect: {
+ "use strict";
+ var o_p = "PASS";
+ console.log(o_p);
+ }
+ expect_stdout: "PASS"
+ node_version: ">=4"
+}
+
+scope_adjustment_const: {
+ options = {
+ conditionals: true,
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ for (var k in [ 42 ])
+ console.log(function f() {
+ if (k) {
+ const a = 0;
+ }
+ }());
+ }
+ expect: {
+ for (var k in [ 42 ])
+ console.log(void (k && 0));
+ }
+ expect_stdout: "undefined"
+}
+
+scope_adjustment_let: {
+ options = {
+ conditionals: true,
+ inline: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ "use strict";
+ for (var k in [ 42 ])
+ console.log(function f() {
+ if (k) {
+ let a = 0;
+ }
+ }());
+ }
+ expect: {
+ "use strict";
+ for (var k in [ 42 ])
+ console.log(void (k && 0));
+ }
+ expect_stdout: "undefined"
+ node_version: ">=4"
+}
+
+issue_4191_const: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ const a = function() {};
+ console.log(typeof a, a());
+ }
+ expect: {
+ function a() {};
+ console.log(typeof a, a());
+ }
+ expect_stdout: "function undefined"
+}
+
+issue_4191_let: {
+ options = {
+ functions: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ varify: true,
+ }
+ input: {
+ "use strict";
+ let a = function() {};
+ console.log(typeof a, a());
+ }
+ expect: {
+ "use strict";
+ function a() {};
+ console.log(typeof a, a());
+ }
+ expect_stdout: "function undefined"
+ node_version: ">=4"
+}
here needed. Nicolas Goaziou 2020-04-22doc: cookbook: Explain how to use bind mounts....* doc/guix-cookbook.texi (Setting up a bind mount): Add example. Signed-off-by: Leo Famulari <leo@famulari.name> Matthew Brooks 2020-03-30gnu: Add sbcl-stumpwm-ttf-fonts....* gnu/packages/wm.scm (sbcl-stumpwm-ttf-fonts): New variable. * doc/guix-cookbook.texi (Customizing a Window Manager): Document SBCL-STUMPWM-TTF-FONTS installation and configuration. Oleg Pykhalov 2020-01-17doc: cookbook: Avoid URL reference to the manual....* doc/guix-cookbook.texi (Other build systems): Use @xref instead of @uref, and remove section number. Ludovic Courtès 2019-11-26doc: cookbook: Add cross-references to the Guile manual....* doc/guix-cookbook.texi (A Scheme Crash Course): Add cross-reference to the Guile manual. Ludovic Courtès 2019-11-26doc: cookbook: Use @result{} & co. instead of a '>' prompt....* doc/guix-cookbook.texi (A Scheme Crash Course) (Extended example): Use @result{}, @print{}, and @error{}. Ludovic Courtès 2019-11-26doc: cookbook: Use Texinfo quotes....* doc/guix-cookbook.texi: Use Texinfo quotes ``like this'' instead of straight quotes or curly quotes. Ludovic Courtès 2019-11-26doc: cookbook: Add cross-reference about ./pre-inst-env....* doc/guix-cookbook.texi (Direct checkout hacking): Refer to "Running Guix Before It Is Installed". Ludovic Courtès 2019-11-26doc: cookbook: Use @lisp for Scheme snippets....* doc/guix-cookbook.texi: Use @lisp instead of @example where appropriate. Ludovic Courtès 2019-10-30doc: Explain how to switch profile from empty shell in "Profiles in Practice"....* doc/guix-cookbook.texi (Profiles in Practice): Add example. Pierre Neidhardt 2019-10-28doc: Link to SICP Info page in "A Scheme Crash Course"....* doc/guix-cookbook.texi (Scheme tutorials): Replace Emacs Info reader hint with more useful interactive link to SICP Info page. Pierre Neidhardt 2019-10-28doc: Finish importing the "Packaging Tutorial"....* doc/guix-cookbook.texi (Packaging Tutorial): Import all sections after the Scheme crash course. Pierre Neidhardt 2019-10-28doc: Fix some typos in "Guix Profiles in Practice"....* doc/guix-cookbook.texi (Guix Profiles in Practice): Fix typos. Pierre Neidhardt 2019-10-25doc: cookbook: Use "@lisp" for Scheme snippets....* doc/guix-cookbook.texi: Use @lisp for Scheme snippets instead of "@example scheme". This allows for syntax highlighting of the HTML output. Ludovic Courtès 2019-10-24doc: Add "Guix Profiles in Practice" to the cookbook....* doc/guix-cookbook.texi (Advanced package management): New chapter. * doc/guix-cookbook.texi (Guix Profiles in Practice): New section. Pierre Neidhardt 2019-09-18doc: Add Guix Cookbook....* .gitignore: Update ignore list. * Makefile.am (assert-no-store-file-names): Exclude the cookbook. * bootstrap: Generate po files for cookbook translations. * doc/guix-cookbook.texi: New file. * doc/local.mk (info_TEXINFOS): Add it; add a rule to build cookbook translations. * po/doc/local.mk (DOC_COOKBOOK_PO_FILES): New variable. (EXTRA_DIST): Add cookbook pot file and po files. (doc-po-update-cookbook-%): New target. (doc-pot-update): Also update cookbook pot file. (doc-po-update): Also update cookbook po files. Ricardo Wurmus