stage2: move all tests to compare_output.zig

This commit is contained in:
Andrew Kelley 2020-08-20 17:15:01 -07:00
parent f54b2e2da6
commit 7d6d4b1473
2 changed files with 18 additions and 59 deletions

View File

@ -23,6 +23,12 @@ pub fn addCases(ctx: *TestContext) !void {
case.addError("", &[_][]const u8{":1:1: error: no entry point found"});
// Incorrect return type
case.addError(
\\export fn _start() noreturn {
\\}
, &[_][]const u8{":2:1: error: expected noreturn, found void"});
// Regular old hello world
case.addCompareOutput(
\\export fn _start() noreturn {
@ -702,4 +708,16 @@ pub fn addCases(ctx: *TestContext) !void {
"1109917696\n",
);
}
ctx.compileError("function redefinition", linux_x64,
\\fn entry() void {}
\\fn entry() void {}
, &[_][]const u8{":2:4: error: redefinition of 'entry'"});
ctx.compileError("extern variable has no type", linux_x64,
\\comptime {
\\ _ = foo;
\\}
\\extern var foo;
, &[_][]const u8{":4:1: error: unable to infer variable type"});
}

View File

@ -61,63 +61,4 @@ pub fn addCases(ctx: *TestContext) !void {
\\@0 = str("_start")
\\@1 = export(@0, "start")
);
ctx.compileError("function redefinition", linux_x64,
\\fn entry() void {}
\\fn entry() void {}
, &[_][]const u8{":2:4: error: redefinition of 'entry'"});
ctx.compileError("incorrect return type", linux_x64,
\\export fn _start() noreturn {
\\}
, &[_][]const u8{":2:1: error: expected noreturn, found void"});
ctx.compileError("extern variable has no type", linux_x64,
\\comptime {
\\ _ = foo;
\\}
\\extern var foo;
, &[_][]const u8{":4:1: error: unable to infer variable type"});
//ctx.incrementalFailure("function redefinition", linux_x64,
// \\fn entry() void {}
// \\fn entry() void {}
//, &[_][]const u8{":2:4: error: redefinition of 'entry'"},
// \\fn entry() void {}
//);
//// TODO: need to make sure this works with other variants of export.
//ctx.incrementalFailure("exported symbol collision", linux_x64,
// \\export fn entry() void {}
// \\export fn entry() void {}
//, &[_][]const u8{":2:11: error: redefinition of 'entry'"},
// \\export fn entry() void {}
//);
// ctx.incrementalFailure("missing function name", linux_x64,
// \\fn() void {}
// , &[_][]const u8{":1:3: error: missing function name"},
// \\fn a() void {}
// );
// TODO: re-enable these tests.
// https://github.com/ziglang/zig/issues/1364
//ctx.testCompileError(
// \\comptime {
// \\ return;
// \\}
//, "1.zig", 2, 5, "return expression outside function definition");
//ctx.testCompileError(
// \\export fn entry() void {
// \\ defer return;
// \\}
//, "1.zig", 2, 11, "cannot return from defer expression");
//ctx.testCompileError(
// \\export fn entry() c_int {
// \\ return 36893488147419103232;
// \\}
//, "1.zig", 2, 12, "integer value '36893488147419103232' cannot be stored in type 'c_int'");
}