authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-20 17:15:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-20 17:15:01-07:00
log7d6d4b1473e7c0c8bc6ee29a3e0ecd03e850e5ee
treea7a07d1768f954f0e5da255bd8c98fa75f9a29b8
parentf54b2e2da6a9ef72a37fae064dc04d951c686298

stage2: move all tests to compare_output.zig


2 files changed, 18 insertions(+), 59 deletions(-)

test/stage2/compare_output.zig+18
......@@ -23,6 +23,12 @@ pub fn addCases(ctx: *TestContext) !void {
2323
2424 case.addError("", &[_][]const u8{":1:1: error: no entry point found"});
2525
26 // Incorrect return type
27 case.addError(
28 \\export fn _start() noreturn {
29 \\}
30 , &[_][]const u8{":2:1: error: expected noreturn, found void"});
31
2632 // Regular old hello world
2733 case.addCompareOutput(
2834 \\export fn _start() noreturn {
......@@ -702,4 +708,16 @@ pub fn addCases(ctx: *TestContext) !void {
702708 "1109917696\n",
703709 );
704710 }
711
712 ctx.compileError("function redefinition", linux_x64,
713 \\fn entry() void {}
714 \\fn entry() void {}
715 , &[_][]const u8{":2:4: error: redefinition of 'entry'"});
716
717 ctx.compileError("extern variable has no type", linux_x64,
718 \\comptime {
719 \\ _ = foo;
720 \\}
721 \\extern var foo;
722 , &[_][]const u8{":4:1: error: unable to infer variable type"});
705723}
test/stage2/compile_errors.zig-59
......@@ -61,63 +61,4 @@ pub fn addCases(ctx: *TestContext) !void {
6161 \\@0 = str("_start")
6262 \\@1 = export(@0, "start")
6363 );
64
65 ctx.compileError("function redefinition", linux_x64,
66 \\fn entry() void {}
67 \\fn entry() void {}
68 , &[_][]const u8{":2:4: error: redefinition of 'entry'"});
69
70 ctx.compileError("incorrect return type", linux_x64,
71 \\export fn _start() noreturn {
72 \\}
73 , &[_][]const u8{":2:1: error: expected noreturn, found void"});
74
75 ctx.compileError("extern variable has no type", linux_x64,
76 \\comptime {
77 \\ _ = foo;
78 \\}
79 \\extern var foo;
80 , &[_][]const u8{":4:1: error: unable to infer variable type"});
81
82 //ctx.incrementalFailure("function redefinition", linux_x64,
83 // \\fn entry() void {}
84 // \\fn entry() void {}
85 //, &[_][]const u8{":2:4: error: redefinition of 'entry'"},
86 // \\fn entry() void {}
87 //);
88
89 //// TODO: need to make sure this works with other variants of export.
90 //ctx.incrementalFailure("exported symbol collision", linux_x64,
91 // \\export fn entry() void {}
92 // \\export fn entry() void {}
93 //, &[_][]const u8{":2:11: error: redefinition of 'entry'"},
94 // \\export fn entry() void {}
95 //);
96
97 // ctx.incrementalFailure("missing function name", linux_x64,
98 // \\fn() void {}
99 // , &[_][]const u8{":1:3: error: missing function name"},
100 // \\fn a() void {}
101 // );
102
103 // TODO: re-enable these tests.
104 // https://github.com/ziglang/zig/issues/1364
105
106 //ctx.testCompileError(
107 // \\comptime {
108 // \\ return;
109 // \\}
110 //, "1.zig", 2, 5, "return expression outside function definition");
111
112 //ctx.testCompileError(
113 // \\export fn entry() void {
114 // \\ defer return;
115 // \\}
116 //, "1.zig", 2, 11, "cannot return from defer expression");
117
118 //ctx.testCompileError(
119 // \\export fn entry() c_int {
120 // \\ return 36893488147419103232;
121 // \\}
122 //, "1.zig", 2, 12, "integer value '36893488147419103232' cannot be stored in type 'c_int'");
12364}