X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_test_cases_book.ml;h=7502b47a235d55ba7eef3e9d9e97f95286728d56;hb=1d155dc1b6399ec69573fc8043f2ec2a96490b50;hp=3911f53d06c5c1cd605c1742fbf96f83bbae4ab0;hpb=789ef466bebb54a589039a8100147a11ea6f9719;p=tiger.ml.git diff --git a/compiler/src/lib/tiger/tiger_test_cases_book.ml b/compiler/src/lib/tiger/tiger_test_cases_book.ml index 3911f53..7502b47 100644 --- a/compiler/src/lib/tiger/tiger_test_cases_book.ml +++ b/compiler/src/lib/tiger/tiger_test_cases_book.ml @@ -91,17 +91,28 @@ let is_error_expected_parsing_of_filename = (* TODO: Fill-in other expected cases *) None -(* TODO test21.tig - error : procedure returns value and procedure is used in arexpr *) -(* TODO test22.tig - No_such_field_in_record *) -(* TODO test24.tig - Exp_not_an_array *) -(* TODO test25.tig - Exp_not_a_record *) +(* TODO: test18.tig - error : definition of recursive functions is interrupted*) +(* TODO: test21.tig - error : procedure returns value and procedure is used in arexpr *) let is_error_expected_semant_of_filename = let module E = Tiger_error in function - | "test17.tig" -> + | "test17.tig" + | "test33.tig" -> Some Error.is_unknown_type (* TODO: Be more specific - which type? *) + | "test20.tig" -> + Some Error.is_unknown_id + (* TODO: Be more specific - the unknown id is "i" *) + | "test22.tig" -> + Some Error.is_no_such_field_in_record + (* TODO: Be more specific - which field? *) + | "test24.tig" -> + Some Error.is_not_an_array + (* TODO: Be more specific *) + | "test25.tig" -> + Some Error.is_not_a_record + (* TODO: Be more specific *) | "test09.tig" | "test11.tig" | "test13.tig" @@ -129,8 +140,21 @@ let test_case_of_filename filename ~dir = ~is_error_expected_parsing:(is_error_expected_parsing_of_filename filename) ~is_error_expected_semant:(is_error_expected_semant_of_filename filename) +let is_filename_starts_with_dot filename = + match filename.[0] with + | exception Invalid_argument _ -> + (* Filename should not be an empty string *) + assert false + | '.' -> true + | _ -> false + +let is_filename_not_hidden filename = + not (is_filename_starts_with_dot filename) + let read ~from_dir:dir = Sys.readdir dir |> Array.to_list + |> List.filter ~f:is_filename_not_hidden + |> List.filter ~f:(fun filename -> Filename.check_suffix filename ".tig") |> List.sort ~cmp:compare |> List.map ~f:(test_case_of_filename ~dir)