Skip to content

Commit

Permalink
add positive test
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Nov 21, 2024
1 parent e274add commit 317abf0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/Compilation/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -495,5 +495,10 @@ tests =
"Test084: issue3030"
$(mkRelDir ".")
$(mkRelFile "test084.juvix")
$(mkRelFile "out/test084.out")
$(mkRelFile "out/test084.out"),
posTest
"Test085: Deriving Eq"
$(mkRelDir ".")
$(mkRelFile "test085.juvix")
$(mkRelFile "out/test085.out")
]
32 changes: 32 additions & 0 deletions tests/Compilation/positive/test085.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Deriving Eq
module test085;

import Stdlib.Data.Fixity open;
import Stdlib.Data.Bool open;
import Stdlib.System.IO open;

builtin eq
trait
type Eq A := mkEq@{builtin isEqual isEqual : A -> A -> Bool};

open Eq;

syntax operator == comparison;

== {A} {{Eq A}} : A -> A -> Bool := Eq.isEqual;

syntax operator , pair;

deriving instance
eqBoolI : Eq Bool;

type Pair (A B : Type) := , : A → B → Pair A B;

deriving instance
eqPairI {A} {B} {{Eq A}} {{Eq B}} : Eq (Pair A B);

main : IO :=
printLn (isEqual true true)
>>> printLn (not (isEqual false true))
>>> printLn (isEqual (false, true) (false, true))
>>> printLn (not (isEqual (false, true) (false, false)));

0 comments on commit 317abf0

Please sign in to comment.