| ... | @@ -24,6 +24,16 @@ void zig_f32(float); | ... | @@ -24,6 +24,16 @@ void zig_f32(float); |
| 24 | void zig_f64(double); | 24 | void zig_f64(double); |
| 25 | void zig_five_floats(float, float, float, float, float); | 25 | void zig_five_floats(float, float, float, float, float); |
| 26 | | 26 | |
| | 27 | bool zig_ret_bool(); |
| | 28 | uint8_t zig_ret_u8(); |
| | 29 | uint16_t zig_ret_u16(); |
| | 30 | uint32_t zig_ret_u32(); |
| | 31 | uint64_t zig_ret_u64(); |
| | 32 | int8_t zig_ret_i8(); |
| | 33 | int16_t zig_ret_i16(); |
| | 34 | int32_t zig_ret_i32(); |
| | 35 | int64_t zig_ret_i64(); |
| | 36 | |
| 27 | void zig_ptr(void *); | 37 | void zig_ptr(void *); |
| 28 | | 38 | |
| 29 | void zig_bool(bool); | 39 | void zig_bool(bool); |
| ... | @@ -119,6 +129,20 @@ void run_c_tests(void) { | ... | @@ -119,6 +129,20 @@ void run_c_tests(void) { |
| 119 | assert_or_panic(res.d == 23); | 129 | assert_or_panic(res.d == 23); |
| 120 | assert_or_panic(res.e == 24); | 130 | assert_or_panic(res.e == 24); |
| 121 | } | 131 | } |
| | 132 | |
| | 133 | { |
| | 134 | assert_or_panic(zig_ret_bool() == 1); |
| | 135 | |
| | 136 | assert_or_panic(zig_ret_u8() == 0xff); |
| | 137 | assert_or_panic(zig_ret_u16() == 0xffff); |
| | 138 | assert_or_panic(zig_ret_u32() == 0xffffffff); |
| | 139 | assert_or_panic(zig_ret_u64() == 0xffffffffffffffff); |
| | 140 | |
| | 141 | assert_or_panic(zig_ret_i8() == -1); |
| | 142 | assert_or_panic(zig_ret_i16() == -1); |
| | 143 | assert_or_panic(zig_ret_i32() == -1); |
| | 144 | assert_or_panic(zig_ret_i64() == -1); |
| | 145 | } |
| 122 | } | 146 | } |
| 123 | | 147 | |
| 124 | void c_u8(uint8_t x) { | 148 | void c_u8(uint8_t x) { |
| ... | @@ -236,3 +260,31 @@ void c_big_struct_floats(Vector5 vec) { | ... | @@ -236,3 +260,31 @@ void c_big_struct_floats(Vector5 vec) { |
| 236 | assert_or_panic(vec.w == 69); | 260 | assert_or_panic(vec.w == 69); |
| 237 | assert_or_panic(vec.q == 55); | 261 | assert_or_panic(vec.q == 55); |
| 238 | } | 262 | } |
| | 263 | |
| | 264 | bool c_ret_bool() { |
| | 265 | return 1; |
| | 266 | } |
| | 267 | uint8_t c_ret_u8() { |
| | 268 | return 0xff; |
| | 269 | } |
| | 270 | uint16_t c_ret_u16() { |
| | 271 | return 0xffff; |
| | 272 | } |
| | 273 | uint32_t c_ret_u32() { |
| | 274 | return 0xffffffff; |
| | 275 | } |
| | 276 | uint64_t c_ret_u64() { |
| | 277 | return 0xffffffffffffffff; |
| | 278 | } |
| | 279 | int8_t c_ret_i8() { |
| | 280 | return -1; |
| | 281 | } |
| | 282 | int16_t c_ret_i16() { |
| | 283 | return -1; |
| | 284 | } |
| | 285 | int32_t c_ret_i32() { |
| | 286 | return -1; |
| | 287 | } |
| | 288 | int64_t c_ret_i64() { |
| | 289 | return -1; |
| | 290 | } |