diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-01-22 22:24:07 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-01-22 22:24:07 -0500 |
| commit | cf39819478e237255109d0343e642db70e88071b (patch) | |
| tree | 6c8232d28a484989f43075efeaa5501d5e60154b /test/compile_errors.zig | |
| parent | cacba6f4357fdec8db0ea792889c60022c39fbd3 (diff) | |
| download | zig-cf39819478e237255109d0343e642db70e88071b.tar.gz zig-cf39819478e237255109d0343e642db70e88071b.zip | |
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
Diffstat (limited to 'test/compile_errors.zig')
| -rw-r--r-- | test/compile_errors.zig | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig index d3c0c7cfee..ed3ddb67e2 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -1,6 +1,29 @@ const tests = @import("tests.zig"); pub fn addCases(cases: &tests.CompileErrorContext) { + cases.add("function with non-extern enum parameter", + \\const Foo = enum { A, B, C }; + \\export fn entry(foo: Foo) { } + , ".tmp_source.zig:2:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'"); + + cases.add("function with non-extern struct parameter", + \\const Foo = struct { + \\ A: i32, + \\ B: f32, + \\ C: bool, + \\}; + \\export fn entry(foo: Foo) { } + , ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'"); + + cases.add("function with non-extern union parameter", + \\const Foo = union { + \\ A: i32, + \\ B: f32, + \\ C: bool, + \\}; + \\export fn entry(foo: Foo) { } + , ".tmp_source.zig:6:22: error: parameter of type 'Foo' not allowed in function with calling convention 'ccc'"); + cases.add("switch on enum with 1 field with no prongs", \\const Foo = enum { M }; \\ @@ -1590,7 +1613,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) { , ".tmp_source.zig:3:28: error: expected struct type, found 'i32'"); cases.add("@fieldParentPtr - bad field name", - \\const Foo = struct { + \\const Foo = extern struct { \\ derp: i32, \\}; \\export fn foo(a: &i32) -> &Foo { @@ -1599,7 +1622,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) { , ".tmp_source.zig:5:33: error: struct 'Foo' has no field 'a'"); cases.add("@fieldParentPtr - field pointer is not pointer", - \\const Foo = struct { + \\const Foo = extern struct { \\ a: i32, \\}; \\export fn foo(a: i32) -> &Foo { |
