diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/translate_c.zig | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/test/translate_c.zig b/test/translate_c.zig index 4ea47a6842..7049173d80 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -31,21 +31,27 @@ pub fn addCases(cases: *tests.TranslateCContext) void { }); cases.add("struct initializer - simple", + \\typedef struct { int x; } foo; \\struct {double x,y,z;} s0 = {1.2, 1.3}; \\struct {int sec,min,hour,day,mon,year;} s1 = {.day=31,12,2014,.sec=30,15,17}; \\struct {int x,y;} s2 = {.y = 2, .x=1}; + \\foo s3 = { 123 }; , &[_][]const u8{ \\const struct_unnamed_1 = extern struct { + \\ x: c_int, + \\}; + \\pub const foo = struct_unnamed_1; + \\const struct_unnamed_2 = extern struct { \\ x: f64, \\ y: f64, \\ z: f64, \\}; - \\pub export var s0: struct_unnamed_1 = struct_unnamed_1{ + \\pub export var s0: struct_unnamed_2 = struct_unnamed_2{ \\ .x = 1.2, \\ .y = 1.3, \\ .z = 0, \\}; - \\const struct_unnamed_2 = extern struct { + \\const struct_unnamed_3 = extern struct { \\ sec: c_int, \\ min: c_int, \\ hour: c_int, @@ -53,7 +59,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ mon: c_int, \\ year: c_int, \\}; - \\pub export var s1: struct_unnamed_2 = struct_unnamed_2{ + \\pub export var s1: struct_unnamed_3 = struct_unnamed_3{ \\ .sec = @as(c_int, 30), \\ .min = @as(c_int, 15), \\ .hour = @as(c_int, 17), @@ -61,14 +67,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ .mon = @as(c_int, 12), \\ .year = @as(c_int, 2014), \\}; - \\const struct_unnamed_3 = extern struct { + \\const struct_unnamed_4 = extern struct { \\ x: c_int, \\ y: c_int, \\}; - \\pub export var s2: struct_unnamed_3 = struct_unnamed_3{ + \\pub export var s2: struct_unnamed_4 = struct_unnamed_4{ \\ .x = @as(c_int, 1), \\ .y = @as(c_int, 2), \\}; + \\pub export var s3: foo = foo{ + \\ .x = @as(c_int, 123), + \\}; }); cases.add("simple ptrCast for casts between opaque types", |
