1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-26 16:28:06 +11:00
collapseos/tests/unit/test_basic_parse.asm
2019-12-31 13:07:05 -05:00

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: