Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit a409ae4

Browse files
author
Iwan
committed
Add extra tests for parsing of conjunctive poly vars
1 parent ac23567 commit a409ae4

File tree

9 files changed

+67
-6
lines changed

9 files changed

+67
-6
lines changed

tests/oprint/oprint.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ module type Conjunctive = {
178178
};
179179

180180
// exotic idents in poly-vars
181-
type t20 = [#\"type"]
182-
type t21 = [#\"va r ia nt"]
183-
type t22 = [#\"Variant ⛰"]
181+
type t20 = [#"type"]
182+
type t21 = [#"va r ia nt"]
183+
type t22 = [#"Variant ⛰"]
184184
type \"let" = int
185-
type \"type" = [ #\"Point🗿"(\"let", float) ]
185+
type \"type" = [ #"Point🗿"(\"let", float) ]
186186

187187
type exoticUser = {
188188
\"let": string,

tests/parsing/grammar/pattern/__snapshots__/parse.spec.js.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,11 @@ let cmp selectedChoice value =
529529
| (lazy #a) -> true
530530
| exception #a -> true
531531
| _ -> false
532-
;;match polyVar with | \`ease-in -> () | \`ease-out⛰ -> () | _ -> ()"
532+
;;match polyVar with
533+
| \`ease-in -> ()
534+
| \`ease-out⛰ -> ()
535+
| \`ease+++ (\`1Blue, \`r+) -> ()
536+
| _ -> ()"
533537
`;
534538

535539
exports[`record.js 1`] = `

tests/parsing/grammar/pattern/polyvariants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,6 @@ let cmp = (selectedChoice, value) =>
102102
switch polyVar {
103103
| #"ease-in" => ()
104104
| #"ease-out⛰" => ()
105+
| #"ease+++"(#"1Blue", #"r+") => ()
105106
| _ => ()
106107
}

tests/parsing/grammar/typexpr/__snapshots__/parse.spec.js.snap

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,19 @@ exports[`poly.js 1`] = `
130130
Js.t = \\"./src/logger.mock.js\\""
131131
`;
132132

133-
exports[`polyVariant.res 1`] = `"type nonrec animation = [ \`ease-in | \`ease-out | \`never ease ✍️ ]"`;
133+
exports[`polyVariant.res 1`] = `
134+
"type nonrec animation = [ \`ease-in | \`ease-out | \`never ease ✍️ ]
135+
module type Conjunctive =
136+
sig
137+
type nonrec u1 = [ \`A | \`B ]
138+
type nonrec u2 = [ \`A | \`B | \`C ]
139+
val f : [< \`T of [< u2]&[< u2]&[< u1] ] -> unit
140+
val g : [< \`S of [< u2]&[< u2]&[< u1] ] -> unit
141+
val g :
142+
[< \`Exotic-S+ of [< \`Exotic-u2+ ]&[< \`Exotic-u2- ]&[< \`Exotic-u1+++ ] ]
143+
-> unit
144+
end"
145+
`;
134146

135147
exports[`tuple.js 1`] = `
136148
"type nonrec t = (string * int)

tests/parsing/grammar/typexpr/polyVariant.res

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@ type animation = [
33
| #"ease-out"
44
| #"never ease ✍️"
55
]
6+
7+
module type Conjunctive = {
8+
type u1 = [ | #A | #B]
9+
type u2 = [ | #A | #B | #C]
10+
11+
let f: [< | #T([< u2]) & ([< u2]) & ([< u1])] => unit
12+
let g: [< | #S&([< u2]) & ([< u2]) & ([< u1])] => unit
13+
let g: [< | #"Exotic-S+"&([< #"Exotic-u2+"]) & ([< #"Exotic-u2-"]) & ([< #"Exotic-u1+++"])] => unit
14+
};

tests/printer/expr/__snapshots__/render.spec.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,6 +3251,8 @@ let b = #\\"1a\\"
32513251
let c = #a2
32523252
let d = #abcd
32533253
3254+
#BigBlue(#\\"Shade-of-blue+++\\", #\\"Shade-of-blue---\\")
3255+
32543256
external openSync: (
32553257
path,
32563258
@bs.string

tests/printer/expr/polyvariant.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ let b = #"1a"
114114
let c = #a2
115115
let d = #abcd
116116

117+
#"BigBlue"(#"Shade-of-blue+++", #"Shade-of-blue---")
118+
117119
external openSync: (
118120
path,
119121
@bs.string [

tests/printer/typexpr/__snapshots__/render.spec.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,5 +647,21 @@ type x = [
647647
| #Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar
648648
| #Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz
649649
]
650+
651+
type animation = [#\\"ease-in\\" | #\\"ease-out\\" | #\\"never ease ✍️\\"]
652+
653+
module type Conjunctive = {
654+
type u1 = [#A | #B]
655+
type u2 = [#A | #B | #C]
656+
657+
let f: [< #T([< u2]) & ([< u2]) & ([< u1])] => unit
658+
let g: [< #S & ([< u2]) & ([< u2]) & ([< u1])] => unit
659+
let g: [<
660+
| #\\"Exotic-S+\\"
661+
& ([< #\\"Exotic-u2+\\"])
662+
& ([< #\\"Exotic-u2-\\"])
663+
& ([< #\\"Exotic-u1+++\\"])
664+
] => unit
665+
}
650666
"
651667
`;

tests/printer/typexpr/variant.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,18 @@ type x = [
6767
| #Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar
6868
| #Baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz
6969
]
70+
71+
type animation = [
72+
| #"ease-in"
73+
| #"ease-out"
74+
| #"never ease ✍️"
75+
]
76+
77+
module type Conjunctive = {
78+
type u1 = [ | #A | #B]
79+
type u2 = [ | #A | #B | #C]
80+
81+
let f: [< | #T([< u2]) & ([< u2]) & ([< u1])] => unit
82+
let g: [< | #S&([< u2]) & ([< u2]) & ([< u1])] => unit
83+
let g: [< | #"Exotic-S+"&([< #"Exotic-u2+"]) & ([< #"Exotic-u2-"]) & ([< #"Exotic-u1+++"])] => unit
84+
};

0 commit comments

Comments
 (0)