diff --git a/Example.juvix b/Example.juvix index 910a663..36f5278 100644 --- a/Example.juvix +++ b/Example.juvix @@ -6,23 +6,24 @@ import Test.JuvixUnit open; headMay {A} : List A -> Maybe A := map just >> head nothing; tests : List Test := - [ testCase "1 == 1" (expectEqual 1 1) - ; testCase "2 > 1" (expectGreater 2 1) - ; testCase "2 >= 1" (expectGreaterEqual 2 1) - ; testCase "1 >= 1" (expectGreaterEqual 1 1) - ; testCase "1 < 2" (expectLess 1 2) - ; testCase "1 <= 2" (expectLessEqual 1 2) - ; testCase "1 <= 1" (expectLessEqual 1 1) - ; testCase "[1] == [1]" (expectEqual [1] [1]) - ; testCase "[2] > [1]" (expectGreater [2] [1]) - ; testCase "[2] >= [1]" (expectGreaterEqual [2] [1]) - ; testCase "[1] >= [1]" (expectGreaterEqual [1] [1]) - ; testCase "[1] < [2]" (expectLess [1] [2]) - ; testCase "[1] <= [2]" (expectLessEqual [1] [2]) - ; testCase "[1] <= [1]" (expectLessEqual [1] [1]) - ; testCase "length [1] == 1" (expectTrue (length [1] == 1)) - ; testCase "headMay [] is nothing" (expectNothing (headMay {Nat} [])) - ; testCase "headMay [1] is just 1" (expectJust 1 (headMay [1])) + [ + testCase "1 == 1" (expectEqual 1 1); + testCase "2 > 1" (expectGreater 2 1); + testCase "2 >= 1" (expectGreaterEqual 2 1); + testCase "1 >= 1" (expectGreaterEqual 1 1); + testCase "1 < 2" (expectLess 1 2); + testCase "1 <= 2" (expectLessEqual 1 2); + testCase "1 <= 1" (expectLessEqual 1 1); + testCase "[1] == [1]" (expectEqual [1] [1]); + testCase "[2] > [1]" (expectGreater [2] [1]); + testCase "[2] >= [1]" (expectGreaterEqual [2] [1]); + testCase "[1] >= [1]" (expectGreaterEqual [1] [1]); + testCase "[1] < [2]" (expectLess [1] [2]); + testCase "[1] <= [2]" (expectLessEqual [1] [2]); + testCase "[1] <= [1]" (expectLessEqual [1] [1]); + testCase "length [1] == 1" (expectTrue (length [1] == 1)); + testCase "headMay [] is nothing" (expectNothing (headMay {Nat} [])); + testCase "headMay [1] is just 1" (expectJust 1 (headMay [1])); ]; main : IO := runTestSuite (testSuite "Example" tests); diff --git a/Package.juvix b/Package.juvix index 1fd652d..eb9d455 100644 --- a/Package.juvix +++ b/Package.juvix @@ -3,8 +3,14 @@ module Package; import PackageDescription.V2 open; package : Package := - defaultPackage@?{ + defaultPackage@{ name := "test"; - version := mkVersion 0 16 0; - dependencies := [github "anoma" "juvix-stdlib" "v0.8.0"]; + version := mkVersion 0 17 0; + dependencies := + [ + github + "anoma" + "juvix-stdlib" + "ff6d964320d24e3e8010733afcd886a62a56dd70"; + ]; }; diff --git a/Test/JuvixUnit.juvix b/Test/JuvixUnit.juvix index d0c6970..acbcf81 100644 --- a/Test/JuvixUnit.juvix +++ b/Test/JuvixUnit.juvix @@ -12,18 +12,19 @@ isFail : Assertion -> Bool | (fail _) := true; type Test := - testCase { + testCase@{ name : String; - assertion : Assertion + assertion : Assertion; }; type TestSuite := - testSuite { + testSuite@{ name : String; - tests : List Test + tests : List Test; }; -anyFail (suite : TestSuite) : Bool := any (Test.assertion >> isFail) (TestSuite.tests suite); +anyFail (suite : TestSuite) : Bool := + any (Test.assertion >> isFail) (TestSuite.tests suite); runTests : List Test -> IO := let @@ -31,14 +32,21 @@ runTests : List Test -> IO := | pass := "OK" | (fail msg) := "FAIL: " ++str msg; runTest (t : Test) : IO := - printStringLn (Test.name t ++str "\t\t" ++str showAssertion (Test.assertion t)); - in foldr λ {t acc := runTest t >>> acc} (printString ""); + printStringLn + (Test.name t ++str "\t\t" ++str showAssertion (Test.assertion t)); + in foldr λ{t acc := runTest t >>> acc} (printString ""); runTestSuite (suite : TestSuite) : IO := printStringLn ("Test suite '" ++str TestSuite.name suite ++str "'") >>> runTests (TestSuite.tests suite) - >>> printStringLn ("All tests from test suite '" ++str TestSuite.name suite ++str "' complete") - >>> ite (anyFail suite) (Fail.failwith "Suite failed") (printStringLn "Suite passed"); + >>> printStringLn + ("All tests from test suite '" + ++str TestSuite.name suite + ++str "' complete") + >>> ite + (anyFail suite) + (Fail.failwith "Suite failed") + (printStringLn "Suite passed"); failWhen (msg : String) (b : Bool) : Assertion := ite b (fail msg) pass; @@ -48,27 +56,36 @@ assertTrue : String -> Bool -> Assertion := failUnless; assertFalse : String -> Bool -> Assertion := failWhen; -assertJust {A} (msg : String) : Maybe A -> Assertion := maybe (fail msg) (const pass); +assertJust {A} (msg : String) : Maybe A -> Assertion := + maybe (fail msg) (const pass); -assertNothing {A} (mkMsg : A -> String) : Maybe A -> Assertion := maybe pass (mkMsg >> fail); +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); +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); +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); +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); +assertLessEqual {A} {{Ord A}} (msg : String) (a1 a2 : A) : Assertion := + failUnless msg (a1 <= a2); -mkExpectMsg {A} {{Show A}} (actual : A) (msg : String) (expected : A) : String := +mkExpectMsg + {A} {{Show A}} (actual : A) (msg : String) (expected : A) : String := "Expected " ++str Show.show actual ++str msg ++str Show.show expected; -expectTrue (actual : Bool) : Assertion := assertTrue (mkExpectMsg actual " to be " true) actual; +expectTrue (actual : Bool) : Assertion := + assertTrue (mkExpectMsg actual " to be " true) actual; -expectFalse (actual : Bool) : Assertion := assertFalse (mkExpectMsg actual " to be " false) actual; +expectFalse (actual : Bool) : Assertion := + assertFalse (mkExpectMsg actual " to be " false) actual; expectEqual {A} {{Eq A}} {{Show A}} (expected actual : A) : Assertion := assertEqual (mkExpectMsg actual " == " expected) expected actual; @@ -86,7 +103,11 @@ expectLessEqual {A} {{Ord A}} {{Show A}} (expected actual : A) : Assertion := assertLessEqual (mkExpectMsg actual " <= " expected) expected actual; expectJust {A} {{Show A}} (expected : A) (actual : Maybe A) : Assertion := - assertJust (mkExpectMsg "nothing" " to be " ("just " ++str Show.show expected)) actual; + assertJust + (mkExpectMsg "nothing" " to be " ("just " ++str Show.show expected)) + actual; expectNothing {A} {{Show A}} (actual : Maybe A) : Assertion := - assertNothing λ {x := mkExpectMsg ("just " ++str Show.show x) " to be " "nothing"} actual; + assertNothing + λ{x := mkExpectMsg ("just " ++str Show.show x) " to be " "nothing"} + actual; diff --git a/juvix.lock.yaml b/juvix.lock.yaml index 7e806cb..e494156 100644 --- a/juvix.lock.yaml +++ b/juvix.lock.yaml @@ -1,11 +1,11 @@ -# This file was autogenerated by Juvix version 0.6.7. +# This file was autogenerated by Juvix version 0.6.8. # Do not edit this file manually. version: 2 -checksum: 23a0f87e39f0f9ccd59b37ed7bbcae0aaccb570430cefb42bc543699546dbac8 +checksum: ffa729ccad4b69b2b7673deabeeb8d738b8a71b6887fff53c4cb45f61d757d09 dependencies: - git: name: anoma_juvix-stdlib - ref: 0080b1183ab55e5180e69bfc3987e4cd6edbc230 + ref: ff6d964320d24e3e8010733afcd886a62a56dd70 url: https://github.com/anoma/juvix-stdlib dependencies: [] diff --git a/tests/Package.juvix b/tests/Package.juvix index 28e4540..a6e583e 100644 --- a/tests/Package.juvix +++ b/tests/Package.juvix @@ -3,7 +3,14 @@ module Package; import PackageDescription.V2 open; package : Package := - defaultPackage@?{ + defaultPackage@{ name := "tests"; - dependencies := [path "../"; github "anoma" "juvix-stdlib" "v0.6.0"] + dependencies := + [ + path "../"; + github + "anoma" + "juvix-stdlib" + "ff6d964320d24e3e8010733afcd886a62a56dd70"; + ]; }; diff --git a/tests/TestFail.juvix b/tests/TestFail.juvix index 47ecabc..37c26de 100644 --- a/tests/TestFail.juvix +++ b/tests/TestFail.juvix @@ -5,8 +5,9 @@ import Test.JuvixUnit open; main : IO := runTestSuite - testSuite@?{ - name := "TestFail"; - tests := - [testCase "2 == 1" (assertEqual "2 /= 1" 2 1); testCase "1 == 1" (assertEqual "1 /= 1" 1 1)] - }; + (testSuite + "TestFail" + [ + testCase "2 == 1" (assertEqual "2 /= 1" 2 1); + testCase "1 == 1" (assertEqual "1 /= 1" 1 1); + ]); diff --git a/tests/TestPass.juvix b/tests/TestPass.juvix index abf2c6b..d98c481 100644 --- a/tests/TestPass.juvix +++ b/tests/TestPass.juvix @@ -5,7 +5,4 @@ import Test.JuvixUnit open; main : IO := runTestSuite - testSuite@?{ - name := "TestPass"; - tests := [testCase "1 == 1" (assertEqual "1 /= 1" 1 1)] - }; + (testSuite "TestPass" [testCase "1 == 1" (assertEqual "1 /= 1" 1 1)]); diff --git a/tests/juvix.lock.yaml b/tests/juvix.lock.yaml index d7666a1..8132aa2 100644 --- a/tests/juvix.lock.yaml +++ b/tests/juvix.lock.yaml @@ -1,18 +1,18 @@ -# This file was autogenerated by Juvix version 0.6.5. +# This file was autogenerated by Juvix version 0.6.8. # Do not edit this file manually. version: 2 -checksum: 90b72165433d68bfe79b7b6a61b2b06165f41afd61444e1aba5d8ed32cb56439 +checksum: 307e5ef4b3124c659fdc9906f641cf6360ccde31cab68b934bf4a65b0ba83b9d dependencies: - path: ../ dependencies: - git: name: anoma_juvix-stdlib - ref: 17a82dd466010b51924677b16a3f09a6c4c86a80 + ref: ff6d964320d24e3e8010733afcd886a62a56dd70 url: https://github.com/anoma/juvix-stdlib dependencies: [] - git: name: anoma_juvix-stdlib - ref: 17a82dd466010b51924677b16a3f09a6c4c86a80 + ref: ff6d964320d24e3e8010733afcd886a62a56dd70 url: https://github.com/anoma/juvix-stdlib dependencies: []