2018-01-22 19:24:07 -08:00
|
|
|
const tests = @import("tests.zig");
|
|
|
|
|
2018-05-31 07:56:59 -07:00
|
|
|
pub fn addCases(cases: *tests.GenHContext) void {
|
2018-01-22 19:24:07 -08:00
|
|
|
cases.add("declare enum",
|
|
|
|
\\const Foo = extern enum { A, B, C };
|
2018-01-25 01:10:11 -08:00
|
|
|
\\export fn entry(foo: Foo) void { }
|
2018-01-22 19:24:07 -08:00
|
|
|
,
|
|
|
|
\\enum Foo {
|
|
|
|
\\ A = 0,
|
|
|
|
\\ B = 1,
|
|
|
|
\\ C = 2
|
|
|
|
\\};
|
|
|
|
\\
|
|
|
|
\\TEST_EXPORT void entry(enum Foo foo);
|
|
|
|
\\
|
|
|
|
);
|
|
|
|
|
|
|
|
cases.add("declare struct",
|
|
|
|
\\const Foo = extern struct {
|
|
|
|
\\ A: i32,
|
|
|
|
\\ B: f32,
|
|
|
|
\\ C: bool,
|
|
|
|
\\};
|
2018-01-25 01:10:11 -08:00
|
|
|
\\export fn entry(foo: Foo) void { }
|
2018-01-22 19:24:07 -08:00
|
|
|
,
|
|
|
|
\\struct Foo {
|
|
|
|
\\ int32_t A;
|
|
|
|
\\ float B;
|
|
|
|
\\ bool C;
|
|
|
|
\\};
|
|
|
|
\\
|
|
|
|
\\TEST_EXPORT void entry(struct Foo foo);
|
|
|
|
\\
|
|
|
|
);
|
|
|
|
|
|
|
|
cases.add("declare union",
|
|
|
|
\\const Foo = extern union {
|
|
|
|
\\ A: i32,
|
|
|
|
\\ B: f32,
|
|
|
|
\\ C: bool,
|
|
|
|
\\};
|
2018-01-25 01:10:11 -08:00
|
|
|
\\export fn entry(foo: Foo) void { }
|
2018-01-22 19:24:07 -08:00
|
|
|
,
|
|
|
|
\\union Foo {
|
|
|
|
\\ int32_t A;
|
|
|
|
\\ float B;
|
|
|
|
\\ bool C;
|
|
|
|
\\};
|
|
|
|
\\
|
|
|
|
\\TEST_EXPORT void entry(union Foo foo);
|
|
|
|
\\
|
|
|
|
);
|
2018-01-23 02:38:20 -08:00
|
|
|
|
2018-03-23 00:27:11 -07:00
|
|
|
cases.add("declare opaque type",
|
|
|
|
\\export const Foo = @OpaqueType();
|
|
|
|
\\
|
2018-05-31 21:07:40 -07:00
|
|
|
\\export fn entry(foo: ?*Foo) void { }
|
2018-03-23 00:27:11 -07:00
|
|
|
,
|
|
|
|
\\struct Foo;
|
|
|
|
\\
|
|
|
|
\\TEST_EXPORT void entry(struct Foo * foo);
|
|
|
|
);
|
|
|
|
|
2018-01-23 02:38:20 -08:00
|
|
|
cases.add("array field-type",
|
|
|
|
\\const Foo = extern struct {
|
|
|
|
\\ A: [2]i32,
|
2018-05-31 21:07:40 -07:00
|
|
|
\\ B: [4]*u32,
|
2018-01-23 02:38:20 -08:00
|
|
|
\\};
|
2018-01-25 01:10:11 -08:00
|
|
|
\\export fn entry(foo: Foo, bar: [3]u8) void { }
|
2018-01-23 02:38:20 -08:00
|
|
|
,
|
|
|
|
\\struct Foo {
|
|
|
|
\\ int32_t A[2];
|
|
|
|
\\ uint32_t * B[4];
|
|
|
|
\\};
|
|
|
|
\\
|
|
|
|
\\TEST_EXPORT void entry(struct Foo foo, uint8_t bar[]);
|
|
|
|
\\
|
|
|
|
);
|
2018-01-22 19:24:07 -08:00
|
|
|
}
|