From 58bd6c5f8e4b26300dcdd9542881fe148fb51d0c Mon Sep 17 00:00:00 2001 From: Alex Cameron Date: Sun, 22 Nov 2020 18:51:15 +1100 Subject: [PATCH] Add tests for emit-h functionality. --- test/stage2/cbe.zig | 67 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/test/stage2/cbe.zig b/test/stage2/cbe.zig index a3ad90b501..96db7b835e 100644 --- a/test/stage2/cbe.zig +++ b/test/stage2/cbe.zig @@ -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 + \\ + \\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 + \\ + \\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 + \\ + \\void start(uint32_t arg0); + \\ + ); + ctx.h("header with usize param function", linux_x64, + \\export fn start(a: usize) void{} + , + \\#include + \\ + \\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 + \\#include + \\ + \\void start(uint32_t arg0, size_t arg1); + \\ + ); }