Add unit test for zasm's parse unit

This commit is contained in:
Virgil Dupras 2019-05-17 10:00:30 -04:00
parent 7083116379
commit 4075c90d44
4 changed files with 58 additions and 2 deletions

View File

@ -56,7 +56,7 @@
; *** Code *** ; *** Code ***
jp zasmMain jp zasmMain
#include "util.asm" #include "util_z.asm"
.equ IO_RAMSTART ZASM_RAMEND .equ IO_RAMSTART ZASM_RAMEND
#include "io.asm" #include "io.asm"
#include "tok.asm" #include "tok.asm"

View File

@ -5,11 +5,12 @@ set -o pipefail
SCAS=scas SCAS=scas
PARTS=../../../parts/z80 PARTS=../../../parts/z80
ZASMDIR=../../../apps/zasm
RUNBIN=../../emul/runbin/runbin RUNBIN=../../emul/runbin/runbin
for fn in *.asm; do for fn in *.asm; do
echo "Running test ${fn}" echo "Running test ${fn}"
if ! ${SCAS} -I ${PARTS} -o - ${fn} | ${RUNBIN}; then if ! ${SCAS} -I ${PARTS} -I ${ZASMDIR} -o - ${fn} | ${RUNBIN}; then
echo "failed with code ${PIPESTATUS[1]}" echo "failed with code ${PIPESTATUS[1]}"
exit 1 exit 1
fi fi

View File

@ -0,0 +1,55 @@
jp test
#include "core.asm"
#include "parse.asm"
#include "util_z.asm"
#include "parse_z.asm"
; mocks. aren't used in tests
zasmIsFirstPass:
symSelect:
symFind:
symGetVal:
jp fail
testNum: .db 1
s99: .db "99", 0
s0x99: .db "0x99", 0
sFoo: .db "Foo", 0
test:
ld hl, 0xffff
ld sp, hl
ld hl, s99
call parseLiteral
jp nz, fail
ld a, ixh
or a
jp nz, fail
ld a, ixl
cp 99
jp nz, fail
call nexttest
ld hl, sFoo
call parseLiteral
jp z, fail
call nexttest
; success
xor a
halt
nexttest:
ld a, (testNum)
inc a
ld (testNum), a
ret
fail:
ld a, (testNum)
halt