Skip to content

Commit 13e31b7

Browse files
Fix #2915: Add test
1 parent fa97e08 commit 13e31b7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/Js/Main/CustomOperatorsTests.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ type CustomPow =
2020
{ Ok: bool }
2121
static member Pow(x: CustomPow, n: int) = { Ok = true }
2222

23+
[<Fable.Core.Erase>]
24+
type WrappedNum = Num of int with
25+
static member ( + ) (Num x, Num y) = 2 * (x + y) |> Num
26+
27+
let addWrapped1 (x: WrappedNum) y = x + y
28+
29+
let addWrapped2 (x: WrappedNum) y = x + Num y
30+
2331
let typeOperators = [
32+
testCase "Can resolve custom operators on erased types" <| fun () -> // See #2915
33+
addWrapped1 (Num 4) (Num 5) |> equal (Num 18)
34+
addWrapped2 (Num 4) 5 |> equal (Num 18)
35+
2436
testCase "Custom operators with types work" <| fun () ->
2537
let p1 = { x=5.; y=10. }
2638
let p2 = { x=2.; y=1. }

0 commit comments

Comments
 (0)