Skip to content

Commit 592f244

Browse files
committed
Add tests for pipe
1 parent 3ed0e72 commit 592f244

File tree

2 files changed

+234
-0
lines changed

2 files changed

+234
-0
lines changed

tests/tests/src/option_stdlib_optimization_test.mjs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ function testPrimitive() {
99
console.log(42);
1010
}
1111

12+
function testPrimitivePipe() {
13+
console.log(42);
14+
}
15+
1216
function testPrimitiveRef() {
1317
console.log(42);
1418
}
@@ -17,6 +21,10 @@ function testNone() {
1721

1822
}
1923

24+
function testNonePipe() {
25+
26+
}
27+
2028
function testNoneRef() {
2129

2230
}
@@ -25,6 +33,10 @@ function testQualified() {
2533
console.log("hello");
2634
}
2735

36+
function testQualifiedPipe() {
37+
console.log("hello");
38+
}
39+
2840
function testQualifiedRef() {
2941
console.log("hello");
3042
}
@@ -33,6 +45,10 @@ function testComplexExpr() {
3345
console.log("true");
3446
}
3547

48+
function testComplexExprPipe() {
49+
console.log("true");
50+
}
51+
3652
function testComplexExprRef() {
3753
console.log("true");
3854
}
@@ -48,6 +64,17 @@ function testNestedCalls() {
4864
});
4965
}
5066

