28 lines
604 B
OCaml
28 lines
604 B
OCaml
open OUnit2
|
|
open Hack.Ast
|
|
open Hack.Translate
|
|
|
|
let peq case value = assert_equal value (parse case)
|
|
let test_parse_g_instr _ = peq "(LOOP)" (Ginstr "LOOP")
|
|
|
|
let test_parse_a_instr _ =
|
|
peq "@100" (Aconst 100);
|
|
peq "@ABC" (Ainstr "ABC")
|
|
;;
|
|
|
|
let test_parse_c_instr _ =
|
|
peq "M-D" (Cinstr ("", "M-D", ""));
|
|
peq "0;JMP" (Cinstr ("", "0", "JMP"));
|
|
peq "D=A+1" (Cinstr ("D", "A+1", ""))
|
|
;;
|
|
|
|
let suite =
|
|
"suite"
|
|
>::: [ "G Instruction" >:: test_parse_g_instr
|
|
; "A Instruction" >:: test_parse_a_instr
|
|
; "C Instruction" >:: test_parse_c_instr
|
|
]
|
|
;;
|
|
|
|
let () = run_test_tt_main suite
|