-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for examples & invalid asm src
- Loading branch information
Showing
9 changed files
with
52 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
; Print factorial of input number | ||
; If input < 0, print 1 | ||
|
||
main: | ||
in rax | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
; Sum N integers | ||
; Print 0 if N <= 0 | ||
|
||
mov rax, 0 | ||
in rcx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
main: | ||
mov 10, rax | ||
hlt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
main: | ||
mov rax, 1 | ||
weirdInstr | ||
hlt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
main: | ||
jmp somewhere | ||
hlt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
set(ASM_OUTPUT ${CMAKE_BINARY_DIR}/test.vo) | ||
|
||
add_asm_test(NAME asm::cmpWithZero SRC examples/cmpWithZero.vasm OUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::cmpWithZero_-1 FILE ${ASM_OUTPUT} INPUT -1 OUTPUT 0) | ||
add_vm_test(NAME vm::cmpWithZero_0 FILE ${ASM_OUTPUT} INPUT 0 OUTPUT 0) | ||
add_vm_test(NAME vm::cmpWithZero_1 FILE ${ASM_OUTPUT} INPUT 1 OUTPUT 1) | ||
add_asm_test(NAME asm::asmExpressions FILE examples/asmExpressions.vasm OUTPUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::asmExpressions FILE ${ASM_OUTPUT} OUTPUT "1\n3\n3\n7") | ||
|
||
add_asm_test(NAME asm::cmpWithZero FILE examples/cmpWithZero.vasm OUTPUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::cmpWithZero_-1 FILE ${ASM_OUTPUT} INPUT "-1" OUTPUT "0") | ||
add_vm_test(NAME vm::cmpWithZero_0 FILE ${ASM_OUTPUT} INPUT "0" OUTPUT "0") | ||
add_vm_test(NAME vm::cmpWithZero_1 FILE ${ASM_OUTPUT} INPUT "1" OUTPUT "1") | ||
|
||
add_asm_test(NAME asm::factorialRecursive FILE examples/factorialRecursive.vasm OUTPUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::factorialRecursive_-1 FILE ${ASM_OUTPUT} INPUT "-1" OUTPUT "1") | ||
add_vm_test(NAME vm::factorialRecursive_0 FILE ${ASM_OUTPUT} INPUT "0" OUTPUT "1") | ||
add_vm_test(NAME vm::factorialRecursive_1 FILE ${ASM_OUTPUT} INPUT "1" OUTPUT "1") | ||
add_vm_test(NAME vm::factorialRecursive_5 FILE ${ASM_OUTPUT} INPUT "5" OUTPUT "120") | ||
|
||
add_asm_test(NAME asm::loopSum FILE examples/loopSum.vasm OUTPUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::loopSum_-1 FILE ${ASM_OUTPUT} INPUT "-1" OUTPUT "0") | ||
add_vm_test(NAME vm::loopSum_0 FILE ${ASM_OUTPUT} INPUT "0 0" OUTPUT "0") | ||
add_vm_test(NAME vm::loopSum_5 FILE ${ASM_OUTPUT} INPUT "5 1 2 3 -1 0" OUTPUT "5") | ||
|
||
add_asm_test(NAME asm::loopSumArray FILE examples/loopSumArray.vasm OUTPUT ${ASM_OUTPUT}) | ||
add_vm_test(NAME vm::loopSumArray_-1 FILE ${ASM_OUTPUT} INPUT "-1" OUTPUT "0") | ||
add_vm_test(NAME vm::loopSumArray_0 FILE ${ASM_OUTPUT} INPUT "0" OUTPUT "0") | ||
add_vm_test(NAME vm::loopSumArray_10 FILE ${ASM_OUTPUT} INPUT "10 -1 -1 -1 -1 -1 -1 -1 -1 1 0" OUTPUT "-7") | ||
add_vm_test(NAME vm::loopSumArray_11 FILE ${ASM_OUTPUT} INPUT "11" OUTPUT "-1") | ||
|
||
add_asm_test(NAME asm::invalidFile FILE howtoexist OUTPUT ${ASM_OUTPUT} WILL_FAIL) | ||
add_asm_test(NAME asm::invalidInstr FILE test/invalidInstr.vasm OUTPUT ${ASM_OUTPUT} WILL_FAIL) | ||
add_asm_test(NAME asm::invalidArgs FILE test/invalidArgs.vasm OUTPUT ${ASM_OUTPUT} WILL_FAIL) | ||
add_asm_test(NAME asm::invalidSymbol FILE test/invalidSymbol.vasm OUTPUT ${ASM_OUTPUT} WILL_FAIL) | ||
|