add new kind of test: generating .h files. and more

* docgen supports obj_err code kind for demonstrating
   errors without explicit test cases
 * add documentation for `extern enum`. See #367
 * remove coldcc keyword and add @setIsCold. See #661
 * add compile errors for non-extern struct, enum, unions
   in function signatures
 * add .h file generation for extern struct, enum, unions
This commit is contained in:
Andrew Kelley
2018-01-22 22:24:07 -05:00
parent cacba6f435
commit cf39819478
21 changed files with 682 additions and 83 deletions

53
test/gen_h.zig Normal file
View File

@@ -0,0 +1,53 @@
const tests = @import("tests.zig");
pub fn addCases(cases: &tests.GenHContext) {
cases.add("declare enum",
\\const Foo = extern enum { A, B, C };
\\export fn entry(foo: Foo) { }
,
\\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,
\\};
\\export fn entry(foo: Foo) { }
,
\\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,
\\};
\\export fn entry(foo: Foo) { }
,
\\union Foo {
\\ int32_t A;
\\ float B;
\\ bool C;
\\};
\\
\\TEST_EXPORT void entry(union Foo foo);
\\
);
}