Skip to content

Commit b922e7b

Browse files
committed
Add tests
1 parent 8f911d5 commit b922e7b

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

tests/tests/src/VariantCoercion.js

+27-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/tests/src/VariantCoercion.res

+30
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,33 @@ module CoerceFromPolyvariantToVariant = {
120120
let withUnboxedCatchAll: withUnboxedCatchAll = #One
121121
let withUnboxedCatchAllP = (withUnboxedCatchAll :> withUnboxedCatchAllP)
122122
}
123+
124+
module CoerceVariantBinaryOp = {
125+
type flag = | @as(0) A | @as(2) B
126+
127+
let x = 0->lor((B :> int))
128+
129+
let v = B
130+
let f1 = () =>
131+
switch v {
132+
| A => "a"
133+
| B => "b"
134+
}
135+
let f2 = () =>
136+
switch (v :> int) {
137+
| 2 => "b"
138+
| _ => "a"
139+
}
140+
141+
for x in 1 to (B :> int) {
142+
Js.log(x)
143+
}
144+
145+
type flagStr = | @as("one") One | @as("two") Two
146+
147+
let y = (One :> string)->String.length
148+
149+
type flagFloat = | @as(1.5) X | @as(2.0) Y
150+
151+
let z = (X :> float) +. (Y :> float) +. 1.5
152+
}

0 commit comments

Comments
 (0)