identify some tokens

This commit is contained in:
andromeda
2026-03-18 16:53:35 +01:00
parent de60e52c5a
commit d5c2dde221
2 changed files with 150 additions and 0 deletions

View File

@@ -34,6 +34,12 @@ run_tests:
call clear_test_arena
call test_evaluate_constant
call clear_test_arena
call test_identify_register
call clear_test_arena
call test_identify_operator
ret
.msg db "running test suite...", 0x0A, 0x00
@@ -405,6 +411,7 @@ test_evaluate_constant:
.case0c_solution dq "char"
.case1c db '"chars"'
.case1c_solution dq "chars"
; " wow my editor really doesn't like highlighting quotes correctly
.case0q db "0q31103755242102"
.case0q_solution dq 0q31103755242102
@@ -412,6 +419,84 @@ test_evaluate_constant:
.case0b db "0b0110011001101001011100100111001101110100001000000011011000110100"
.case0b_solution dq 0b0110011001101001011100100111001101110100001000000011011000110100
; ------------------------------------------------------------------------------
; test_identify_register
;
; description:
; tests identify_register described funtionality
; ------------------------------------------------------------------------------
test_identify_register:
mov rsi, .msg
call print.test
mov edi, "rcx"
call identify_register
cmp ax, 0x0002
jne .fail
mov edi, "RaNd"
call identify_register
cmp ax, UNRECOGNISED_TOKEN_ID
jne .fail
mov edi, ""
call identify_register
cmp ax, UNRECOGNISED_TOKEN_ID
jne .fail
.pass:
mov rsi, msg_pass
call print
ret
.fail:
mov rsi, msg_fail
call print
ret
.msg db "test_identify_register...", 0x00
; ------------------------------------------------------------------------------
; test_identify_operator
;
; description:
; tests identify_operator described funtionality
; ------------------------------------------------------------------------------
test_identify_operator:
mov rsi, .msg
call print.test
mov edi, "xor"
call identify_operator
cmp ax, 0x0053
jne .fail
mov edi, [tokens.operators_end]
call identify_operator
cmp ax, UNRECOGNISED_TOKEN_ID
jne .fail
mov edi, "RaNd"
call identify_operator
cmp ax, UNRECOGNISED_TOKEN_ID
jne .fail
mov edi, ""
call identify_operator
cmp ax, UNRECOGNISED_TOKEN_ID
jne .fail
.pass:
mov rsi, msg_pass
call print
ret
.fail:
mov rsi, msg_fail
call print
ret
.msg db "test_identify_operator...", 0x00
msg_pass:
db 0x0A
times (TEST_LINE_LENGTH + .start - .end) db " ", ; right align