diff --git a/Example.juvix b/Example.juvix index e938d67..8dd84be 100644 --- a/Example.juvix +++ b/Example.juvix @@ -8,17 +8,11 @@ headMay {A} : List A -> Maybe A := map just >> head nothing; tests : List Test := [ testCase "1 == 1" (assertEqual "1 /= 1" 1 1) ; testCase "[1] == [1]" (assertEqual "[1] /= [1]" [1] [1]) - ; testCase - "length [1] == 1" - (assertTrue "length [1] /= 1" (length [1] == 1)) + ; testCase "length [1] == 1" (assertTrue "length [1] /= 1" (length [1] == 1)) ; testCase "headMay [] is nothing" - (assertNothing - λ {xs := "expected nothing, got: " ++str Show.show xs} - (headMay {Nat} [])) - ; testCase - "headMay [1] is just" - (assertJust "expected just, got nothing" (headMay [1])) + (assertNothing λ {xs := "expected nothing, got: " ++str Show.show xs} (headMay {Nat} [])) + ; testCase "headMay [1] is just" (assertJust "expected just, got nothing" (headMay [1])) ]; main : IO := runTestSuite (testSuite "Example" tests); diff --git a/Package.juvix b/Package.juvix index 6f0070a..9a0a234 100644 --- a/Package.juvix +++ b/Package.juvix @@ -3,11 +3,8 @@ module Package; import PackageDescription.V2 open; package : Package := - defaultPackage - {name := "test"; - version := mkVersion 0 11 0; - dependencies := [ github - "anoma" - "juvix-stdlib" - "v0.4.0" - ]}; + defaultPackage@?{ + name := "test"; + version := mkVersion 0 12 0; + dependencies := [github "anoma" "juvix-stdlib" "v0.5.0"] + }; diff --git a/Test/JuvixUnit.juvix b/Test/JuvixUnit.juvix index 07b6988..8b76351 100644 --- a/Test/JuvixUnit.juvix +++ b/Test/JuvixUnit.juvix @@ -23,8 +23,7 @@ type TestSuite := 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 @@ -32,40 +31,25 @@ 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)); + 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 "'") + 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; +failWhen (msg : String) (b : Bool) : Assertion := ite b (fail msg) pass; -failUnless (msg : String) (b : Bool) : Assertion := - failWhen msg (not b); +failUnless (msg : String) (b : Bool) : Assertion := failWhen msg (not b); 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); diff --git a/juvix.lock.yaml b/juvix.lock.yaml index 3497647..5b32eb2 100644 --- a/juvix.lock.yaml +++ b/juvix.lock.yaml @@ -1,11 +1,11 @@ -# This file was autogenerated by Juvix version 0.6.3. +# This file was autogenerated by Juvix version 0.6.4. # Do not edit this file manually. version: 2 -checksum: 792ac5870f4193fd7a2ce6336e1cc664e91872f3984be33ee8f5981de39df018 +checksum: ccfae54b08216f345ed4d42cf26fa111a95ae51d1171c611b86352af409ee561 dependencies: - git: name: anoma_juvix-stdlib - ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b + ref: 16211500dc59a944f851fbaeeef703fdd09163fa url: https://github.com/anoma/juvix-stdlib dependencies: [] diff --git a/tests/Package.juvix b/tests/Package.juvix index e2ac54a..fbb1cfe 100644 --- a/tests/Package.juvix +++ b/tests/Package.juvix @@ -3,11 +3,7 @@ module Package; import PackageDescription.V2 open; package : Package := - defaultPackage - {name := "tests"; - dependencies := [ path "../" - ; github - "anoma" - "juvix-stdlib" - "v0.4.0" - ]}; + defaultPackage@?{ + name := "tests"; + dependencies := [path "../"; github "anoma" "juvix-stdlib" "v0.5.0"] + }; diff --git a/tests/TestFail.juvix b/tests/TestFail.juvix index b141c94..47ecabc 100644 --- a/tests/TestFail.juvix +++ b/tests/TestFail.juvix @@ -5,8 +5,8 @@ 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@?{ + name := "TestFail"; + tests := + [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 be5129a..abf2c6b 100644 --- a/tests/TestPass.juvix +++ b/tests/TestPass.juvix @@ -5,6 +5,7 @@ import Test.JuvixUnit open; main : IO := runTestSuite - (testSuite - (name := "TestPass"; - tests := [testCase "1 == 1" (assertEqual "1 /= 1" 1 1)])); + testSuite@?{ + name := "TestPass"; + tests := [testCase "1 == 1" (assertEqual "1 /= 1" 1 1)] + }; diff --git a/tests/juvix.lock.yaml b/tests/juvix.lock.yaml index 0d26dd3..73a63aa 100644 --- a/tests/juvix.lock.yaml +++ b/tests/juvix.lock.yaml @@ -1,18 +1,18 @@ -# This file was autogenerated by Juvix version 0.6.3. +# This file was autogenerated by Juvix version 0.6.4. # Do not edit this file manually. version: 2 -checksum: 217a59a792323e680e3389cb3ab31f3534004fbbc7f695d3d81f66be6d7e7c41 +checksum: c18d1a5878618cd758cd7a371c641facc945dc4c4d4ea7831135a01fa84bf6be dependencies: - path: ../ dependencies: - git: name: anoma_juvix-stdlib - ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b + ref: 16211500dc59a944f851fbaeeef703fdd09163fa url: https://github.com/anoma/juvix-stdlib dependencies: [] - git: name: anoma_juvix-stdlib - ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b + ref: 16211500dc59a944f851fbaeeef703fdd09163fa url: https://github.com/anoma/juvix-stdlib dependencies: []