[WIP] initial compiler backend code
This commit is contained in:
3
compiler/test/dune
Normal file
3
compiler/test/dune
Normal file
@@ -0,0 +1,3 @@
|
||||
(tests
|
||||
(names test_backend)
|
||||
(libraries backend ounit2))
|
31
compiler/test/test_backend.ml
Normal file
31
compiler/test/test_backend.ml
Normal file
@@ -0,0 +1,31 @@
|
||||
open OUnit2
|
||||
open Backend.Be_ast
|
||||
open Backend.Be_translate
|
||||
|
||||
let peq case value = assert_equal value (parse case)
|
||||
|
||||
let test_parse_a_command _ =
|
||||
peq "add" (Acommand "add");
|
||||
peq "sub" (Acommand "sub");
|
||||
peq "neg" (Acommand "neg");
|
||||
peq "eq" (Acommand "eq");
|
||||
peq "gt" (Acommand "gt");
|
||||
peq "lt" (Acommand "lt");
|
||||
peq "and" (Acommand "and");
|
||||
peq "or" (Acommand "or");
|
||||
peq "not" (Acommand "not")
|
||||
;;
|
||||
|
||||
let test_parse_m_command _ =
|
||||
peq "pop local 12" (Mcommand ("pop", "local", "12"));
|
||||
peq "push argument 4" (Mcommand ("push", "argument", "4"))
|
||||
;;
|
||||
|
||||
let suite =
|
||||
"suite"
|
||||
>::: [ "A Instruction" >:: test_parse_a_command
|
||||
; "M Instruction" >:: test_parse_m_command
|
||||
]
|
||||
;;
|
||||
|
||||
let () = run_test_tt_main suite
|
Reference in New Issue
Block a user