diff --git a/fish_tests.cpp b/fish_tests.cpp index 0c273643a..af65b70ab 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -585,63 +585,63 @@ static void test_parser() parser_t parser(PARSER_TYPE_GENERAL, true); say(L"Testing block nesting"); - if (!parser.detect_errors(L"if; end")) + if (!parse_util_detect_errors(L"if; end")) { err(L"Incomplete if statement undetected"); } - if (!parser.detect_errors(L"if test; echo")) + if (!parse_util_detect_errors(L"if test; echo")) { err(L"Missing end undetected"); } - if (!parser.detect_errors(L"if test; end; end")) + if (!parse_util_detect_errors(L"if test; end; end")) { err(L"Unbalanced end undetected"); } say(L"Testing detection of invalid use of builtin commands"); - if (!parser.detect_errors(L"case foo")) + if (!parse_util_detect_errors(L"case foo")) { err(L"'case' command outside of block context undetected"); } - if (!parser.detect_errors(L"switch ggg; if true; case foo;end;end")) + if (!parse_util_detect_errors(L"switch ggg; if true; case foo;end;end")) { err(L"'case' command outside of switch block context undetected"); } - if (!parser.detect_errors(L"else")) + if (!parse_util_detect_errors(L"else")) { err(L"'else' command outside of conditional block context undetected"); } - if (!parser.detect_errors(L"else if")) + if (!parse_util_detect_errors(L"else if")) { err(L"'else if' command outside of conditional block context undetected"); } - if (!parser.detect_errors(L"if false; else if; end")) + if (!parse_util_detect_errors(L"if false; else if; end")) { err(L"'else if' missing command undetected"); } - if (!parser.detect_errors(L"break")) + if (!parse_util_detect_errors(L"break")) { err(L"'break' command outside of loop block context undetected"); } - if (parser.detect_errors(L"break --help")) + if (parse_util_detect_errors(L"break --help")) { err(L"'break --help' incorrectly marked as error"); } - if (! parser.detect_errors(L"while false ; function foo ; break ; end ; end ")) + if (! parse_util_detect_errors(L"while false ; function foo ; break ; end ; end ")) { err(L"'break' command inside function allowed to break from loop outside it"); } - if (!parser.detect_errors(L"exec ls|less") || !parser.detect_errors(L"echo|return")) + if (!parse_util_detect_errors(L"exec ls|less") || !parse_util_detect_errors(L"echo|return")) { err(L"Invalid pipe command undetected"); } - if (parser.detect_errors(L"for i in foo ; switch $i ; case blah ; break; end; end ")) + if (parse_util_detect_errors(L"for i in foo ; switch $i ; case blah ; break; end; end ")) { err(L"'break' command inside switch falsely reported as error"); } diff --git a/parse_util.h b/parse_util.h index 28e263ed9..862e5a621 100644 --- a/parse_util.h +++ b/parse_util.h @@ -163,6 +163,6 @@ wcstring parse_util_escape_string_with_quote(const wcstring &cmd, wchar_t quote) /** Given a string, parse it as fish code and then return the indents. The return value has the same size as the string */ std::vector parse_util_compute_indents(const wcstring &src); -parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, parse_error_list_t *out_errors); +parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src, parse_error_list_t *out_errors = NULL); #endif