diff --git a/Test/JuvixUnit.juvix b/Test/JuvixUnit.juvix index 8b76351..98320ef 100644 --- a/Test/JuvixUnit.juvix +++ b/Test/JuvixUnit.juvix @@ -53,3 +53,34 @@ assertJust {A} (msg : String) : Maybe A -> Assertion := maybe (fail msg) (const assertNothing {A} (mkMsg : A -> String) : Maybe A -> Assertion := maybe pass (mkMsg >> fail); assertEqual {A} {{Eq A}} (msg : String) (a1 a2 : A) : Assertion := failUnless msg (a1 == a2); + +assertGreater {A} {{Ord A}} (msg : String) (a1 a2 : A) : Assertion := failUnless msg (a1 >= a2); + +assertGreaterEqual {A} {{Ord A}} (msg : String) (a1 a2 : A) : Assertion := + failUnless msg (a1 >= a2); + +assertLess {A} {{Ord A}} (msg : String) (a1 a2 : A) : Assertion := failUnless msg (a1 < a2); + +assertLessEqual {A} {{Ord A}} (msg : String) (a1 a2 : A) : Assertion := failUnless msg (a1 <= a2); + +mkExpectMsg {A} {{Show A}} (expected actual : A) (msg : String) : String := + "\nExpected " ++str Show.show expected ++str "\nto be " ++str msg ++str Show.show actual; + +expectTrue (actual : Bool) : Assertion := assertTrue (mkExpectMsg true actual "") actual; + +expectFalse (actual : Bool) : Assertion := assertFalse (mkExpectMsg false actual "") actual; + +expectEqual {A} {{Eq A}} {{Show A}} (expected actual : A) : Assertion := + assertEqual (mkExpectMsg expected actual "equal to ") expected actual; + +expectGreater {A} {{Ord A}} {{Show A}} (expected actual : A) : Assertion := + assertGreater (mkExpectMsg expected actual "greater than ") expected actual; + +expectGreaterEqual {A} {{Ord A}} {{Show A}} (expected actual : A) : Assertion := + assertGreaterEqual (mkExpectMsg expected actual "greater than or equal to ") expected actual; + +expectLess {A} {{Ord A}} {{Show A}} (expected actual : A) : Assertion := + assertLess (mkExpectMsg expected actual "less than ") expected actual; + +expectLessEqual {A} {{Ord A}} {{Show A}} (expected actual : A) : Assertion := + assertLessEqual (mkExpectMsg expected actual "less than or equal to ") expected actual;