From 317abf0d8ea2ceae3773a8cda84dfcb13753f17a Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Thu, 21 Nov 2024 18:18:09 +0100 Subject: [PATCH] add positive test --- test/Compilation/Positive.hs | 7 +++++- tests/Compilation/positive/test085.juvix | 32 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Compilation/positive/test085.juvix diff --git a/test/Compilation/Positive.hs b/test/Compilation/Positive.hs index 178b43554a..b7afcd21c1 100644 --- a/test/Compilation/Positive.hs +++ b/test/Compilation/Positive.hs @@ -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") ] diff --git a/tests/Compilation/positive/test085.juvix b/tests/Compilation/positive/test085.juvix new file mode 100644 index 0000000000..5aa34d8ab1 --- /dev/null +++ b/tests/Compilation/positive/test085.juvix @@ -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)));