diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-24 00:31:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-24 00:31:33 -0400 |
| commit | 10bdf73a02c90dc375985e49b08b5020cfc20b93 (patch) | |
| tree | 2485d62496dd7436bcbabe80e7b47ca369ccbd38 /test | |
| parent | 99153ac0aa390f01091308073b39947c45851ae6 (diff) | |
| parent | 72599d420b1bebb37efb2179a91d8256287f7c28 (diff) | |
| download | zig-10bdf73a02c90dc375985e49b08b5020cfc20b93.tar.gz zig-10bdf73a02c90dc375985e49b08b5020cfc20b93.zip | |
Merge pull request #1266 from ziglang/self-hosted-libc-hello-world
Self hosted libc hello world
Diffstat (limited to 'test')
| -rw-r--r-- | test/stage2/compare_output.zig | 12 | ||||
| -rw-r--r-- | test/stage2/compile_errors.zig | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/test/stage2/compare_output.zig b/test/stage2/compare_output.zig new file mode 100644 index 0000000000..35adcbb96b --- /dev/null +++ b/test/stage2/compare_output.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const TestContext = @import("../../src-self-hosted/test.zig").TestContext; + +pub fn addCases(ctx: *TestContext) !void { + try ctx.testCompareOutputLibC( + \\extern fn puts([*]const u8) void; + \\export fn main() c_int { + \\ puts(c"Hello, world!"); + \\ return 0; + \\} + , "Hello, world!" ++ std.cstr.line_sep); +} diff --git a/test/stage2/compile_errors.zig b/test/stage2/compile_errors.zig index 1dca908e69..2cecd78653 100644 --- a/test/stage2/compile_errors.zig +++ b/test/stage2/compile_errors.zig @@ -9,4 +9,22 @@ pub fn addCases(ctx: *TestContext) !void { try ctx.testCompileError( \\fn() void {} , "1.zig", 1, 1, "missing function name"); + + try ctx.testCompileError( + \\comptime { + \\ return; + \\} + , "1.zig", 2, 5, "return expression outside function definition"); + + try ctx.testCompileError( + \\export fn entry() void { + \\ defer return; + \\} + , "1.zig", 2, 11, "cannot return from defer expression"); + + try ctx.testCompileError( + \\export fn entry() c_int { + \\ return 36893488147419103232; + \\} + , "1.zig", 2, 12, "integer value '36893488147419103232' cannot be stored in type 'c_int'"); } |
