From: Siraaj Khandkar Date: Sun, 16 Sep 2018 16:17:35 +0000 (-0400) Subject: Expect syntax error in test49.tig X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=890378947d20b74a3cdd695f011a7fa1352fa5af;p=tiger.ml.git Expect syntax error in test49.tig --- diff --git a/compiler/src/lib/tiger/tiger_test.ml b/compiler/src/lib/tiger/tiger_test.ml index 47939df..1a27cf2 100644 --- a/compiler/src/lib/tiger/tiger_test.ml +++ b/compiler/src/lib/tiger/tiger_test.ml @@ -46,6 +46,7 @@ type t = ; code : string ; out_lexing : (Tiger_parser.token list) option ; out_parsing : Tiger_absyn.t option + ; is_error_expected_parsing : (Tiger_error.t -> bool) option ; is_error_expected_semant : (Tiger_error.t -> bool) option } @@ -120,6 +121,7 @@ let status_skip ?(info="") () = let case ?(out_lexing=None) ?(out_parsing=None) + ?(is_error_expected_parsing=None) ?(is_error_expected_semant=None) ~code name @@ -128,6 +130,7 @@ let case ; code ; out_lexing ; out_parsing + ; is_error_expected_parsing ; is_error_expected_semant } @@ -291,6 +294,7 @@ let run tests = ; code ; out_lexing ; out_parsing + ; is_error_expected_parsing ; is_error_expected_semant } -> @@ -305,7 +309,7 @@ let run tests = run_pass ~f:(fun () -> pass_parsing ~fake_filename:name ~code) ~expect_output:out_parsing - ~is_error_expected:None + ~is_error_expected:is_error_expected_parsing in let res_sem = run_pass diff --git a/compiler/src/lib/tiger/tiger_test.mli b/compiler/src/lib/tiger/tiger_test.mli index 30527a5..58d743c 100644 --- a/compiler/src/lib/tiger/tiger_test.mli +++ b/compiler/src/lib/tiger/tiger_test.mli @@ -3,6 +3,7 @@ type t val case : ?out_lexing : Tiger_parser.token list option -> ?out_parsing : Tiger_absyn.t option + -> ?is_error_expected_parsing : (Tiger_error.t -> bool) option -> ?is_error_expected_semant : (Tiger_error.t -> bool) option -> code : string -> string diff --git a/compiler/src/lib/tiger/tiger_test_cases_book.ml b/compiler/src/lib/tiger/tiger_test_cases_book.ml index 1ef024d..25e004d 100644 --- a/compiler/src/lib/tiger/tiger_test_cases_book.ml +++ b/compiler/src/lib/tiger/tiger_test_cases_book.ml @@ -80,6 +80,16 @@ let out_parsing_of_filename _ = (* TODO: Fill-in expected cases *) None +let is_error_expected_parsing_of_filename = + let module E = Tiger_error in + function + | "test49.tig" -> + Some (function E.Invalid_syntax _ -> true | _ -> false) + (* TODO: Be more specific - test position *) + | _ -> + (* TODO: Fill-in other expected cases *) + None + let is_error_expected_semant_of_filename _ = (* TODO: Fill-in expected cases *) None @@ -90,6 +100,7 @@ let test_case_of_filename filename ~dir = ~code:(read_file (Filename.concat dir filename)) ~out_lexing:(out_lexing_of_filename filename) ~out_parsing:(out_parsing_of_filename filename) + ~is_error_expected_parsing:(is_error_expected_parsing_of_filename filename) ~is_error_expected_semant:(is_error_expected_semant_of_filename filename) let read ~from_dir:dir =