ソースを参照

Add unit test for zasm's parse unit

pull/10/head
Virgil Dupras 5年前
コミット
4075c90d44
4個のファイルの変更58行の追加2行の削除
  1. +1
    -1
      apps/zasm/main.asm
  2. +0
    -0
      apps/zasm/util_z.asm
  3. +2
    -1
      tools/tests/unit/runtests.sh
  4. +55
    -0
      tools/tests/unit/test_parse_z.asm

+ 1
- 1
apps/zasm/main.asm ファイルの表示

@@ -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"


apps/zasm/util.asm → apps/zasm/util_z.asm ファイルの表示


+ 2
- 1
tools/tests/unit/runtests.sh ファイルの表示

@@ -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
- 0
tools/tests/unit/test_parse_z.asm ファイルの表示

@@ -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



読み込み中…
キャンセル
保存