C : 0
},
reduce_vars : true,
+ toplevel : true,
unused : true
}
input: {
reduce_vars: true,
}
input: {
- if (code == 16)
- var bitsLength = 2, bitsOffset = 3, what = len;
- else if (code == 17)
- var bitsLength = 3, bitsOffset = 3, what = (len = 0);
- else if (code == 18)
- var bitsLength = 7, bitsOffset = 11, what = (len = 0);
- var repeatLength = this.getBits(bitsLength) + bitsOffset;
+ function f(){
+ if (code == 16)
+ var bitsLength = 2, bitsOffset = 3, what = len;
+ else if (code == 17)
+ var bitsLength = 3, bitsOffset = 3, what = (len = 0);
+ else if (code == 18)
+ var bitsLength = 7, bitsOffset = 11, what = (len = 0);
+ var repeatLength = this.getBits(bitsLength) + bitsOffset;
+ }
}
expect: {
- if (16 == code)
- var bitsLength = 2, bitsOffset = 3, what = len;
- else if (17 == code)
- var bitsLength = 3, bitsOffset = 3, what = (len = 0);
- else if (18 == code)
- var bitsLength = 7, bitsOffset = 11, what = (len = 0);
- var repeatLength = this.getBits(bitsLength) + bitsOffset;
+ function f(){
+ if (16 == code)
+ var bitsLength = 2, bitsOffset = 3, what = len;
+ else if (17 == code)
+ var bitsLength = 3, bitsOffset = 3, what = (len = 0);
+ else if (18 == code)
+ var bitsLength = 7, bitsOffset = 11, what = (len = 0);
+ var repeatLength = this.getBits(bitsLength) + bitsOffset;
+ }
}
}
reduce_vars: true,
}
input: {
- console.log(t);
- var t = 1;
+ function f(){
+ console.log(t);
+ var t = 1;
+ }
}
expect: {
- console.log(t);
- var t = 1;
+ function f(){
+ console.log(t);
+ var t = 1;
+ }
}
}
reduce_vars: true,
}
input: {
- function f(){
- return 0;
+ function f(a){
+ if (a)
+ var t = 1;
+ if (!t)
+ console.log(t);
}
- if (f())
- var t = 1;
- if (!t)
- console.log(t);
}
expect: {
- function f(){
- return 0;
+ function f(a){
+ if (a)
+ var t = 1;
+ if (!t)
+ console.log(t);
}
- if (f())
- var t = 1;
- if (!t)
- console.log(t);
}
}
reduce_vars: true,
}
input: {
- function f(){
- return 1;
- }
- l: {
- if (f()) break l;
- var t = 1;
+ function f(a){
+ l: {
+ if (a) break l;
+ var t = 1;
+ }
+ console.log(t);
}
- console.log(t);
}
expect: {
- function f(){
- return 1;
- }
- l: {
- if (f()) break l;
- var t = 1;
+ function f(a){
+ l: {
+ if (a) break l;
+ var t = 1;
+ }
+ console.log(t);
}
- console.log(t);
}
}
reduce_vars: true,
}
input: {
- var a = 1;
- x(a, b, d);
- for (var b = 2, c = 3; x(a, b, c, d); x(a, b, c, d)) {
- var d = 4, e = 5;
+ function f() {
+ var a = 1;
+ x(a, b, d);
+ for (var b = 2, c = 3; x(a, b, c, d); x(a, b, c, d)) {
+ var d = 4, e = 5;
+ x(a, b, c, d, e);
+ }
x(a, b, c, d, e);
}
- x(a, b, c, d, e)
}
expect: {
- var a = 1;
- x(1, b, d);
- for (var b = 2, c = 3; x(1, b, 3, d); x(1, b, 3, d)) {
- var d = 4, e = 5;
+ function f() {
+ var a = 1;
+ x(1, b, d);
+ for (var b = 2, c = 3; x(1, b, 3, d); x(1, b, 3, d)) {
+ var d = 4, e = 5;
+ x(1, b, 3, d, e);
+ }
x(1, b, 3, d, e);
}
- x(1, b, 3, d, e);
}
}
reduce_vars: true,
}
input: {
- var a = 1, b = 2;
- for (b in (function() {
- return x(a, b, c);
- })()) {
- var c = 3, d = 4;
+ function f() {
+ var a = 1, b = 2;
+ for (b in (function() {
+ return x(a, b, c);
+ })()) {
+ var c = 3, d = 4;
+ x(a, b, c, d);
+ }
x(a, b, c, d);
}
- x(a, b, c, d);
}
expect: {
- var a = 1, b = 2;
- for (b in (function() {
- return x(1, b, c);
- })()) {
- var c = 3, d = 4;
+ function f() {
+ var a = 1, b = 2;
+ for (b in (function() {
+ return x(1, b, c);
+ })()) {
+ var c = 3, d = 4;
+ x(1, b, c, d);
+ }
x(1, b, c, d);
}
- x(1, b, c, d);
}
}
reduce_vars: true,
}
input: {
- for (var long_name in {})
- console.log(long_name);
+ function f() {
+ for (var long_name in {})
+ console.log(long_name);
+ }
}
expect: {
- for (var long_name in {})
- console.log(long_name);
+ function f() {
+ for (var long_name in {})
+ console.log(long_name);
+ }
}
}
reduce_vars: true,
}
input: {
- try {
- a();
- } catch (e) {
- var b = 1;
+ function f() {
+ try {
+ a();
+ } catch (e) {
+ var b = 1;
+ }
+ console.log(b);
}
- console.log(b);
}
expect: {
- try {
- a();
- } catch (e) {
- var b = 1;
+ function f() {
+ try {
+ a();
+ } catch (e) {
+ var b = 1;
+ }
+ console.log(b);
}
- console.log(b);
}
}
reduce_vars: true,
}
input: {
- var id = "";
- for (id in {break: "me"})
- console.log(id);
+ function f() {
+ var id = "";
+ for (id in {break: "me"})
+ console.log(id);
+ }
}
expect: {
- var id = "";
- for (id in {break: "me"})
- console.log(id);
+ function f() {
+ var id = "";
+ for (id in {break: "me"})
+ console.log(id);
+ }
}
}
reduce_vars: true,
}
input: {
- var id = "";
- for (var id in {break: "me"})
+ function f() {
+ var id = "";
+ for (var id in {break: "me"})
+ console.log(id);
console.log(id);
- console.log(id);
+ }
}
expect: {
- var id = "";
- for (var id in {break: "me"})
+ function f() {
+ var id = "";
+ for (var id in {break: "me"})
+ console.log(id);
console.log(id);
- console.log(id);
+ }
+ }
+}
+
+toplevel_on: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel:true,
+ unused: true,
+ }
+ input: {
+ var x = 3;
+ console.log(x);
+ }
+ expect: {
+ console.log(3);
+ }
+}
+
+toplevel_off: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel:false,
+ unused: true,
+ }
+ input: {
+ var x = 3;
+ console.log(x);
+ }
+ expect: {
+ var x = 3;
+ console.log(x);
+ }
+}
+
+toplevel_on_loops_1: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:true,
+ unused: true,
+ }
+ input: {
+ function bar() {
+ console.log("bar:", --x);
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+ expect: {
+ function bar() {
+ console.log("bar:", --x);
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+}
+
+toplevel_off_loops_1: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:false,
+ unused: true,
+ }
+ input: {
+ function bar() {
+ console.log("bar:", --x);
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+ expect: {
+ function bar() {
+ console.log("bar:", --x);
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+}
+
+toplevel_on_loops_2: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:true,
+ unused: true,
+ }
+ input: {
+ function bar() {
+ console.log("bar:");
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+ expect: {
+ function bar() {
+ console.log("bar:");
+ }
+ for (;;) bar();
+ }
+}
+
+toplevel_off_loops_2: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:false,
+ unused: true,
+ }
+ input: {
+ function bar() {
+ console.log("bar:");
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+ expect: {
+ function bar() {
+ console.log("bar:");
+ }
+ var x = 3;
+ do
+ bar();
+ while (x);
+ }
+}
+
+toplevel_on_loops_3: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:true,
+ unused: true,
+ }
+ input: {
+ var x = 3;
+ while (x) bar();
+ }
+ expect: {
+ for (;;) bar();
+ }
+}
+
+toplevel_off_loops_3: {
+ options = {
+ evaluate: true,
+ loops: true,
+ reduce_vars: true,
+ toplevel:false,
+ unused: true,
+ }
+ input: {
+ var x = 3;
+ while (x) bar();
+ }
+ expect: {
+ var x = 3;
+ for (;x;) bar();
}
}