X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_test_cases_book.ml;h=928373bf8683c80d32d745649362b8f350984a50;hb=a284f5c25c7f6e4d38a7b0c71846af50321951e2;hp=92ad429557f8bbbfc207cb4c833b286b86b9d58f;hpb=80c3c410b1bdc70e7c13a76c77717c509353bb96;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 92ad429..928373b 100644 --- a/compiler/src/lib/tiger/tiger_test_cases_book.ml +++ b/compiler/src/lib/tiger/tiger_test_cases_book.ml @@ -85,27 +85,44 @@ let is_error_expected_parsing_of_filename = let module E = Tiger_error in function | "test49.tig" -> - Some (function E.Invalid_syntax _ -> true | _ -> false) + Some Error.is_invalid_syntax (* TODO: Be more specific - test position *) | _ -> (* 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: 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? *) + | "test18.tig" + | "test19.tig" + | "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 *) + | "test35.tig" + | "test36.tig" -> + Some Error.is_wrong_number_of_args + (* TODO: Be more specific - how many expected, how many given? *) | "test09.tig" | "test11.tig" | "test13.tig" | "test14.tig" + | "test21.tig" | "test23.tig" | "test26.tig" | "test28.tig" @@ -115,7 +132,7 @@ let is_error_expected_semant_of_filename = | "test34.tig" | "test43.tig" -> Some Error.is_wrong_type - (* TODO: Be more specific - what expected, what given? *) + (* TODO: Be more specific - what expected, what given? Where? *) | _ -> (* TODO: Fill-in other expected cases *) None @@ -129,8 +146,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)