Debian Codegraph @

test/instrument/pattern/unary.t

raw
1 Alias.
2
3 $ bash ../test.sh <<'EOF'
4 > let _ =
5 > match `A with
6 > | `A | `B as _x -> print_endline "foo"
7 > EOF
8 let _ =
9 match `A with
10 | (`A | `B) as _x as ___bisect_matched_value___ ->
11 (match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
12 ___bisect_matched_value___
13 with
14 | `A as _x ->
15 ___bisect_visit___ 1;
16 ()
17 | `B as _x ->
18 ___bisect_visit___ 2;
19 ()
20 | _ -> ());
21 ___bisect_post_visit___ 0 (print_endline "foo")
22
23
24 Constructor.
25
26 $ bash ../test.sh <<'EOF'
27 > let _ =
28 > match Some `A with
29 > | Some (`A | `B) -> print_endline "foo"
30 > | None -> ()
31 > EOF
32 let _ =
33 match Some `A with
34 | Some (`A | `B) as ___bisect_matched_value___ ->
35 (match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
36 ___bisect_matched_value___
37 with
38 | Some `A ->
39 ___bisect_visit___ 1;
40 ()
41 | Some `B ->
42 ___bisect_visit___ 2;
43 ()
44 | _ -> ());
45 ___bisect_post_visit___ 0 (print_endline "foo")
46 | None ->
47 ___bisect_visit___ 3;
48 ()
49
50
51 Polymorphic variant constructor.
52
53 $ bash ../test.sh <<'EOF'
54 > let _ =
55 > match `A `B with
56 > | `A (`B | `C) -> print_endline "foo"
57 > EOF
58 let _ =
59 match `A `B with
60 | `A (`B | `C) as ___bisect_matched_value___ ->
61 (match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
62 ___bisect_matched_value___
63 with
64 | `A `B ->
65 ___bisect_visit___ 1;
66 ()
67 | `A `C ->
68 ___bisect_visit___ 2;
69 ()
70 | _ -> ());
71 ___bisect_post_visit___ 0 (print_endline "foo")
72
73
74 Type constraint.
75
76 $ bash ../test.sh <<'EOF'
77 > let _ =
78 > match `A with
79 > | (`A | `B : _) -> print_endline "foo"
80 > EOF
81 let _ =
82 match `A with
83 | (`A | `B : _) as ___bisect_matched_value___ ->
84 (match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
85 ___bisect_matched_value___
86 with
87 | (`A : _) ->
88 ___bisect_visit___ 1;
89 ()
90 | (`B : _) ->
91 ___bisect_visit___ 2;
92 ()
93 | _ -> ());
94 ___bisect_post_visit___ 0 (print_endline "foo")
95
96
97 Lazy.
98
99 $ bash ../test.sh <<'EOF'
100 > let _ =
101 > match lazy `A with
102 > | lazy (`A | `B) -> print_endline "foo"
103 > EOF
104 let _ =
105 match
106 lazy
107 (___bisect_visit___ 3;
108 `A)
109 with
110 | (lazy (`A | `B)) as ___bisect_matched_value___ ->
111 (match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
112 ___bisect_matched_value___
113 with
114 | (lazy `A) ->
115 ___bisect_visit___ 1;
116 ()
117 | (lazy `B) ->
118 ___bisect_visit___ 2;
119 ()
120 | _ -> ());
121 ___bisect_post_visit___ 0 (print_endline "foo")