Fixed a bunch of semant back and forth but now it looks like I broke some parameter checking in functions.
This commit is contained in:
144
Test.jai
144
Test.jai
@@ -169,7 +169,7 @@ run_parser_test :: (file_path : string, output_type : Output_Type = 0) -> Result
|
||||
|
||||
result := lex(*lexer, *temp);
|
||||
if result.had_error {
|
||||
result_data.type = .Passed;
|
||||
result_data.type = .Passed; //@Incomplete: Huh?
|
||||
return result_data, null;
|
||||
}
|
||||
|
||||
@@ -408,10 +408,10 @@ run_codegen_test :: (path : string, output_type : Output_Type = 0) -> Result, Co
|
||||
return result, codegen_result;
|
||||
}
|
||||
|
||||
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compilation_Result {
|
||||
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result {
|
||||
compiler : Shader_Compiler;
|
||||
result : Result;
|
||||
compilation_result := compile_file(*compiler, path);
|
||||
compilation_result := compile_file(*compiler, .[path]);
|
||||
print("\n");
|
||||
|
||||
if compilation_result.had_error {
|
||||
@@ -422,6 +422,102 @@ run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Co
|
||||
return result, compilation_result;
|
||||
}
|
||||
|
||||
run_lexer_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||
result_data : Result;
|
||||
result_data.path = file_path;
|
||||
result_data.stage = .Lexer;
|
||||
|
||||
result_text : string;
|
||||
|
||||
add_file(result, file_path);
|
||||
lex(result);
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(result.messages);
|
||||
} else {
|
||||
result_text = pretty_print_tokens(result.files[0].tokens.tokens, *temp);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(file_path, .Lexer);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data;
|
||||
}
|
||||
|
||||
run_parser_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||
result_data : Result;
|
||||
result_data.path = file_path;
|
||||
|
||||
add_file(result, file_path);
|
||||
|
||||
lex(result);
|
||||
if result.had_error {
|
||||
result_data.type = .Passed;
|
||||
return result_data;
|
||||
}
|
||||
|
||||
result_data = run_parser_test(result, output_type);
|
||||
|
||||
return result_data;
|
||||
}
|
||||
|
||||
run_parser_test :: (result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||
parse(result);
|
||||
result_data : Result;
|
||||
result_data.path = result.files[0].file.path;
|
||||
result_text : string;
|
||||
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(result.messages,, temp);
|
||||
} else {
|
||||
result_text = pretty_print_ast(result.files[0].ast_root, *temp);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(result.files[0].file.path, .Parser);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data;
|
||||
}
|
||||
|
||||
run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
|
||||
add_file(result, file_path);
|
||||
|
||||
result_data : Result;
|
||||
|
||||
result_data.path = file_path;
|
||||
result_data.stage = .Semantic_Analysis;
|
||||
result_text : string;
|
||||
check(result);
|
||||
|
||||
if result.had_error {
|
||||
result_data.type = .Failed;
|
||||
result_text = report_messages(result.messages);
|
||||
} else {
|
||||
result_text = pretty_print_symbol_table(result, temp);
|
||||
}
|
||||
|
||||
if output_type & .StdOut {
|
||||
result_data.info_text = result_text;
|
||||
result_data.type = .StdOut;
|
||||
return result_data;
|
||||
}
|
||||
|
||||
golden_path := get_golden_path(file_path, .Semantic_Analysis);
|
||||
do_golden_comparison(golden_path, result_text, *result_data, output_type);
|
||||
return result_data;
|
||||
}
|
||||
|
||||
make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := context.allocator) -> Test_Case {
|
||||
test_case : Test_Case;
|
||||
test_case.path = copy_string(path,, allocator);
|
||||
@@ -431,6 +527,48 @@ make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := contex
|
||||
return test_case;
|
||||
}
|
||||
|
||||
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
||||
compile_result : Compile_Result;
|
||||
result : Result;
|
||||
if stage_flags & .Lexer {
|
||||
result = run_lexer_test(file_path, *compile_result, output_type);
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Parser {
|
||||
if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
|
||||
result = run_parser_test(*compile_result, output_type);
|
||||
} else {
|
||||
result = run_parser_test(file_path, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
if stage_flags & .Semantic_Analysis {
|
||||
if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
result = run_semantic_analysis_test(file_path, *compile_result, output_type);
|
||||
} else {
|
||||
result = run_semantic_analysis_test(file_path, *compile_result, output_type);
|
||||
}
|
||||
record_result(results, result);
|
||||
}
|
||||
|
||||
// if stage_flags & .Codegen {
|
||||
// if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
|
||||
// result = run_codegen_test(file_path, *compile_result, output_type);
|
||||
// } else if compile_result.ast_root {
|
||||
// result = run_codegen_test(file_path, *compile_result, output_type);
|
||||
// } else {
|
||||
// result = run_codegen_test(file_path, *compile_result, output_type);
|
||||
// }
|
||||
// record_result(results, result);
|
||||
// }
|
||||
|
||||
// if stage_flags & .Compile {
|
||||
// result = run_compile_test(file_path, output_type);
|
||||
// }
|
||||
}
|
||||
|
||||
run_test :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
||||
lexer : Lexer;
|
||||
result : Result;
|
||||
|
||||
Reference in New Issue
Block a user