67+
function testNestedCallsPipe() {
68+
let opt = [
69+
1,
70+
2,
71+
3
72+
];
73+
opt.forEach(item => {
74+
console.log(item);
75+
});
76+
}
77+
5178
function testNestedCallsRef() {
5279
let opt = [
5380
1,
@@ -63,6 +90,10 @@ function testNamedCallback() {
6390
console.log(42);
6491
}
6592

93+
function testNamedCallbackPipe() {
94+
console.log(42);
95+
}
96+
6697
function testNamedCallbackRef() {
6798
console.log(42);
6899
}
@@ -72,6 +103,11 @@ function testMultiple() {
72103
console.log("second");
73104
}
74105

106+
function testMultiplePipe() {
107+
console.log("first");
108+
console.log("second");
109+
}
110+
75111
function testMultipleRef() {
76112
console.log("first");
77113
console.log("second");
@@ -81,26 +117,38 @@ function testNonPrimitive() {
81117
console.log("hello");
82118
}
83119

120+
function testNonPrimitivePipe() {
121+
console.log("hello");
122+
}
123+
84124
function testNonPrimitiveRef() {
85125
console.log("hello");
86126
}
87127

88128
let ForEach = {
89129
testPrimitive: testPrimitive,
130+
testPrimitivePipe: testPrimitivePipe,
90131
testPrimitiveRef: testPrimitiveRef,
91132
testNone: testNone,
133+
testNonePipe: testNonePipe,
92134
testNoneRef: testNoneRef,
93135
testQualified: testQualified,
136+
testQualifiedPipe: testQualifiedPipe,
94137
testQualifiedRef: testQualifiedRef,
95138
testComplexExpr: testComplexExpr,
139+
testComplexExprPipe: testComplexExprPipe,
96140
testComplexExprRef: testComplexExprRef,
97141
testNestedCalls: testNestedCalls,
142+
testNestedCallsPipe: testNestedCallsPipe,
98143
testNestedCallsRef: testNestedCallsRef,
99144
testNamedCallback: testNamedCallback,
145+
testNamedCallbackPipe: testNamedCallbackPipe,
100146
testNamedCallbackRef: testNamedCallbackRef,
101147
testMultiple: testMultiple,
148+
testMultiplePipe: testMultiplePipe,
102149
testMultipleRef: testMultipleRef,
103150
testNonPrimitive: testNonPrimitive,
151+
testNonPrimitivePipe: testNonPrimitivePipe,
104152
testNonPrimitiveRef: testNonPrimitiveRef
105153
};
106154

@@ -109,6 +157,11 @@ function testPrimitive$1() {
109157
console.log(result);
110158
}
111159

160+
function testPrimitivePipe$1() {
161+
let result = 42 + 1 | 0;
162+
console.log(result);
163+
}
164+
112165
function testPrimitiveRef$1() {
113166
let result = 42 + 1 | 0;
114167
console.log(result);
@@ -119,6 +172,11 @@ function testNone$1() {
119172
console.log(result);
120173
}
121174

175+
function testNonePipe$1() {
176+
let result;
177+
console.log(result);
178+
}
179+
122180
function testNoneRef$1() {
123181
let result;
124182
console.log(result);
@@ -129,6 +187,11 @@ function testQualified$1() {
129187
console.log(result);
130188
}
131189

190+
function testQualifiedPipe$1() {
191+
let result = "hello" + " world";
192+
console.log(result);
193+
}
194+
132195
function testQualifiedRef$1() {
133196
let result = "hello" + " world";
134197
console.log(result);
@@ -139,6 +202,11 @@ function testComplex() {
139202
console.log(result);
140203
}
141204

205+
function testComplexPipe() {
206+
let result = "true";
207+
console.log(result);
208+
}
209+
142210
function testComplexRef() {
143211
let result = "true";
144212
console.log(result);
@@ -149,21 +217,31 @@ function testNamedCallback$1() {
149217
console.log(result);
150218
}
151219

220+
function testNamedCallbackPipe$1() {
221+
let result = 42 + 1 | 0;
222+
console.log(result);
223+
}
224+
152225
function testNamedCallbackRef$1() {
153226
let result = 42 + 1 | 0;
154227
console.log(result);
155228
}
156229

157230
let $$Map = {
158231
testPrimitive: testPrimitive$1,
232+
testPrimitivePipe: testPrimitivePipe$1,
159233
testPrimitiveRef: testPrimitiveRef$1,
160234
testNone: testNone$1,
235+
testNonePipe: testNonePipe$1,
161236
testNoneRef: testNoneRef$1,
162237
testQualified: testQualified$1,
238+
testQualifiedPipe: testQualifiedPipe$1,
163239
testQualifiedRef: testQualifiedRef$1,
164240
testComplex: testComplex,
241+
testComplexPipe: testComplexPipe,
165242
testComplexRef: testComplexRef,
166243
testNamedCallback: testNamedCallback$1,
244+
testNamedCallbackPipe: testNamedCallbackPipe$1,
167245
testNamedCallbackRef: testNamedCallbackRef$1
168246
};
169247

@@ -172,6 +250,11 @@ function testPrimitive$2() {
172250
console.log(result);
173251
}
174252

253+
function testPrimitivePipe$2() {
254+
let result = 42 + 1 | 0;
255+
console.log(result);
256+
}
257+
175258
function testPrimitiveRef$2() {
176259
let result = 42 + 1 | 0;
177260
console.log(result);
@@ -182,6 +265,11 @@ function testNone$2() {
182265
console.log(result);
183266
}
184267

268+
function testNonePipe$2() {
269+
let result;
270+
console.log(result);
271+
}
272+
185273
function testNoneRef$2() {
186274
let result;
187275
console.log(result);
@@ -192,6 +280,11 @@ function testQualified$2() {
192280
console.log(result);
193281
}
194282

283+
function testQualifiedPipe$2() {
284+
let result = "hello" + " world";
285+
console.log(result);
286+
}
287+
195288
function testQualifiedRef$2() {
196289
let result = "hello" + " world";
197290
console.log(result);
@@ -202,6 +295,11 @@ function testComplex$1() {
202295
console.log(result);
203296
}
204297

298+
function testComplexPipe$1() {
299+
let result = "true";
300+
console.log(result);
301+
}
302+
205303
function testComplexRef$1() {
206304
let result = "true";
207305
console.log(result);
@@ -212,21 +310,31 @@ function testNamedCallback$2() {
212310
console.log(result);
213311
}
214312

313+
function testNamedCallbackPipe$2() {
314+
let result = 42 + 1 | 0;
315+
console.log(result);
316+
}
317+
215318
function testNamedCallbackRef$2() {
216319
let result = 42 + 1 | 0;
217320
console.log(result);
218321
}
219322

220323
let FlatMap = {
221324
testPrimitive: testPrimitive$2,
325+
testPrimitivePipe: testPrimitivePipe$2,
222326
testPrimitiveRef: testPrimitiveRef$2,
223327
testNone: testNone$2,
328+
testNonePipe: testNonePipe$2,
224329
testNoneRef: testNoneRef$2,
225330
testQualified: testQualified$2,
331+
testQualifiedPipe: testQualifiedPipe$2,
226332
testQualifiedRef: testQualifiedRef$2,
227333
testComplex: testComplex$1,
334+
testComplexPipe: testComplexPipe$1,
228335
testComplexRef: testComplexRef$1,
229336
testNamedCallback: testNamedCallback$2,
337+
testNamedCallbackPipe: testNamedCallbackPipe$2,
230338
testNamedCallbackRef: testNamedCallbackRef$2
231339
};
232340

0 commit comments

Comments
 (0)