Skip to content

Commit

Permalink
fixed bug in auto derive Equals
Browse files Browse the repository at this point in the history
  • Loading branch information
stackoverflow committed May 22, 2022
1 parent 50ad275 commit 4bf5be7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/resources/test/test/autoDerive.novah
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module test.autoDerive

import novah.test

#[derive: {equalsPoint: "Equals"}]
type Point = Point Int Int

#[derive: {equalsEnum: "Equals"}]
type Enum = A | B | C

#[derive: {equalsComplex: "Equals"}]
type Complex a = Ctor1 Int a | Ctor2 String | Ctor3

autoDeriveTest : Unit
autoDeriveTest =
test "Auto derive Equals" \_ ->
let p1 = Point 0 0
let p2 = Point 0 0
let p3 = Point 0 1
p1 `shouldBe` p2
p1 `shouldNotBe` p3
let e1 = A
let e2 = A
let e3 = B
let e4 = C
e1 `shouldBe` e2
e1 `shouldNotBe` e3
e1 `shouldNotBe` e4
e3 `shouldNotBe` e4
let c1 = Ctor1 1 "a"
let c2 = Ctor1 1 "a"
let c3 = Ctor1 1 "b"
let c4 = Ctor2 "a" : Complex Int
let c5 = Ctor2 "a"
let c6 = Ctor3
c1 `shouldBe` c2
c1 `shouldNotBe` c3
c4 `shouldBe` c5
c1 `shouldNotBe` c6
c4 `shouldNotBe` c6

0 comments on commit 4bf5be7

Please sign in to comment.