Simplified shader test output

This commit is contained in:
2024-09-20 13:00:17 +02:00
parent 3f93e1a92d
commit 243d83663a
11 changed files with 48 additions and 36 deletions

View File

@@ -283,7 +283,6 @@ pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String
print_to_builder(builder, "%", node.name); print_to_builder(builder, "%", node.name);
for child : node.children { for child : node.children {
print("%\n", child.kind);
if child.kind == .Variable { if child.kind == .Variable {
append(builder, "."); append(builder, ".");
pretty_print_variable(child, indentation, builder); pretty_print_variable(child, indentation, builder);

View File

@@ -386,7 +386,11 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
} }
case .Binary; { case .Binary; {
indent(*state.builder, indentation); indent(*state.builder, indentation);
if node.token.kind != .TOKEN_ASSIGN {
append(*state.builder, "("); append(*state.builder, "(");
}
lhs := node.children[0]; lhs := node.children[0];
rhs := node.children[1]; rhs := node.children[1];
emit_node(state, lhs, 0); emit_node(state, lhs, 0);
@@ -395,8 +399,10 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
emit_operator(state, node.token.kind); emit_operator(state, node.token.kind);
append(*state.builder, " "); append(*state.builder, " ");
emit_node(state, rhs, 0); emit_node(state, rhs, 0);
if node.token.kind != .TOKEN_ASSIGN {
append(*state.builder, ")"); append(*state.builder, ")");
} }
}
case .Unary; { case .Unary; {
assert(false, "Not implemented yet: unary"); assert(false, "Not implemented yet: unary");
} }

View File

@@ -310,8 +310,8 @@ run_semantic_analysis_test :: (file_path : string, root : *AST_Node, output_type
result_text = pretty_print_symbol_table(*checker, temp); result_text = pretty_print_symbol_table(*checker, temp);
constraints := pretty_print_type_constraints(*checker, temp); constraints := pretty_print_type_constraints(*checker, temp);
type_vars := pretty_print_type_variables(*checker, temp); type_vars := pretty_print_type_variables(*checker, temp);
print("Constraints\n%\n", constraints); // print("Constraints\n%\n", constraints);
print("Solution\n%\n", type_vars); // print("Solution\n%\n", type_vars);
} }
if output_type & .StdOut { if output_type & .StdOut {
@@ -477,7 +477,23 @@ run_test :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Resul
} }
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) { run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) {
print("%Running test: %\n", cyan(), test_case.path); print("%Running test: %......", cyan(), test_case.path);
// path 30
// len 35
// == 5
// path 20
// len = 35
// == 15
len := 50;
rest := len - test_case.path.count;
for i: 0..rest {
print(" ");
}
run_test(test_case.path, test_case.stage_flags, results, output_type); run_test(test_case.path, test_case.stage_flags, results, output_type);
} }
@@ -525,7 +541,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
} }
} }
print("\n"); // print("\n");
} }
print("\n"); print("\n");
@@ -620,26 +636,26 @@ evaluate_result :: (result : Result) {
if #complete result.type == { if #complete result.type == {
case .File_Read_Failed; { case .File_Read_Failed; {
print("%", red()); print(" %", red());
print("% failed with File_Read_Failed\n", result.path); print("failed with File_Read_Failed\n");
} }
case .Golden_File_Not_Found; { case .Golden_File_Not_Found; {
print("%", red()); print(" %", red());
print("% failed with Golden File Not Found for stage %\n", result.path, stage); print("failed with Golden File Not Found for stage %\n", stage);
} }
case .StdOut; { case .StdOut; {
} }
case .Golden_Output; { case .Golden_Output; {
print("%", yellow()); print(" %", yellow());
print("% output new golden file at %\n", result.path, result.golden_path); print("output new golden file at %\n", result.golden_path);
} }
case .Passed; { case .Passed; {
print("%", green()); print(" %", green());
print("% passed %\n", result.path, stage); print("passed %\n", stage);
} }
case .Failed; { case .Failed; {
print("%", red()); print(" %", red());
print("% failed %\n", result.path, stage); print("failed %\n", stage);
} }
} }

View File

@@ -1,5 +1,5 @@
void vs_main() void vs_main()
{ {
float x = 2.0f + 5.0f; float x = (2.0f + 5.0f);
} }

View File

@@ -2,6 +2,6 @@ void vs_main()
{ {
float x = 5.0f; float x = 5.0f;
float y = 3000.0f; float y = 3000.0f;
float z = y * y + x; float z = ((y * y) + x);
} }

View File

@@ -1,4 +1,2 @@
struct Foo; struct Foo {};
struct Foo {}

View File

@@ -4,7 +4,7 @@ cbuffer __PROPERTIES : register(b0)
} }
float3 vs_main(float3 pos : POSITION, float2 uv) : SV_POSITION float3 vs_main(float3 pos : POSITION, float2 uv : TEXCOORD0) : SV_POSITION
{ {
return pos; return pos;
} }

View File

@@ -8,7 +8,7 @@ int foo()
float bar() float bar()
{ {
return 1235.0f * 500; return (1235.0f * 500);
} }
void vs_main() void vs_main()

View File

@@ -1,15 +1,13 @@
struct Foo;
float foo(Foo f); float foo(Foo f);
struct Foo struct Foo
{ {
float some_data; float some_data;
} };
float foo(Foo f) float foo(Foo f)
{ {
return f.some_data * 2.0f; return (f.some_data * 2.0f);
} }
void vs_main() void vs_main()

View File

@@ -1,9 +1,7 @@
struct Data;
struct Data struct Data
{ {
float4 color; float4 color;
} };
void vs_main() void vs_main()
{ {

View File

@@ -1,15 +1,12 @@
struct Foo;
struct Bar;
struct Foo struct Foo
{ {
float4 color; float4 color;
} };
struct Bar struct Bar
{ {
Foo t; Foo t;
} };
void vs_main() void vs_main()
{ {