this repo has no description
1let triple f1 f2 f3 ppf (v1, v2, v3) =
2 Format.fprintf ppf "(%a,%a,%a)" f1 v1 f2 v2 f3 v3
3
4let fmt = Fmt.Dump.(list (triple string string (list string)))
5let print phr = Format.printf "%a" fmt phr
6
7let check phrase =
8 let output = snd (Js_top_worker.Impl.mangle_toplevel true phrase []) in
9 print_endline "input:";
10 Printf.printf "{|%s|}\n" phrase;
11 print_endline "output:";
12 Printf.printf "{|%s|}\n" output;
13 let output_mapped = String.map (fun c -> if c = ' ' then '.' else c) output in
14 print_endline "output mapped:";
15 Printf.printf "{|%s|}\n" output_mapped
16
17let%expect_test _ =
18 check "# foo;; junk\n bar\n# baz;;\n moo\n# unterminated;; foo\n";
19 [%expect
20 {xxx|
21 input:
22 {|# foo;; junk
23 bar
24 # baz;;
25 moo
26 # unterminated;; foo
27 |}
28 output:
29 {| foo;;
30
31 baz;;
32
33 unterminated;;
34 |}
35 output mapped:
36 {|..foo;;.....
37 .....
38 ..baz;;
39 .....
40 ..unterminated;;....
41 |}
42 |xxx}]
43
44let%expect_test _ =
45 check "# 1+2;;\n- 3 : int\n \n";
46 [%expect
47 {xxx|
48 input:
49 {|# 1+2;;
50 - 3 : int
51
52 |}
53 output:
54 {| 1+2;;
55
56
57 |}
58 output mapped:
59 {|..1+2;;
60 .........
61 ..
62 |}
63 |xxx}]
64
65let%expect_test _ =
66 check "# 1+2;;";
67 [%expect
68 {xxx|
69 input:
70 {|# 1+2;;|}
71 output:
72 {| 1+2;;|}
73 output mapped:
74 {|..1+2;;|}
75 |xxx}]
76
77let%expect_test _ =
78 check "# 1+2;;\nx\n";
79 [%expect
80 {xxx|
81 input:
82 {|# 1+2;;
83 x
84 |}
85 output:
86 {| 1+2;;
87
88 |}
89 output mapped:
90 {|..1+2;;
91 .
92 |}
93 |xxx}]
94
95let%expect_test _ =
96 check "# let ;;\n foo";
97 [%expect
98 " \n\
99 \ fallback parser\n\
100 \ Got phrase\n\
101 \ input:\n\
102 \ {|# let ;;\n\
103 \ foo|}\n\
104 \ output:\n\
105 \ {| let ;;\n\
106 \ |}\n\
107 \ output mapped:\n\
108 \ {|..let.;;\n\
109 \ .....|}\n\
110 \ "]
111
112let%expect_test _ =
113 check "# let x=1;;\n foo\n\n# let y=2;;\n bar\n\n";
114 [%expect
115 " \n\
116 \ input:\n\
117 \ {|# let x=1;;\n\
118 \ foo\n\n\
119 \ # let y=2;;\n\
120 \ bar\n\n\
121 \ |}\n\
122 \ output:\n\
123 \ {| let x=1;;\n\n\n\
124 \ let y=2;;\n\n\n\
125 \ |}\n\
126 \ output mapped:\n\
127 \ {|..let.x=1;;\n\
128 \ .....\n\n\
129 \ ..let.y=2;;\n\
130 \ .....\n\n\
131 \ |}\n\
132 \ "]