Skip to content

Commit 01d876a

Browse files
committed
add a few more good to have tests
1 parent 5fff229 commit 01d876a

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

jscomp/syntax/tests/parsing/grammar/pattern/expected/variantSpreads.res.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,27 @@ let lookupOpt =
5353
| Some (Four) -> Js.log {js|four|js}
5454
| Some (Five) -> Js.log {js|five|js}
5555
| None -> Js.log {js|None|js}))
56+
[@res.arity 1])
57+
module Foo =
58+
struct
59+
type nonrec zz =
60+
| First
61+
| Second
62+
type nonrec xx =
63+
| ... of zz
64+
| Third
65+
end
66+
let doWithZ =
67+
((Function$
68+
(fun (z : Foo.zz) ->
69+
match z with
70+
| First -> Js.log {js|First|js}
71+
| Second -> Js.log {js|Second|js}))
72+
[@res.arity 1])
73+
let lookup3 =
74+
((Function$
75+
(fun (d : Foo.xx) ->
76+
match d with
77+
| ((#Foo.zz)[@res.patVariantSpread ]) as z -> Js.log z
78+
| Third -> Js.log {js|Third|js}))
5679
[@res.arity 1])

jscomp/syntax/tests/parsing/grammar/pattern/variantSpreads.res

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,21 @@ let lookupOpt = (b: option<b>) =>
3939
| Some(Five) => Js.log("five")
4040
| None => Js.log("None")
4141
}
42+
43+
44+
module Foo = {
45+
type zz = First | Second
46+
type xx = | ...zz | Third
47+
}
48+
49+
let doWithZ = (z: Foo.zz) =>
50+
switch z {
51+
| First => Js.log("First")
52+
| Second => Js.log("Second")
53+
}
54+
55+
let lookup3 = (d: Foo.xx) =>
56+
switch d {
57+
| ...Foo.zz as z => Js.log(z)
58+
| Third => Js.log("Third")
59+
}

tests/tests/src/VariantPatternMatchingSpreads.js

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/tests/src/VariantPatternMatchingSpreads.res

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ let lookupOpt = (b: option<b>) =>
3939
| Some(Five) => Js.log("five")
4040
| None => Js.log("None")
4141
}
42+
43+
module Foo = {
44+
type zz = First | Second
45+
type xx = | ...zz | Third
46+
}
47+
48+
let doWithZ = (z: Foo.zz) =>
49+
switch z {
50+
| First => Js.log("First")
51+
| Second => Js.log("Second")
52+
}
53+
54+
let lookup3 = (d: Foo.xx) =>
55+
switch d {
56+
| ...Foo.zz as z => Js.log(z)
57+
| Third => Js.log("Third")
58+
}

0 commit comments

Comments
 (0)