enable tests on scheme, fix error handling on scheme
This commit is contained in:
3
Makefile
3
Makefile
@@ -34,6 +34,9 @@ newt2.ss: newt.so
|
|||||||
test: newt.js
|
test: newt.js
|
||||||
scripts/test
|
scripts/test
|
||||||
|
|
||||||
|
cheztest: newt.so
|
||||||
|
make test NEWT='chez --program newt.so' RUNOUT="chez --script" OUTFILE=tmp/out.ss
|
||||||
|
|
||||||
aoctest: newt.js
|
aoctest: newt.js
|
||||||
scripts/aoc
|
scripts/aoc
|
||||||
scripts/aoc25
|
scripts/aoc25
|
||||||
|
|||||||
13
prim.ss
13
prim.ss
@@ -1,6 +1,3 @@
|
|||||||
;; REVIEW all of this - some of it is IO and needs the IO dance
|
|
||||||
;; maybe we make a helper? A macro?
|
|
||||||
|
|
||||||
; (define $IORes (lambda (nm-1 nm-2) (vector 0 #f nm-1 nm-2)))
|
; (define $IORes (lambda (nm-1 nm-2) (vector 0 #f nm-1 nm-2)))
|
||||||
(define $IORes (lambda (nm-1 nm-2) (cons nm-1 nm-2)))
|
(define $IORes (lambda (nm-1 nm-2) (cons nm-1 nm-2)))
|
||||||
(define ($Left x) (vector 0 #f #f x))
|
(define ($Left x) (vector 0 #f #f x))
|
||||||
@@ -17,7 +14,6 @@
|
|||||||
(define (Prelude.ltString a b) (string<? a b))
|
(define (Prelude.ltString a b) (string<? a b))
|
||||||
(define (Prelude.eqString a b) (string=? a b))
|
(define (Prelude.eqString a b) (string=? a b))
|
||||||
(define Prelude.showInt number->string)
|
(define Prelude.showInt number->string)
|
||||||
(define (Node.exitFailure _ msg) (raise msg))
|
|
||||||
(define (Prelude.primPutStrLn msg)
|
(define (Prelude.primPutStrLn msg)
|
||||||
(lambda (w)
|
(lambda (w)
|
||||||
(display msg)
|
(display msg)
|
||||||
@@ -73,7 +69,12 @@
|
|||||||
(define (Prelude.subInt a b) (- a b))
|
(define (Prelude.subInt a b) (- a b))
|
||||||
(define (Prelude.jsEq _ a b) (= a b))
|
(define (Prelude.jsEq _ a b) (= a b))
|
||||||
(define (Prelude.divInt a b) (fx/ a b))
|
(define (Prelude.divInt a b) (fx/ a b))
|
||||||
(define (Prelude.fatalError _ msg) (raise msg))
|
;; In node this throws and the next one exits cleanly
|
||||||
|
(define (Prelude.fatalError _ msg) (raise (error #f msg)))
|
||||||
|
(define (Node.exitFailure _ msg)
|
||||||
|
(display msg)
|
||||||
|
(newline)
|
||||||
|
(exit 1))
|
||||||
(define (Prelude.isSuffixOf sfx s)
|
(define (Prelude.isSuffixOf sfx s)
|
||||||
(let ((n (string-length sfx))
|
(let ((n (string-length sfx))
|
||||||
(m (string-length s)))
|
(m (string-length s)))
|
||||||
@@ -81,3 +82,5 @@
|
|||||||
(string=? sfx (substring s (- m n) m))
|
(string=? sfx (substring s (- m n) m))
|
||||||
#f)))
|
#f)))
|
||||||
(define (Node.getArgs w) ($IORes (command-line) w))
|
(define (Node.getArgs w) ($IORes (command-line) w))
|
||||||
|
(define (Prelude.unsafePerformIO a f)
|
||||||
|
(car (f 'world)))
|
||||||
|
|||||||
13
scripts/test
13
scripts/test
@@ -1,7 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
SAMPLES=$(find playground/samples -name "*.newt")
|
SAMPLES=$(find playground/samples -name "*.newt")
|
||||||
# NCC="bun run newt.js"
|
# NEWT ="bun run newt.js"
|
||||||
NCC="node newt.js"
|
NEWT=${NEWT:="node newt.js"}
|
||||||
|
OUTFILE=${OUTFILE:="tmp/out.js"}
|
||||||
|
RUNOUT=${RUNOUT:="node"}
|
||||||
|
mkdir -p tmp
|
||||||
total=0
|
total=0
|
||||||
failed=0
|
failed=0
|
||||||
for fn in tests/*.newt ; do
|
for fn in tests/*.newt ; do
|
||||||
@@ -9,10 +12,10 @@ for fn in tests/*.newt ; do
|
|||||||
echo Test $fn
|
echo Test $fn
|
||||||
bn=$(basename $fn)
|
bn=$(basename $fn)
|
||||||
if [ -f ${fn}.golden ]; then
|
if [ -f ${fn}.golden ]; then
|
||||||
$NCC $fn -o out.js > tmp/${bn}.compile
|
$NEWT $fn -o $OUTFILE > tmp/${bn}.compile
|
||||||
else
|
else
|
||||||
# we've dropped support for compiling things without main for now.
|
# we've dropped support for compiling things without main for now.
|
||||||
$NCC $fn > tmp/${bn}.compile
|
$NEWT $fn > tmp/${bn}.compile
|
||||||
fi
|
fi
|
||||||
cerr=$?
|
cerr=$?
|
||||||
if [ -f ${fn}.fail ]; then
|
if [ -f ${fn}.fail ]; then
|
||||||
@@ -34,7 +37,7 @@ for fn in tests/*.newt ; do
|
|||||||
fi
|
fi
|
||||||
# if there is a golden file, run the code and compare output
|
# if there is a golden file, run the code and compare output
|
||||||
if [ -f ${fn}.golden ]; then
|
if [ -f ${fn}.golden ]; then
|
||||||
node out.js > tmp/${bn}.out
|
$RUNOUT $OUTFILE > tmp/${bn}.out
|
||||||
if [ $? != "0" ]; then
|
if [ $? != "0" ]; then
|
||||||
echo Run failed for $fn
|
echo Run failed for $fn
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user