diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/compare_output.zig | 8 | ||||
| -rw-r--r-- | test/stage2/compile_errors.zig | 22 | ||||
| -rw-r--r-- | test/stage2/test.zig | 2 | ||||
| -rw-r--r-- | test/stage2/zir.zig | 18 |
4 files changed, 24 insertions, 26 deletions
diff --git a/test/stage2/compare_output.zig b/test/stage2/compare_output.zig index 182ff8131a..4332ed120c 100644 --- a/test/stage2/compare_output.zig +++ b/test/stage2/compare_output.zig @@ -17,9 +17,9 @@ pub fn addCases(ctx: *TestContext) !void { } { - var case = ctx.addExe("hello world with updates", linux_x64); + var case = try ctx.addExe("hello world with updates", linux_x64, .Zig); // Regular old hello world - case.addCompareOutput( + try case.addCompareOutput( \\export fn _start() noreturn { \\ print(); \\ @@ -51,7 +51,7 @@ pub fn addCases(ctx: *TestContext) !void { "Hello, World!\n", ); // Now change the message only - case.addCompareOutput( + try case.addCompareOutput( \\export fn _start() noreturn { \\ print(); \\ @@ -83,7 +83,7 @@ pub fn addCases(ctx: *TestContext) !void { "What is up? This is a longer message that will force the data to be relocated in virtual address space.\n", ); // Now we print it twice. - case.addCompareOutput( + try case.addCompareOutput( \\export fn _start() noreturn { \\ print(); \\ print(); diff --git a/test/stage2/compile_errors.zig b/test/stage2/compile_errors.zig index 7596894dca..4f4ec611db 100644 --- a/test/stage2/compile_errors.zig +++ b/test/stage2/compile_errors.zig @@ -9,7 +9,7 @@ const linux_x64 = std.zig.CrossTarget{ }; pub fn addCases(ctx: *TestContext) !void { - ctx.addZIRError("call undefined local", linux_x64, + try ctx.addError("call undefined local", linux_x64, .ZIR, \\@noreturn = primitive(noreturn) \\ \\@start_fnty = fntype([], @noreturn, cc=Naked) @@ -19,7 +19,7 @@ pub fn addCases(ctx: *TestContext) !void { // TODO: address inconsistency in this message and the one in the next test , &[_][]const u8{":5:13: error: unrecognized identifier: %test"}); - ctx.addZIRError("call with non-existent target", linux_x64, + try ctx.addError("call with non-existent target", linux_x64, .ZIR, \\@noreturn = primitive(noreturn) \\ \\@start_fnty = fntype([], @noreturn, cc=Naked) @@ -31,7 +31,7 @@ pub fn addCases(ctx: *TestContext) !void { , &[_][]const u8{":5:13: error: decl 'notafunc' not found"}); // TODO: this error should occur at the call site, not the fntype decl - ctx.addZIRError("call naked function", linux_x64, + try ctx.addError("call naked function", linux_x64, .ZIR, \\@noreturn = primitive(noreturn) \\ \\@start_fnty = fntype([], @noreturn, cc=Naked) @@ -45,17 +45,15 @@ pub fn addCases(ctx: *TestContext) !void { // TODO: re-enable these tests. // https://github.com/ziglang/zig/issues/1364 - // TODO: add Zig AST -> ZIR testing pipeline - //try ctx.testCompileError( - // \\export fn entry() void {} - // \\export fn entry() void {} - //, "1.zig", 2, 8, "exported symbol collision: 'entry'"); - - //try ctx.testCompileError( - // \\fn() void {} - //, "1.zig", 1, 1, "missing function name"); + // try ctx.addError("Export same symbol twice", linux_x64, .Zig, + // \\export fn entry() void {} + // \\export fn entry() void {} + // , &[_][]const u8{":2:1: error: exported symbol collision"}); + // try ctx.addError("Missing function name", linux_x64, .Zig, + // \\fn() void {} + // , &[_][]const u8{":1:3: error: missing function name"}); //try ctx.testCompileError( // \\comptime { // \\ return; diff --git a/test/stage2/test.zig b/test/stage2/test.zig index dc92f99506..e0ef291588 100644 --- a/test/stage2/test.zig +++ b/test/stage2/test.zig @@ -3,5 +3,5 @@ const TestContext = @import("../../src-self-hosted/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { try @import("compile_errors.zig").addCases(ctx); try @import("compare_output.zig").addCases(ctx); - @import("zir.zig").addCases(ctx); + try @import("zir.zig").addCases(ctx); } diff --git a/test/stage2/zir.zig b/test/stage2/zir.zig index 673be6d99f..a3dec10e73 100644 --- a/test/stage2/zir.zig +++ b/test/stage2/zir.zig @@ -8,8 +8,8 @@ const linux_x64 = std.zig.CrossTarget{ .os_tag = .linux, }; -pub fn addCases(ctx: *TestContext) void { - ctx.addZIRTransform("referencing decls which appear later in the file", linux_x64, +pub fn addCases(ctx: *TestContext) !void { + try ctx.addTransform("referencing decls which appear later in the file", linux_x64, .ZIR, \\@void = primitive(void) \\@fnty = fntype([], @void, cc=C) \\ @@ -32,7 +32,7 @@ pub fn addCases(ctx: *TestContext) void { \\}) \\ ); - ctx.addZIRTransform("elemptr, add, cmp, condbr, return, breakpoint", linux_x64, + try ctx.addTransform("elemptr, add, cmp, condbr, return, breakpoint", linux_x64, .ZIR, \\@void = primitive(void) \\@usize = primitive(usize) \\@fnty = fntype([], @void, cc=C) @@ -86,8 +86,8 @@ pub fn addCases(ctx: *TestContext) void { ); { - var case = ctx.addObjZIR("reference cycle with compile error in the cycle", linux_x64); - case.addTransform( + var case = try ctx.addObj("reference cycle with compile error in the cycle", linux_x64, .ZIR); + try case.addTransform( \\@void = primitive(void) \\@fnty = fntype([], @void, cc=C) \\ @@ -133,7 +133,7 @@ pub fn addCases(ctx: *TestContext) void { \\ ); // Now we introduce a compile error - case.addError( + try case.addError( \\@void = primitive(void) \\@fnty = fntype([], @void, cc=C) \\ @@ -163,7 +163,7 @@ pub fn addCases(ctx: *TestContext) void { // Now we remove the call to `a`. `a` and `b` form a cycle, but no entry points are // referencing either of them. This tests that the cycle is detected, and the error // goes away. - case.addTransform( + try case.addTransform( \\@void = primitive(void) \\@fnty = fntype([], @void, cc=C) \\ @@ -207,7 +207,7 @@ pub fn addCases(ctx: *TestContext) void { return; } - ctx.addZIRCompareOutput("hello world ZIR", + try ctx.addCompareOutput("hello world ZIR", .ZIR, \\@noreturn = primitive(noreturn) \\@void = primitive(void) \\@usize = primitive(usize) @@ -265,7 +265,7 @@ pub fn addCases(ctx: *TestContext) void { \\ ); - ctx.addZIRCompareOutput("function call with no args no return value", + try ctx.addCompareOutput("function call with no args no return value", .ZIR, \\@noreturn = primitive(noreturn) \\@void = primitive(void) \\@usize = primitive(usize) |
