Commit 6664d2418d

Andrew Kelley <andrew@ziglang.org>
2023-03-15 02:02:33
test-cases: add missing compile log output
The new testing harness is not bound by previous limitations; it can now test compile log output as well.
1 parent 6d6f6a4
test/cases/compile_errors/compile_log.zig
@@ -17,3 +17,12 @@ export fn baz() void {
 //
 // :5:5: error: found compile log statement
 // :11:5: note: also here
+//
+// Compile Log Output:
+// @as(*const [5:0]u8, "begin")
+// @as(*const [1:0]u8, "a"), @as(i32, 12), @as(*const [1:0]u8, "b"), @as([]const u8, "hi")
+// @as(*const [3:0]u8, "end")
+// @as(comptime_int, 4)
+// @as(*const [5:0]u8, "begin")
+// @as(*const [1:0]u8, "a"), @as(i32, [runtime value]), @as(*const [1:0]u8, "b"), @as([]const u8, [runtime value])
+// @as(*const [3:0]u8, "end")
test/cases/compile_errors/compile_log_a_pointer_to_an_opaque_value.zig
@@ -1,5 +1,5 @@
 export fn entry() void {
-    @compileLog(@ptrCast(*const anyopaque, &entry));
+    @compileLog(@ptrCast(*align(1) const anyopaque, &entry));
 }
 
 // error
@@ -7,3 +7,6 @@ export fn entry() void {
 // target=native
 //
 // :2:5: error: found compile log statement
+//
+// Compile Log Output:
+// @as(*const anyopaque, (function 'entry'))
test/cases/compile_errors/compile_log_statement_inside_function_which_must_be_comptime_evaluated.zig
@@ -12,3 +12,6 @@ export fn entry() void {
 // target=native
 //
 // :2:5: error: found compile log statement
+//
+// Compile Log Output:
+// @as(*const [3:0]u8, "i32\x00")
test/cases/compile_errors/compile_log_statement_warning_deduplication_in_generic_fn.zig
@@ -13,3 +13,8 @@ fn inner(comptime n: usize) void {
 //
 // :7:39: error: found compile log statement
 // :7:39: note: also here
+//
+// Compile Log Output:
+// @as(*const [4:0]u8, "!@#$")
+// @as(*const [4:0]u8, "!@#$")
+// @as(*const [4:0]u8, "!@#$")
test/cases/compile_errors/compileLog_of_tagged_enum_doesnt_crash_the_compiler.zig
@@ -15,3 +15,7 @@ pub export fn entry() void {
 // target=native
 //
 // :6:5: error: found compile log statement
+//
+// Compile Log Output:
+// @as(tmp.Bar, .{ .X = 123 })
+// @as(tmp.Bar, [runtime value])
test/cases/compile_log.0.zig
@@ -15,3 +15,8 @@ fn x() void {}
 // error
 //
 // :6:23: error: expected type 'usize', found 'bool'
+//
+// Compile Log Output:
+// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn() void, (function 'x'))
+// @as(comptime_int, 1000)
+// @as(comptime_int, 1234)
test/cases/compile_log.1.zig
@@ -14,3 +14,7 @@ fn x() void {}
 //
 // :9:5: error: found compile log statement
 // :4:5: note: also here
+//
+// Compile Log Output:
+// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn() void, (function 'x'))
+// @as(comptime_int, 1000)