Add tests for emit-h functionality.

This commit is contained in:
Alex Cameron 2020-11-22 18:51:15 +11:00
parent 8d6066e09c
commit 58bd6c5f8e

View File

@ -19,7 +19,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
\\
);
ctx.h("Simple header", linux_x64,
ctx.h("simple header", linux_x64,
\\export fn start() void{}
,
\\void start(void);
@ -249,4 +249,69 @@ pub fn addCases(ctx: *TestContext) !void {
\\}
\\
);
ctx.h("header with single param function", linux_x64,
\\export fn start(a: u8) void{}
,
\\#include <stdint.h>
\\
\\void start(uint8_t arg0);
\\
);
ctx.h("header with multiple param function", linux_x64,
\\export fn start(a: u8, b: u8, c: u8) void{}
,
\\#include <stdint.h>
\\
\\void start(uint8_t arg0, uint8_t arg1, uint8_t arg2);
\\
);
ctx.h("header with u32 param function", linux_x64,
\\export fn start(a: u32) void{}
,
\\#include <stdint.h>
\\
\\void start(uint32_t arg0);
\\
);
ctx.h("header with usize param function", linux_x64,
\\export fn start(a: usize) void{}
,
\\#include <stddef.h>
\\
\\void start(size_t arg0);
\\
);
ctx.h("header with bool param function", linux_x64,
\\export fn start(a: bool) void{}
,
\\void start(bool arg0);
\\
);
ctx.h("header with noreturn function", linux_x64,
\\export fn start() noreturn {
\\ unreachable;
\\}
,
\\zig_noreturn void start(void);
\\
);
ctx.h("header with multiple functions", linux_x64,
\\export fn a() void{}
\\export fn b() void{}
\\export fn c() void{}
,
\\void a(void);
\\void b(void);
\\void c(void);
\\
);
ctx.h("header with multiple includes", linux_x64,
\\export fn start(a: u32, b: usize) void{}
,
\\#include <stddef.h>
\\#include <stdint.h>
\\
\\void start(uint32_t arg0, size_t arg1);
\\
);
}