mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:38:05 +11:00
Add unit test for zasm's parse unit
This commit is contained in:
parent
7083116379
commit
4075c90d44
@ -56,7 +56,7 @@
|
||||
; *** Code ***
|
||||
jp zasmMain
|
||||
|
||||
#include "util.asm"
|
||||
#include "util_z.asm"
|
||||
.equ IO_RAMSTART ZASM_RAMEND
|
||||
#include "io.asm"
|
||||
#include "tok.asm"
|
||||
|
@ -5,11 +5,12 @@ set -o pipefail
|
||||
|
||||
SCAS=scas
|
||||
PARTS=../../../parts/z80
|
||||
ZASMDIR=../../../apps/zasm
|
||||
RUNBIN=../../emul/runbin/runbin
|
||||
|
||||
for fn in *.asm; do
|
||||
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]}"
|
||||
exit 1
|
||||
fi
|
||||
|
55
tools/tests/unit/test_parse_z.asm
Normal file
55
tools/tests/unit/test_parse_z.asm
Normal 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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user