-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt to standard library traits (#1)
* adapt to numeric traits * Use Package.juvix * Run formatter * Use release ref for juvix-stdlib * Format project * Test should call Debug.failWith only at the end of a failing suite * Use == instead of Eq.eq * Add a test suite * Run tests on CI * Print output on failure * Add line buffering * Remove Example.juvix * Expand Example.juvix * Run the Example as part of the test suite * Add examples to the README --------- Co-authored-by: Jonathan Cubides <[email protected]> Co-authored-by: Paul Cadman <[email protected]>
- Loading branch information
1 parent
a7ac74c
commit 3ed8a39
Showing
14 changed files
with
173 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test Test | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download latest nightly Juvix binary | ||
uses: jaxxstorm/[email protected] | ||
with: | ||
repo: anoma/juvix-nightly-builds | ||
cache: enable | ||
|
||
- name: Run tests | ||
run: | | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Package; | ||
|
||
import PackageDescription.V1 open; | ||
|
||
package : Package := | ||
defaultPackage | ||
{name := "test"; | ||
version := mkVersion 0 7 0; | ||
dependencies := [github "anoma" "juvix-stdlib" "v0.0.1"]}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file was autogenerated by Juvix version 0.5.4. | ||
# Do not edit this file manually. | ||
|
||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: f68b0614ad695eaa13ead42f3466e0a78219f826 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.juvix-build | ||
.history | ||
deps/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Package; | ||
|
||
import PackageDescription.V1 open; | ||
|
||
package : Package := | ||
defaultPackage | ||
{name := "tests"; | ||
dependencies := [defaultStdlib; path "../"]}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module TestFail; | ||
|
||
import Stdlib.Prelude open; | ||
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) | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module TestPass; | ||
|
||
import Stdlib.Prelude open; | ||
import Test.JuvixUnit open; | ||
|
||
main : IO := | ||
runTestSuite | ||
(testSuite | ||
(name := "TestPass"; | ||
tests := [testCase "1 == 1" (assertEqual "1 /= 1" 1 1)])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -lt 3 ]; then | ||
echo "Usage: $0 <command> <expect_success> <regex_list>" | ||
exit 1 | ||
fi | ||
|
||
# The command under test | ||
COMMAND="$1" | ||
|
||
# Whether a success (0 exit code) is expected | ||
EXPECT_SUCCESS="$2" | ||
|
||
# Regular expressions passed as a single string, split by a delimiter (e.g., comma) | ||
IFS=',' read -r -a regex_list <<< "$3" | ||
|
||
# Execute the command and store both stdout and stderr in the output | ||
output=$(stdbuf -oL $COMMAND 2>&1) | ||
exit_code=$? | ||
|
||
# Check the exit code | ||
if [[ "$EXPECT_SUCCESS" == "expect_success" && $exit_code -ne 0 ]]; then | ||
echo "Expected $COMMAND to succeed but it failed with exit code $exit_code." | ||
exit 1 | ||
elif [[ ! "$EXPECT_SUCCESS" == "expect_success" && $exit_code -eq 0 ]]; then | ||
echo "Expected $COMMAND to fail but it succeeded." | ||
exit 1 | ||
fi | ||
|
||
|
||
failed=0 | ||
|
||
for regex in "${regex_list[@]}"; do | ||
if [[ ! $output =~ $regex ]]; then | ||
echo "$COMMAND: No match found for regex: $regex" | ||
echo "output:" | ||
echo "$output" | ||
failed=1 | ||
fi | ||
done | ||
|
||
if [ $failed -eq 1 ]; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This file was autogenerated by Juvix version 0.5.4. | ||
# Do not edit this file manually. | ||
|
||
dependencies: | ||
- path: .juvix-build/stdlib/ | ||
dependencies: [] | ||
- path: ../ | ||
dependencies: | ||
- git: | ||
name: anoma_juvix-stdlib | ||
ref: f68b0614ad695eaa13ead42f3466e0a78219f826 | ||
url: https://github.com/anoma/juvix-stdlib | ||
dependencies: [] |