add golden test stuff
This commit is contained in:
parent
b7dc5ffdc4
commit
8823154973
24 changed files with 126 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -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
15
golden-tests/Tests.idr
Normal 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]
|
4
golden-tests/quox-golden-tests.ipkg
Normal file
4
golden-tests/quox-golden-tests.ipkg
Normal 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
10
golden-tests/run-tests.sh
Executable 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" "$@"
|
0
golden-tests/tests/empty/empty.quox
Normal file
0
golden-tests/tests/empty/empty.quox
Normal file
0
golden-tests/tests/empty/expected
Normal file
0
golden-tests/tests/empty/expected
Normal file
2
golden-tests/tests/empty/run
Normal file
2
golden-tests/tests/empty/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
scheme "$1" empty.quox
|
3
golden-tests/tests/file-not-found/expected
Normal file
3
golden-tests/tests/file-not-found/expected
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
no location:
|
||||||
|
couldn't load file nonexistent.quox
|
||||||
|
File Not Found
|
2
golden-tests/tests/file-not-found/run
Normal file
2
golden-tests/tests/file-not-found/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
check "$1" nonexistent.quox
|
12
golden-tests/tests/hello/expected
Normal file
12
golden-tests/tests/hello/expected
Normal 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 🐉
|
7
golden-tests/tests/hello/hello.quox
Normal file
7
golden-tests/tests/hello/hello.quox
Normal 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 🐉"
|
2
golden-tests/tests/hello/run
Normal file
2
golden-tests/tests/hello/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
compile_run "$1" hello.quox hello.ss
|
3
golden-tests/tests/ill-typed-main/expected
Normal file
3
golden-tests/tests/ill-typed-main/expected
Normal 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 ℕ
|
2
golden-tests/tests/ill-typed-main/ill-typed-main.quox
Normal file
2
golden-tests/tests/ill-typed-main/ill-typed-main.quox
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#[main]
|
||||||
|
def main : ℕ = 5
|
2
golden-tests/tests/ill-typed-main/run
Normal file
2
golden-tests/tests/ill-typed-main/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
check "$1" ill-typed-main.quox
|
4
golden-tests/tests/it-5/expected
Normal file
4
golden-tests/tests/it-5/expected
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
ω.five : ℕ
|
||||||
|
five = 5
|
||||||
|
(define five
|
||||||
|
5)
|
1
golden-tests/tests/it-5/five.quox
Normal file
1
golden-tests/tests/it-5/five.quox
Normal file
|
@ -0,0 +1 @@
|
||||||
|
def five : ℕ = 5
|
2
golden-tests/tests/it-5/run
Normal file
2
golden-tests/tests/it-5/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
scheme "$1" five.quox
|
18
golden-tests/tests/lib.sh
Normal file
18
golden-tests/tests/lib.sh
Normal 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"
|
||||||
|
}
|
16
golden-tests/tests/load/expected
Normal file
16
golden-tests/tests/load/expected
Normal 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 🐉
|
8
golden-tests/tests/load/lib.quox
Normal file
8
golden-tests/tests/load/lib.quox
Normal 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 🐉"
|
||||||
|
}
|
4
golden-tests/tests/load/main.quox
Normal file
4
golden-tests/tests/load/main.quox
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
load "lib.quox"
|
||||||
|
|
||||||
|
#[main]
|
||||||
|
def main = lib.main
|
2
golden-tests/tests/load/run
Normal file
2
golden-tests/tests/load/run
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
. ../lib.sh
|
||||||
|
compile_run "$1" main.quox load.ss
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in a new issue