add golden test stuff

This commit is contained in:
rhiannon morris 2024-04-14 20:47:59 +02:00
parent b7dc5ffdc4
commit 8823154973
24 changed files with 126 additions and 0 deletions

2
.gitignore vendored
View file

@ -5,3 +5,5 @@ result
*~ *~
quox quox
quox-tests quox-tests
quox-golden-tests/tests/*/output
quox-golden-tests/tests/*/*.ss

15
golden-tests/Tests.idr Normal file
View file

@ -0,0 +1,15 @@
module Tests
import Test.Golden
import Language.Reflection
import System
import System.Path
%language ElabReflection
projDir = %runElab idrisDir ProjectDir
testDir = projDir </> "tests"
tests = testsInDir { poolName = "quox golden tests", dirName = testDir }
main = runner [!tests]

View file

@ -0,0 +1,4 @@
package quox-golden-tests
depends = quox, contrib, test
executable = quox-golden-tests
main = Tests

10
golden-tests/run-tests.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
set -e
quox="$PWD/../exe/build/exec/quox"
run_tests="$PWD/build/exec/quox-golden-tests"
test -f "$quox" || pack build quox
test -f "$run_tests" || pack build quox-golden-tests
"$run_tests" "$quox" "$@"

View file

View file

View file

@ -0,0 +1,2 @@
. ../lib.sh
scheme "$1" empty.quox

View file

@ -0,0 +1,3 @@
no location:
couldn't load file nonexistent.quox
File Not Found

View file

@ -0,0 +1,2 @@
. ../lib.sh
check "$1" nonexistent.quox

View file

@ -0,0 +1,12 @@
0.IO : 1.★ → ★
ω.print : 1.String → IO {ok}
ω.main : IO {ok}
IO = □
print = scheme:(lambda (str) (builtin-io (display str) (newline)))
#[main] main = print "hello 🐉"
;; IO erased
(define print
(lambda (str) (builtin-io (display str) (newline))))
(define main
(print "hello \x1f409;"))
hello 🐉

View file

@ -0,0 +1,7 @@
def0 IO : ★ → ★ = λ A ⇒ IOState → A × IOState
#[compile-scheme "(lambda (str) (builtin-io (display str) (newline)))"]
postulate print : String → IO {ok}
#[main]
def main = print "hello 🐉"

View file

@ -0,0 +1,2 @@
. ../lib.sh
compile_run "$1" hello.quox hello.ss

View file

@ -0,0 +1,3 @@
ill-typed-main.quox:1:11-1:12:
when checking a function declared as #[main] has type 1.IOState → {𝑎} × IOState
expected a function type, but got

View file

@ -0,0 +1,2 @@
#[main]
def main : = 5

View file

@ -0,0 +1,2 @@
. ../lib.sh
check "$1" ill-typed-main.quox

View file

@ -0,0 +1,4 @@
ω.five :
five = 5
(define five
5)

View file

@ -0,0 +1 @@
def five : = 5

View file

@ -0,0 +1,2 @@
. ../lib.sh
scheme "$1" five.quox

18
golden-tests/tests/lib.sh Normal file
View file

@ -0,0 +1,18 @@
FLAGS="--dump-check - --dump-erase - --dump-scheme - --color=none --width=100000"
check() {
$1 $FLAGS "$2" -P check 2>&1
}
erase() {
$1 $FLAGS "$2" -P erase 2>&1
}
scheme() {
$1 $FLAGS "$2" -P scheme 2>&1
}
compile_run() {
$1 $FLAGS "$2" -o "$3" 2>&1
chezscheme --program "$3"
}

View file

@ -0,0 +1,16 @@
0.lib.IO : 1.★ → ★
ω.lib.print : 1.String → lib.IO {ok}
ω.lib.main : lib.IO {ok}
ω.main : lib.IO {ok}
lib.IO = □
lib.print = scheme:(lambda (str) (builtin-io (display str) (newline)))
lib.main = lib.print "hello 🐉"
#[main] main = lib.main
;; lib.IO erased
(define lib.print
(lambda (str) (builtin-io (display str) (newline))))
(define lib.main
(lib.print "hello \x1f409;"))
(define main
lib.main)
hello 🐉

View file

@ -0,0 +1,8 @@
namespace lib {
def0 IO : ★ → ★ = λ A ⇒ IOState → A × IOState
#[compile-scheme "(lambda (str) (builtin-io (display str) (newline)))"]
postulate print : String → IO {ok}
def main = print "hello 🐉"
}

View file

@ -0,0 +1,4 @@
load "lib.quox"
#[main]
def main = lib.main

View file

@ -0,0 +1,2 @@
. ../lib.sh
compile_run "$1" main.quox load.ss

View file

@ -20,3 +20,8 @@ ipkg = "quox.ipkg"
type = "local" type = "local"
path = "./tests" path = "./tests"
ipkg = "quox-tests.ipkg" ipkg = "quox-tests.ipkg"
[custom.all.quox-golden-tests]
type = "local"
path = "./golden-tests"
ipkg = "quox-golden-tests.ipkg"