Skip to content

Commit 51273b7

Browse files
committed
add a failure test case
1 parent 66c4ebf commit 51273b7

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed

jscomp/test/build.ninja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cm
320320
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
321321
build test/gpr_4069_test.cmi test/gpr_4069_test.cmj : cc test/gpr_4069_test.ml | $stdlib
322322
build test/gpr_4265_test.cmi test/gpr_4265_test.cmj : cc test/gpr_4265_test.ml | test/mt.cmj $stdlib
323+
build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml | $stdlib
323324
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib
324325
build test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib
325326
build test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib

jscomp/test/gpr_4280_test.js

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
'use strict';
2+
3+
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
4+
5+
var u = {
6+
contents: 0
7+
};
8+
9+
function div(children, param) {
10+
for(var i = 0; i <= 1; ++i){
11+
u.contents = 300;
12+
console.log("nonline");
13+
}
14+
15+
}
16+
17+
function string(s) {
18+
for(var i = 0; i <= 1; ++i){
19+
u.contents = 200;
20+
console.log("no");
21+
}
22+
23+
}
24+
25+
var React = {
26+
string: string
27+
};
28+
29+
function fn(authState, route) {
30+
var exit = 0;
31+
var onboardingRoute;
32+
if (typeof authState === "number") {
33+
if (typeof route === "number") {
34+
if (route >= -730831382) {
35+
if (!(route !== -384135774 && route !== -384133096)) {
36+
exit = 2;
37+
}
38+
39+
} else if (!(route !== -799423340 && route < -730831383)) {
40+
exit = 2;
41+
}
42+
43+
} else if (route[0] === 378129979) {
44+
onboardingRoute = route[1];
45+
exit = 1;
46+
}
47+
div(/* :: */[
48+
string("Redirect"),
49+
/* [] */0
50+
], undefined);
51+
return 3;
52+
}
53+
if (typeof route !== "number" && route[0] === 378129979) {
54+
onboardingRoute = route[1];
55+
exit = 1;
56+
}
57+
console.log(authState[1]);
58+
div(/* :: */[
59+
string("VerifyEmail"),
60+
/* [] */0
61+
], undefined);
62+
return 2;
63+
switch (exit) {
64+
case 1 :
65+
console.log(onboardingRoute);
66+
div(/* :: */[
67+
string("Onboarding"),
68+
/* [] */0
69+
], undefined);
70+
return 0;
71+
case 2 :
72+
div(/* :: */[
73+
string("LoggedOut"),
74+
/* [] */0
75+
], undefined);
76+
return 1;
77+
78+
}
79+
}
80+
81+
if (fn(/* Unauthenticated */-54822762, /* Invite */-730831383) !== 1) {
82+
throw [
83+
Caml_builtin_exceptions.assert_failure,
84+
/* tuple */[
85+
"gpr_4280_test.ml",
86+
40,
87+
3
88+
]
89+
];
90+
}
91+
92+
exports.u = u;
93+
exports.div = div;
94+
exports.React = React;
95+
exports.fn = fn;
96+
/* Not a pure module */

jscomp/test/gpr_4280_test.ml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
let u = ref 0
3+
let div ~children () =
4+
for i = 0 to 1 do
5+
u := 300;
6+
Js.log "nonline"
7+
done
8+
module React = struct
9+
let string (s : string) =
10+
for i = 0 to 1 do
11+
u := 200;
12+
Js.log "no"
13+
done
14+
end
15+
let fn authState route =
16+
match (authState, route) with
17+
| (`Unauthenticated,`Onboarding onboardingRoute)
18+
| (`Unverified _,`Onboarding onboardingRoute) ->
19+
Js.Console.log onboardingRoute;
20+
div
21+
~children:[React.string
22+
"Onboarding"] ();
23+
0
24+
| (`Unauthenticated,`SignIn)|(`Unauthenticated,`SignUp)
25+
|(`Unauthenticated,`Invite)|(`Unauthenticated,`PasswordReset) ->
26+
div
27+
~children:[React.string
28+
"LoggedOut"] ();1
29+
30+
| (`Unverified user,_) ->
31+
Js.Console.log user;
32+
div
33+
~children:[React.string
34+
"VerifyEmail"] ();
35+
2
36+
| (`Unauthenticated,_) ->
37+
div
38+
~children:[React.string
39+
"Redirect"] ();3
40+
;; assert (fn (`Unauthenticated) `Invite = 1 ) (* == 1*)

0 commit comments

Comments
 (0)