diff options
author | Marvin Borner | 2024-03-30 16:54:14 +0100 |
---|---|---|
committer | Marvin Borner | 2024-03-30 16:54:14 +0100 |
commit | 2e0a67b6219052b57a9ca5db666038c31ea0cec9 (patch) | |
tree | 7353297ad0ec436e3d7c8f6566416c8a150f0897 | |
parent | da026dcd2f4a2c35dc59afe6dce33c5aaa6df84f (diff) |
Adds tests for samples
-rw-r--r-- | .github/workflows/ci.yml | 10 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | samples/rosetta/ackermann_function.bruijn (renamed from samples/rosetta/ackermann-function.bruijn) | 0 | ||||
-rw-r--r-- | samples/rosetta/binary_search.bruijn | 2 | ||||
-rw-r--r-- | samples/rosetta/halt_and_catch_fire.bruijn | 4 | ||||
-rw-r--r-- | samples/rosetta/prime_decomposition.bruijn | 11 | ||||
-rw-r--r-- | samples/rosetta/test_a_function.bruijn | 2 | ||||
-rwxr-xr-x | samples/test_all.sh | 25 |
8 files changed, 50 insertions, 5 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f48cd1c..6e0d76f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,15 @@ jobs: run: sudo apt-get install hyperfine - name: Install bruijn run: stack install + - name: Run HigherOrder sample tests + run: cd samples/ && ./test_all.sh HigherOrder - name: Run HigherOrder tests and measure time run: cd std/ && ./test_all.sh HigherOrder + - name: Run RKNL sample tests + run: cd samples/ && ./test_all.sh RKNL - name: Run RKNL tests and measure time run: cd std/ && ./test_all.sh RKNL - - name: Run ION tests and measure time - run: cd std/ && ./test_all.sh ION + # - name: Run ION sample tests + # run: cd samples/ && ./test_all.sh ION + # - name: Run ION tests and measure time + # run: cd std/ && ./test_all.sh ION @@ -1,3 +1,4 @@ .stack-work/ *~ std/All.bruijn +samples/All.bruijn diff --git a/samples/rosetta/ackermann-function.bruijn b/samples/rosetta/ackermann_function.bruijn index c0689f1..c0689f1 100644 --- a/samples/rosetta/ackermann-function.bruijn +++ b/samples/rosetta/ackermann_function.bruijn diff --git a/samples/rosetta/binary_search.bruijn b/samples/rosetta/binary_search.bruijn index 87f01ba..d1cddc1 100644 --- a/samples/rosetta/binary_search.bruijn +++ b/samples/rosetta/binary_search.bruijn @@ -1,6 +1,6 @@ :import std/Combinator . -:import std/Math . :import std/List . +:import std/Math . :import std/Option . binary-search [y [[[[[2 <? 3 none go]]]]] (+0) --(∀0) 0] diff --git a/samples/rosetta/halt_and_catch_fire.bruijn b/samples/rosetta/halt_and_catch_fire.bruijn index e053451..163ec11 100644 --- a/samples/rosetta/halt_and_catch_fire.bruijn +++ b/samples/rosetta/halt_and_catch_fire.bruijn @@ -1,3 +1,5 @@ -:test ([[0]]) ([[1]]) +# invalid test +# :test ([[0]]) ([[1]]) +# or infinite loop main [[0 0] [0 0]] diff --git a/samples/rosetta/prime_decomposition.bruijn b/samples/rosetta/prime_decomposition.bruijn new file mode 100644 index 0000000..0287889 --- /dev/null +++ b/samples/rosetta/prime_decomposition.bruijn @@ -0,0 +1,11 @@ +:import std/Combinator . +:import std/List . +:import std/Math . + +factors \divs primes + divs y [[&[[&[[3 ⋅ 3 >? 4 case-1 (=?0 case-2 case-3)]] (quot-rem 2 1)]]]] + case-1 4 >? (+1) {}4 empty + case-2 3 : (5 1 (3 : 2)) + case-3 5 4 2 + +main [factors <$> ({ (+42) → (+50) })] diff --git a/samples/rosetta/test_a_function.bruijn b/samples/rosetta/test_a_function.bruijn index dc76eeb..f4c05b2 100644 --- a/samples/rosetta/test_a_function.bruijn +++ b/samples/rosetta/test_a_function.bruijn @@ -3,4 +3,4 @@ main [<~>0 =? 0] :test (main "tacocat") ([[1]]) -:test (main "bruijn") ([[1]]) +:test (main "bruijn") ([[0]]) diff --git a/samples/test_all.sh b/samples/test_all.sh new file mode 100755 index 0000000..45b85ae --- /dev/null +++ b/samples/test_all.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 <reducer>" + exit 1 +fi + +echo "# useful for run the tests of all samples at once" >All.bruijn +echo >>All.bruijn + +FILES="$(find euler fun rosetta -type f -name "*.bruijn")" + +for f in $FILES; do + echo ":import ${f%*.bruijn} ." >>All.bruijn +done + +# for ci, just run `bruijn All.bruijn` +echo >>All.bruijn +echo "main [[0]]" >>All.bruijn + +if cat /dev/null | bruijn -v All.bruijn -r "$1" | tee /dev/fd/2 | grep -q "ERROR"; then + exit 1 +fi + +# hyperfine --warmup 5 --runs 20 "cat /dev/null | bruijn -r $1 All.bruijn" |