Skip to content

Commit

Permalink
Update to new stdlib (#7)
Browse files Browse the repository at this point in the history
* Update to new stdlib

* Update for juvix 0.6.3
  • Loading branch information
paulcadman authored Jul 2, 2024
1 parent 4e54de4 commit 4254b60
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Example.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Example;
import Stdlib.Prelude open;
import Test.JuvixUnit open;

headMay {A} : List A -> Maybe A := head nothing ∘ map just;
headMay {A} : List A -> Maybe A := map just >> head nothing;

tests : List Test :=
[ testCase "1 == 1" (assertEqual "1 /= 1" 1 1)
Expand Down
8 changes: 6 additions & 2 deletions Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ import PackageDescription.V2 open;
package : Package :=
defaultPackage
{name := "test";
version := mkVersion 0 10 0;
dependencies := [github "anoma" "juvix-stdlib" "v0.3.0"]};
version := mkVersion 0 11 0;
dependencies := [ github
"anoma"
"juvix-stdlib"
"v0.4.0"
]};
16 changes: 8 additions & 8 deletions Test/JuvixUnit.juvix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Test.JuvixUnit;

import Test.Prelude open;
import Stdlib.Prelude open hiding {fail};
import Stdlib.Debug.Fail as Fail;

type Assertion :=
Expand All @@ -24,7 +24,7 @@ type TestSuite :=
};

anyFail (suite : TestSuite) : Bool :=
any (isFail ∘ Test.assertion) (TestSuite.tests suite);
any (Test.assertion >> isFail) (TestSuite.tests suite);

runTests : List Test -> IO :=
let
Expand All @@ -36,23 +36,23 @@ runTests : List Test -> IO :=
(Test.name t
++str "\t\t"
++str showAssertion (Test.assertion t));
in foldr λ {t acc := runTest t >> acc} (printString "");
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
>>> runTests (TestSuite.tests suite)
>>> printStringLn
("All tests from test suite '"
++str TestSuite.name suite
++str "' complete")
>> if
>>> ite
(anyFail suite)
(Fail.failwith "Suite failed")
(printStringLn "Suite passed");

failWhen (msg : String) (b : Bool) : Assertion :=
if b (fail msg) pass;
ite b (fail msg) pass;

failUnless (msg : String) (b : Bool) : Assertion :=
failWhen msg (not b);
Expand All @@ -65,7 +65,7 @@ assertJust {A} (msg : String) : Maybe A -> Assertion :=
maybe (fail msg) (const pass);

assertNothing {A} (mkMsg : A -> String)
: Maybe A -> Assertion := maybe pass (fail ∘ mkMsg);
: Maybe A -> Assertion := maybe pass (mkMsg >> fail);

assertEqual {A} {{Eq A}} (msg : String) (a1 a2 : A)
: Assertion := failUnless msg (a1 == a2);
10 changes: 0 additions & 10 deletions Test/Prelude.juvix

This file was deleted.

6 changes: 3 additions & 3 deletions juvix.lock.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This file was autogenerated by Juvix version 0.6.2.
# This file was autogenerated by Juvix version 0.6.3.
# Do not edit this file manually.

version: 2
checksum: 02d9520e22444b4ad60a0f000f5c4f0a8d220592393b944a8e19bb3dd6712712
checksum: 792ac5870f4193fd7a2ce6336e1cc664e91872f3984be33ee8f5981de39df018
dependencies:
- git:
name: anoma_juvix-stdlib
ref: 73ecbc57738f4bde6f4f39636436ba38504b33f6
ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b
url: https://github.com/anoma/juvix-stdlib
dependencies: []
5 changes: 4 additions & 1 deletion tests/Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ package : Package :=
defaultPackage
{name := "tests";
dependencies := [ path "../"
; github "anoma" "juvix-stdlib" "v0.2.0"
; github
"anoma"
"juvix-stdlib"
"v0.4.0"
]};
8 changes: 4 additions & 4 deletions tests/juvix.lock.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This file was autogenerated by Juvix version 0.6.0.
# This file was autogenerated by Juvix version 0.6.3.
# Do not edit this file manually.

version: 2
checksum: 6f4532909e9c488a5c3d0686e7d24327857725fdbb8cd61e29c84cdb4ee66c8a
checksum: 217a59a792323e680e3389cb3ab31f3534004fbbc7f695d3d81f66be6d7e7c41
dependencies:
- path: ../
dependencies:
- git:
name: anoma_juvix-stdlib
ref: e2efe4e6fe8e8bf1766050a7fa7ad8ff4e8c69fc
ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b
url: https://github.com/anoma/juvix-stdlib
dependencies: []
- git:
name: anoma_juvix-stdlib
ref: e2efe4e6fe8e8bf1766050a7fa7ad8ff4e8c69fc
ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b
url: https://github.com/anoma/juvix-stdlib
dependencies: []

0 comments on commit 4254b60

Please sign in to comment.