Skip to content

Commit 854d7a2

Browse files
committed
turn off by default -- add more tests for polyvar pattern match later
1 parent 6c382df commit 854d7a2

23 files changed

+3305
-3782
lines changed

jscomp/core/bs_conditional_initial.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let setup_env () =
3030
Translcore.wrap_single_field_record := Transl_single_field_record.wrap_single_field_record;
3131
Translmod.eval_rec_bindings := Compile_rec_module.eval_rec_bindings;
3232
Typemod.should_hide := Typemod_hide.should_hide;
33-
#if 1 then
33+
#if 0 then
3434
Matching.make_test_sequence_variant_constant := Polyvar_pattern_match.make_test_sequence_variant_constant;
3535
Matching.call_switcher_variant_constant := Polyvar_pattern_match.call_switcher_variant_constant;
3636
Matching.call_switcher_variant_constr := Polyvar_pattern_match.call_switcher_variant_constr;

jscomp/test/bb.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33

44
function f(x) {
5-
if (x === /* b */98) {
6-
return "b";
7-
} else if (x === /* c */99) {
8-
return "c";
5+
if (x !== 98) {
6+
if (x >= 99) {
7+
return "c";
8+
} else {
9+
return "a";
10+
}
911
} else {
10-
return "a";
12+
return "b";
1113
}
1214
}
1315

@@ -55,12 +57,14 @@ function test(x) {
5557
Error: new Error()
5658
};
5759
}
58-
if (match === /* b */98) {
59-
return "b";
60-
} else if (match === /* c */99) {
61-
return "c";
60+
if (match !== 98) {
61+
if (match >= 99) {
62+
return "c";
63+
} else {
64+
return "a";
65+
}
6266
} else {
63-
return "a";
67+
return "b";
6468
}
6569
}
6670

jscomp/test/const_test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ function fff(x) {
2626
}
2727

