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