diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-05-10 16:50:06 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-05-18 00:44:49 -0700 |
commit | 94a60e2b1bb273f5c98fc3b71ebb1de4f0086525 (patch) | |
tree | 106f3842170ab2e51e6691ff67081f6a68dec4d3 | |
parent | d0ae490d042cc7258fdf331955c0b5b1ca8b32ec (diff) | |
download | mu-94a60e2b1bb273f5c98fc3b71ebb1de4f0086525.tar.gz |
mu.subx: tests for parse-var-with-type
-rw-r--r-- | apps/mu.subx | 138 |
1 files changed, 93 insertions, 45 deletions
diff --git a/apps/mu.subx b/apps/mu.subx index 49be4484..778c3e79 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -4278,14 +4278,23 @@ test-parse-var-with-type: # _test-input-stream contains "int" (clear-stream _test-input-stream) (write _test-input-stream "int") + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %edx 4/r32/esp # - (parse-var-with-type %ecx _test-input-stream) - 8b/-> *eax 2/r32/edx # Var-name - (check-strings-equal %edx "x" "F - test-parse-var-with-type/name") - 8b/-> *(eax+4) 2/r32/edx # Var-type - (check-ints-equal *edx 1 "F - test-parse-var-with-type/type:0") # Tree-is-atom - (check-ints-equal *(edx+4) 1 "F - test-parse-var-with-type/type:1") # Tree-value - (check-ints-equal *(edx+8) 0 "F - test-parse-var-with-type/type:2") # Tree-right + (parse-var-with-type %ecx _test-input-stream %edx) + # var v-addr/edx: (addr var) = lookup(v) + (lookup *edx *(edx+4)) # => eax + 89/<- %edx 0/r32/eax + # check v-addr->name + (lookup *edx *(edx+4)) # Var-name Var-name => eax + (check-strings-equal %eax "x" "F - test-parse-var-with-type/name") + # check v-addr->type + (lookup *(edx+8) *(edx+0xc)) # Var-type Var-type => eax + (check-ints-equal *eax 1 "F - test-parse-var-with-type/type:0") # Tree-is-atom + (check-ints-equal *(eax+4) 1 "F - test-parse-var-with-type/type:1") # Tree-value + (check-ints-equal *(eax+0xc) 0 "F - test-parse-var-with-type/type:2") # Tree-right # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -4307,16 +4316,26 @@ test-parse-var-with-type-and-register: # _test-input-stream contains "int" (clear-stream _test-input-stream) (write _test-input-stream "int") + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %edx 4/r32/esp # - (parse-var-with-type %ecx _test-input-stream) - 8b/-> *eax 2/r32/edx # Var-name - (check-strings-equal %edx "x" "F - test-parse-var-with-type-and-register/name") - 8b/-> *(eax+0x10) 2/r32/edx # Var-register - (check-strings-equal %edx "eax" "F - test-parse-var-with-type-and-register/register") - 8b/-> *(eax+4) 2/r32/edx # Var-type - (check-ints-equal *edx 1 "F - test-parse-var-with-type-and-register/type:0") # Tree-is-atom - (check-ints-equal *(edx+4) 1 "F - test-parse-var-with-type-and-register/type:1") # Tree-left - (check-ints-equal *(edx+8) 0 "F - test-parse-var-with-type-and-register/type:2") # Tree-right + (parse-var-with-type %ecx _test-input-stream %edx) + # var v-addr/edx: (addr var) = lookup(v) + (lookup *edx *(edx+4)) # => eax + 89/<- %edx 0/r32/eax + # check v-addr->name + (lookup *edx *(edx+4)) # Var-name Var-name => eax + (check-strings-equal %eax "x" "F - test-parse-var-with-type-and-register/name") + # check v-addr->register + (lookup *(edx+0x18) *(edx+0x1c)) # Var-register Var-register => eax + (check-strings-equal %eax "eax" "F - test-parse-var-with-type-and-register/register") + # check v-addr->type + (lookup *(edx+8) *(edx+0xc)) # Var-type Var-type => eax + (check-ints-equal *eax 1 "F - test-parse-var-with-type-and-register/type:0") # Tree-is-atom + (check-ints-equal *(eax+4) 1 "F - test-parse-var-with-type-and-register/type:1") # Tree-left + (check-ints-equal *(eax+0xc) 0 "F - test-parse-var-with-type-and-register/type:2") # Tree-right # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -4338,16 +4357,25 @@ test-parse-var-with-trailing-characters: # _test-input-stream contains "int," (clear-stream _test-input-stream) (write _test-input-stream "int,") + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %edx 4/r32/esp # - (parse-var-with-type %ecx _test-input-stream) - 8b/-> *eax 2/r32/edx # Var-name - (check-strings-equal %edx "x" "F - test-parse-var-with-trailing-characters/name") - 8b/-> *(eax+0x10) 2/r32/edx # Var-register - (check-ints-equal %edx 0 "F - test-parse-var-with-trailing-characters/register") - 8b/-> *(eax+4) 2/r32/edx # Var-type - (check-ints-equal *edx 1 "F - test-parse-var-with-trailing-characters/type:0") # Tree-is-atom - (check-ints-equal *(edx+4) 1 "F - test-parse-var-with-trailing-characters/type:1") # Tree-left - (check-ints-equal *(edx+8) 0 "F - test-parse-var-with-trailing-characters/type:1") # Tree-right + (parse-var-with-type %ecx _test-input-stream %edx) + # var v-addr/edx: (addr var) = lookup(v) + (lookup *edx *(edx+4)) # => eax + 89/<- %edx 0/r32/eax + # check v-addr->name + (lookup *edx *(edx+4)) # Var-name Var-name => eax + (check-strings-equal %eax "x" "F - test-parse-var-with-trailing-characters/name") + # check v-addr->register + (check-ints-equal *(edx+0x18) 0 "F - test-parse-var-with-trailing-characters/register") # Var-register + # check v-addr->type + (lookup *(edx+8) *(edx+0xc)) # Var-type Var-type => eax + (check-ints-equal *eax 1 "F - test-parse-var-with-trailing-characters/type:0") # Tree-is-atom + (check-ints-equal *(eax+4) 1 "F - test-parse-var-with-trailing-characters/type:1") # Tree-left + (check-ints-equal *(eax+0xc) 0 "F - test-parse-var-with-trailing-characters/type:1") # Tree-right # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -4369,16 +4397,26 @@ test-parse-var-with-register-and-trailing-characters: # _test-input-stream contains "int," (clear-stream _test-input-stream) (write _test-input-stream "int,") + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %edx 4/r32/esp # - (parse-var-with-type %ecx _test-input-stream) - 8b/-> *eax 2/r32/edx # Var-name - (check-strings-equal %edx "x" "F - test-parse-var-with-register-and-trailing-characters/name") - 8b/-> *(eax+0x10) 2/r32/edx # Var-register - (check-strings-equal %edx "eax" "F - test-parse-var-with-register-and-trailing-characters/register") - 8b/-> *(eax+4) 2/r32/edx # Var-type - (check-ints-equal *edx 1 "F - test-parse-var-with-register-and-trailing-characters/type:0") # Tree-is-atom - (check-ints-equal *(edx+4) 1 "F - test-parse-var-with-register-and-trailing-characters/type:1") # Tree-left - (check-ints-equal *(edx+8) 0 "F - test-parse-var-with-register-and-trailing-characters/type:2") # Tree-right + (parse-var-with-type %ecx _test-input-stream %edx) + # var v-addr/edx: (addr var) = lookup(v) + (lookup *edx *(edx+4)) # => eax + 89/<- %edx 0/r32/eax + # check v-addr->name + (lookup *edx *(edx+4)) # Var-name Var-name => eax + (check-strings-equal %eax "x" "F - test-parse-var-with-register-and-trailing-characters/name") + # check v-addr->register + (lookup *(edx+0x18) *(edx+0x1c)) # Var-register Var-register => eax + (check-strings-equal %eax "eax" "F - test-parse-var-with-register-and-trailing-characters/register") + # check v-addr->type + (lookup *(edx+8) *(edx+0xc)) # Var-type Var-type => eax + (check-ints-equal *eax 1 "F - test-parse-var-with-register-and-trailing-characters/type:0") # Tree-is-atom + (check-ints-equal *(eax+4) 1 "F - test-parse-var-with-register-and-trailing-characters/type:1") # Tree-left + (check-ints-equal *(eax+0xc) 0 "F - test-parse-var-with-register-and-trailing-characters/type:2") # Tree-right # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp @@ -4400,27 +4438,37 @@ test-parse-var-with-compound-type: # _test-input-stream contains "(addr int)" (clear-stream _test-input-stream) (write _test-input-stream "(addr int)") + # var v/edx: (handle var) + 68/push 0/imm32 + 68/push 0/imm32 + 89/<- %edx 4/r32/esp # - (parse-var-with-type %ecx _test-input-stream) - 8b/-> *eax 2/r32/edx # Var-name - (check-strings-equal %edx "x" "F - test-parse-var-with-compound-type/name") - 8b/-> *(eax+0x10) 2/r32/edx # Var-register - (check-ints-equal %edx 0 "F - test-parse-var-with-compound-type/register") - # var type/edx: (handle tree type-id) = var->type - 8b/-> *(eax+4) 2/r32/edx # Var-type + (parse-var-with-type %ecx _test-input-stream %edx) + # var v-addr/edx: (addr var) = lookup(v) + (lookup *edx *(edx+4)) # => eax + 89/<- %edx 0/r32/eax + # check v-addr->name + (lookup *edx *(edx+4)) # Var-name Var-name => eax + (check-strings-equal %eax "x" "F - test-parse-var-with-compound-type/name") + # check v-addr->register + (check-ints-equal *(edx+0x18) 0 "F - test-parse-var-with-compound-type/register") # Var-register + # - check v-addr->type + # var type/edx: (addr tree type-id) = var->type + (lookup *(edx+8) *(edx+0xc)) # Var-type Var-type => eax + 89/<- %edx 0/r32/eax # type is a non-atom (check-ints-equal *edx 0 "F - test-parse-var-with-compound-type/type:0") # Tree-is-atom # type->left == atom(addr) - 8b/-> *(edx+4) 0/r32/eax # Tree-left + (lookup *(edx+4) *(edx+8)) # Tree-left Tree-left => eax (check-ints-equal *eax 1 "F - test-parse-var-with-compound-type/type:1") # Tree-is-atom (check-ints-equal *(eax+4) 2 "F - test-parse-var-with-compound-type/type:2") # Tree-value # type->right->left == atom(int) - 8b/-> *(edx+8) 2/r32/edx # Tree-right - 8b/-> *(edx+4) 0/r32/eax # Tree-left + (lookup *(edx+0xc) *(edx+0x10)) # Tree-right Tree-right => eax + (lookup *(eax+4) *(eax+8)) # Tree-left Tree-left => eax (check-ints-equal *eax 1 "F - test-parse-var-with-compound-type/type:3") # Tree-is-atom (check-ints-equal *(eax+4) 1 "F - test-parse-var-with-compound-type/type:4") # Tree-value # type->right->right == null - (check-ints-equal *(edx+8) 0 "F - test-parse-var-with-compound-type/type:5") # Tree-right + (check-ints-equal *(eax+0xc) 0 "F - test-parse-var-with-compound-type/type:5") # Tree-right # . epilogue 89/<- %esp 5/r32/ebp 5d/pop-to-ebp |