2828
function h(x) {
29-
if (x === /* B */66) {
30-
return 1;
31-
} else if (x === /* C */67) {
32-
return 2;
29+
if (x !== 66) {
30+
if (x >= 67) {
31+
return 2;
32+
} else {
33+
return 0;
34+
}
3335
} else {
34-
return 0;
36+
return 1;
3537
}
3638
}
3739

jscomp/test/ext_filename_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ function chop_extension_if_any(fname) {
115115
var os_path_separator_char = Filename.dir_sep.charCodeAt(0);
116116

117117
function relative_path(file_or_dir_1, file_or_dir_2) {
118-
var relevant_dir1 = file_or_dir_1.HASH === /* File */781515420 ? Curry._1(Filename.dirname, file_or_dir_1.VAL) : file_or_dir_1.VAL;
119-
var relevant_dir2 = file_or_dir_2.HASH === /* File */781515420 ? Curry._1(Filename.dirname, file_or_dir_2.VAL) : file_or_dir_2.VAL;
118+
var relevant_dir1 = file_or_dir_1.HASH >= 781515420 ? Curry._1(Filename.dirname, file_or_dir_1.VAL) : file_or_dir_1.VAL;
119+
var relevant_dir2 = file_or_dir_2.HASH >= 781515420 ? Curry._1(Filename.dirname, file_or_dir_2.VAL) : file_or_dir_2.VAL;
120120
var dir1 = Ext_string_test.split(undefined, relevant_dir1, os_path_separator_char);
121121
var dir2 = Ext_string_test.split(undefined, relevant_dir2, os_path_separator_char);
122122
var go = function (_dir1, _dir2) {
@@ -149,13 +149,13 @@ function node_relative_path(node_modules_shorten, file1, dep_file) {
149149
var v = Ext_string_test.find(undefined, Test_literals.node_modules, file2);
150150
var len = file2.length;
151151
if (!(node_modules_shorten && v >= 0)) {
152-
return relative_path(dep_file.HASH === /* File */781515420 ? ({
152+
return relative_path(dep_file.HASH >= 781515420 ? ({
153153
HASH: /* File */781515420,
154154
VAL: absolute_path(dep_file.VAL)
155155
}) : ({
156156
HASH: /* Dir */3405101,
157157
VAL: absolute_path(dep_file.VAL)
158-
}), file1.HASH === /* File */781515420 ? ({
158+
}), file1.HASH >= 781515420 ? ({
159159
HASH: /* File */781515420,
160160
VAL: absolute_path(file1.VAL)
161161
}) : ({

jscomp/test/gpr_1891_test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var Curry = require("../../lib/js/curry.js");
44

55
function foo(x) {
6-
if (typeof x === "number" || !(x.HASH === /* Foo */3505894 && x.VAL === 3)) {
6+
if (typeof x === "number" || x.HASH !== 3505894 || x.VAL !== 3) {
77
console.log("2");
88
} else {
99
console.log("1");
@@ -12,31 +12,31 @@ function foo(x) {
1212
}
1313

1414
function foo2(x) {
15-
if (typeof x === "number" || !(x.HASH === /* Foo */3505894 && x.VAL === 3)) {
15+
if (typeof x === "number" || x.HASH !== 3505894 || x.VAL !== 3) {
1616
return "xxx";
1717
} else {
1818
return "xxxx";
1919
}
2020
}
2121

2222
function foo3(x) {
23-
if (typeof x === "number" || !(x.HASH === /* Foo */3505894 && x.VAL === 3)) {
23+
if (typeof x === "number" || x.HASH !== 3505894 || x.VAL !== 3) {
2424
return 2;
2525
} else {
2626
return 1;
2727
}
2828
}
2929

3030
function foo4(x, h) {
31-
if (typeof x === "number" || !(x.HASH === /* Foo */3505894 && x.VAL === 3)) {
31+
if (typeof x === "number" || x.HASH !== 3505894 || x.VAL !== 3) {
3232
return ;
3333
} else {
3434
return Curry._1(h, undefined);
3535
}
3636
}
3737

3838
function foo5(x) {
39-
if (typeof x === "number" || !(x.HASH === /* Foo */3505894 && x.VAL === 3)) {
39+
if (typeof x === "number" || x.HASH !== 3505894 || x.VAL !== 3) {
4040
console.log("x");
4141
} else {
4242
console.log("hi");

jscomp/test/gpr_4280_test.js

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,29 @@ function string(s) {
3535
}
3636

3737
function fn(authState, route) {
38+
var exit = 0;
3839
var onboardingRoute;
3940
if (typeof authState === "number") {
40-
var exit = 0;
41+
var exit$1 = 0;
4142
if (typeof route === "number") {
42-
if (route === /* SignUp */-384133096 || route === /* SignIn */-384135774 || route === /* Invite */-730831383 || route === /* PasswordReset */-799423340) {
43-
div({
44-
hd: string("LoggedOut"),
45-
tl: /* [] */0
46-
}, undefined);
47-
return 1;
43+
if (route >= -730831382) {
44+
if (route !== -384135774 && route !== -384133096) {
45+
exit$1 = 3;
46+
} else {
47+
exit = 2;
48+
}
49+
} else if (route !== -799423340 && route < -730831383) {
50+
exit$1 = 3;
51+
} else {
52+
exit = 2;
4853
}
49-
exit = 2;
50-
} else if (route.HASH === /* Onboarding */378129979) {
51-
onboardingRoute = route.VAL;
54+
} else if (route.HASH !== 378129979) {
55+
exit$1 = 3;
5256
} else {
53-
exit = 2;
57+
onboardingRoute = route.VAL;
58+
exit = 1;
5459
}
55-
if (exit === 2) {
60+
if (exit$1 === 3) {
5661
div({
5762
hd: string("Redirect"),
5863
tl: /* [] */0
@@ -61,13 +66,14 @@ function fn(authState, route) {
6166
}
6267

6368
} else {
64-
var exit$1 = 0;
65-
if (typeof route === "number" || route.HASH !== /* Onboarding */378129979) {
66-
exit$1 = 2;
69+
var exit$2 = 0;
70+
if (typeof route === "number" || route.HASH !== 378129979) {
71+
exit$2 = 3;
6772
} else {
6873
onboardingRoute = route.VAL;
74+
exit = 1;
6975
}
70-
if (exit$1 === 2) {
76+
if (exit$2 === 3) {
7177
console.log(authState.VAL);
7278
div({
7379
hd: string("VerifyEmail"),
@@ -77,12 +83,22 @@ function fn(authState, route) {
7783
}
7884

7985
}
80-
console.log(onboardingRoute);
81-
div({
82-
hd: string("Onboarding"),
83-
tl: /* [] */0
84-
}, undefined);
85-
return 0;
86+
switch (exit) {
87+
case 1 :
88+
console.log(onboardingRoute);
89+
div({
90+
hd: string("Onboarding"),
91+
tl: /* [] */0
92+
}, undefined);
93+
return 0;
94+
case 2 :
95+
div({
96+
hd: string("LoggedOut"),
97+
tl: /* [] */0
98+
}, undefined);
99+
return 1;
100+
101+
}
86102
}
87103

88104
eq("File \"gpr_4280_test.ml\", line 46, characters 6-13", fn(/* Unauthenticated */-54822762, /* Invite */-730831383), 1);

jscomp/test/ocaml_parsetree_test.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11149,28 +11149,29 @@ function directive_parse(token_with_comments, lexbuf) {
1114911149
var pred = match[0];
1115011150
var match$1 = semantic_version_parse(lhs$1, 0, lhs$1.length - 1 | 0);
1115111151
var lversion = match$1[0];
11152-
if (pred === /* Ge */15934) {
11153-
return Caml_obj.caml_greaterequal(lversion, version);
11154-
}
11155-
if (pred === /* Gt */15949) {
11156-
return Caml_obj.caml_greaterthan(lversion, version);
11157-
}
11158-
if (pred === /* Le */17049) {
11159-
return Caml_obj.caml_lessequal(lversion, version);
11160-
}
11161-
if (pred === /* Lt */17064) {
11162-
return Caml_obj.caml_lessthan(lversion, version);
11163-
}
11164-
if (pred === /* Exact */172069535) {
11165-
return Caml_obj.caml_equal(lversion, version);
11166-
}
1116711152
var l_major = lversion[0];
11168-
if (pred === /* Compatible */785637236) {
11169-
return major === l_major;
11170-
} else if (major === l_major) {
11171-
return version[1] === lversion[1];
11153+
if (pred >= 17049) {
11154+
if (pred >= 172069535) {
11155+
if (pred >= 785637236) {
11156+
return major === l_major;
11157+
} else {
11158+
return Caml_obj.caml_equal(lversion, version);
11159+
}
11160+
} else if (pred >= 17064) {
11161+
return Caml_obj.caml_lessthan(lversion, version);
11162+
} else {
11163+
return Caml_obj.caml_lessequal(lversion, version);
11164+
}
11165+
} else if (pred !== 15934) {
11166+
if (pred >= 15949) {
11167+
return Caml_obj.caml_greaterthan(lversion, version);
11168+
} else if (major === l_major) {
11169+
return version[1] === lversion[1];
11170+
} else {
11171+
return false;
11172+
}
1117211173
} else {
11173-
return false;
11174+
return Caml_obj.caml_greaterequal(lversion, version);
1117411175
}
1117511176
}
1117611177
exit$2 = 3;

0 commit comments

Comments
 (0)