1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-01 19:20:56 +11:00
collapseos/tests/unit/test_basic_parse.asm

96 lines
1.2 KiB
NASM
Raw Normal View History

2019-11-22 08:06:14 +11:00
jp test
.inc "ascii.h"
2019-11-22 08:06:14 +11:00
.inc "core.asm"
.inc "str.asm"
.inc "lib/util.asm"
.inc "lib/ari.asm"
2019-11-22 08:06:14 +11:00
.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"
2019-11-22 08:06:14 +11:00
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
2019-11-22 08:06:14 +11:00
or a
call assertNZ
2019-11-22 08:06:14 +11:00
jp nexttest
.false:
call parseTruth
call assertZ
2019-11-22 08:06:14 +11:00
or a
call assertZ
2019-11-22 08:06:14 +11:00
jp nexttest
.error:
call parseTruth
call assertNZ
2019-11-22 08:06:14 +11:00
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: