Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80728 views
1
make_sequences_1: {
2
options = {
3
sequences: true
4
};
5
input: {
6
foo();
7
bar();
8
baz();
9
}
10
expect: {
11
foo(),bar(),baz();
12
}
13
}
14
15
make_sequences_2: {
16
options = {
17
sequences: true
18
};
19
input: {
20
if (boo) {
21
foo();
22
bar();
23
baz();
24
} else {
25
x();
26
y();
27
z();
28
}
29
}
30
expect: {
31
if (boo) foo(),bar(),baz();
32
else x(),y(),z();
33
}
34
}
35
36
make_sequences_3: {
37
options = {
38
sequences: true
39
};
40
input: {
41
function f() {
42
foo();
43
bar();
44
return baz();
45
}
46
function g() {
47
foo();
48
bar();
49
throw new Error();
50
}
51
}
52
expect: {
53
function f() {
54
return foo(), bar(), baz();
55
}
56
function g() {
57
throw foo(), bar(), new Error();
58
}
59
}
60
}
61
62
make_sequences_4: {
63
options = {
64
sequences: true
65
};
66
input: {
67
x = 5;
68
if (y) z();
69
70
x = 5;
71
for (i = 0; i < 5; i++) console.log(i);
72
73
x = 5;
74
for (; i < 5; i++) console.log(i);
75
76
x = 5;
77
switch (y) {}
78
79
x = 5;
80
with (obj) {}
81
}
82
expect: {
83
if (x = 5, y) z();
84
for (x = 5, i = 0; i < 5; i++) console.log(i);
85
for (x = 5; i < 5; i++) console.log(i);
86
switch (x = 5, y) {}
87
with (x = 5, obj);
88
}
89
}
90
91
lift_sequences_1: {
92
options = { sequences: true };
93
input: {
94
foo = !(x(), y(), bar());
95
}
96
expect: {
97
x(), y(), foo = !bar();
98
}
99
}
100
101
lift_sequences_2: {
102
options = { sequences: true, evaluate: true };
103
input: {
104
q = 1 + (foo(), bar(), 5) + 7 * (5 / (3 - (a(), (QW=ER), c(), 2))) - (x(), y(), 5);
105
}
106
expect: {
107
foo(), bar(), a(), QW = ER, c(), x(), y(), q = 36
108
}
109
}
110
111
lift_sequences_3: {
112
options = { sequences: true, conditionals: true };
113
input: {
114
x = (foo(), bar(), baz()) ? 10 : 20;
115
}
116
expect: {
117
foo(), bar(), x = baz() ? 10 : 20;
118
}
119
}
120
121
lift_sequences_4: {
122
options = { side_effects: true };
123
input: {
124
x = (foo, bar, baz);
125
}
126
expect: {
127
x = baz;
128
}
129
}
130
131
for_sequences: {
132
options = { sequences: true };
133
input: {
134
// 1
135
foo();
136
bar();
137
for (; false;);
138
// 2
139
foo();
140
bar();
141
for (x = 5; false;);
142
// 3
143
x = (foo in bar);
144
for (; false;);
145
// 4
146
x = (foo in bar);
147
for (y = 5; false;);
148
}
149
expect: {
150
// 1
151
for (foo(), bar(); false;);
152
// 2
153
for (foo(), bar(), x = 5; false;);
154
// 3
155
x = (foo in bar);
156
for (; false;);
157
// 4
158
x = (foo in bar);
159
for (y = 5; false;);
160
}
161
}
162
163