a034f63e23
This should make tests a bit more convenient to write and debug. Moreover, begin de de-IX-ization of parseExpr. I have, in a local WIP, a parseExpr implemented using a recursive descent algo, it passes all tests, but it unfortunately assembles a faulty zasm. I have to find the expressions that it doesn't parse properly. But before I do that, I prefer to commit these significant improvements I've been making to tests harness in parallel of this development.
96 lines
1.2 KiB
NASM
96 lines
1.2 KiB
NASM
jp test
|
|
|
|
.inc "ascii.h"
|
|
.inc "core.asm"
|
|
.inc "str.asm"
|
|
.inc "lib/util.asm"
|
|
.inc "lib/ari.asm"
|
|
.inc "lib/parse.asm"
|
|
.equ EXPR_PARSE parseLiteral
|
|
.inc "lib/expr.asm"
|
|
.inc "basic/parse.asm"
|
|
.inc "lib/fmt.asm"
|
|
.inc "stdio.asm"
|
|
.inc "common.asm"
|
|
|
|
test:
|
|
ld sp, 0xffff
|
|
|
|
call testParseThruth
|
|
|
|
; success
|
|
xor a
|
|
halt
|
|
|
|
testParseThruth:
|
|
ld hl, .t1
|
|
call .true
|
|
ld hl, .t2
|
|
call .true
|
|
ld hl, .t3
|
|
call .true
|
|
ld hl, .t4
|
|
call .true
|
|
ld hl, .t5
|
|
call .true
|
|
ld hl, .t6
|
|
call .true
|
|
ld hl, .t7
|
|
call .true
|
|
ld hl, .t8
|
|
call .true
|
|
|
|
ld hl, .f1
|
|
call .false
|
|
ld hl, .f2
|
|
call .false
|
|
ld hl, .f3
|
|
call .false
|
|
ld hl, .f4
|
|
call .false
|
|
ld hl, .f5
|
|
call .false
|
|
ld hl, .f6
|
|
call .false
|
|
|
|
ld hl, .e1
|
|
call .error
|
|
ret
|
|
|
|
.true:
|
|
call parseTruth
|
|
call assertZ
|
|
or a
|
|
call assertNZ
|
|
jp nexttest
|
|
|
|
.false:
|
|
call parseTruth
|
|
call assertZ
|
|
or a
|
|
call assertZ
|
|
jp nexttest
|
|
|
|
.error:
|
|
call parseTruth
|
|
call assertNZ
|
|
jp nexttest
|
|
|
|
.t1: .db "42", 0
|
|
.t2: .db "42+4=50-4", 0
|
|
.t3: .db "1<2", 0
|
|
.t4: .db "2>1", 0
|
|
.t5: .db "2>=1", 0
|
|
.t6: .db "2>=2", 0
|
|
.t7: .db "1<=2", 0
|
|
.t8: .db "2<=2", 0
|
|
.f1: .db "42-42", 0
|
|
.f2: .db "42+4=33+2", 0
|
|
.f3: .db "2<2", 0
|
|
.f4: .db "1>2", 0
|
|
.f5: .db "1>=2", 0
|
|
.f6: .db "2<=1", 0
|
|
.e1: .db "foo", 0
|
|
|
|
STDIO_RAMSTART:
|