| ... | ... | @@ -6,6 +6,8 @@ const maxInt = std.math.maxInt; |
| 6 | 6 | const native_endian = builtin.target.cpu.arch.endian(); |
| 7 | 7 | |
| 8 | 8 | test "pointer reinterpret const float to int" { |
| 9 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 10 | |
| 9 | 11 | // The hex representation is 0x3fe3333333333303. |
| 10 | 12 | const float: f64 = 5.99999999999994648725e-01; |
| 11 | 13 | const float_ptr = &float; |
| ... | ... | @@ -18,6 +20,8 @@ test "pointer reinterpret const float to int" { |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | 22 | test "@floatToInt" { |
| 23 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 24 | |
| 21 | 25 | try testFloatToInts(); |
| 22 | 26 | comptime try testFloatToInts(); |
| 23 | 27 | } |
| ... | ... | @@ -33,6 +37,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void { |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | 39 | test "implicit cast from [*]T to ?*anyopaque" { |
| 40 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 41 | |
| 36 | 42 | var a = [_]u8{ 3, 2, 1 }; |
| 37 | 43 | var runtime_zero: usize = 0; |
| 38 | 44 | incrementVoidPtrArray(a[runtime_zero..].ptr, 3); |
| ... | ... | @@ -49,6 +55,7 @@ fn incrementVoidPtrArray(array: ?*anyopaque, len: usize) void { |
| 49 | 55 | test "compile time int to ptr of function" { |
| 50 | 56 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 51 | 57 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO |
| 58 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 52 | 59 | |
| 53 | 60 | try foobar(FUNCTION_CONSTANT); |
| 54 | 61 | } |
| ... | ... | @@ -61,6 +68,8 @@ fn foobar(func: PFN_void) !void { |
| 61 | 68 | } |
| 62 | 69 | |
| 63 | 70 | test "implicit ptr to *anyopaque" { |
| 71 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 72 | |
| 64 | 73 | var a: u32 = 1; |
| 65 | 74 | var ptr: *align(@alignOf(u32)) anyopaque = &a; |
| 66 | 75 | var b: *u32 = @ptrCast(*u32, ptr); |
| ... | ... | @@ -87,6 +96,7 @@ fn returnNullLitFromOptionalTypeErrorRef() anyerror!?*A { |
| 87 | 96 | } |
| 88 | 97 | |
| 89 | 98 | test "peer type resolution: [0]u8 and []const u8" { |
| 99 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 90 | 100 | try expect(peerTypeEmptyArrayAndSlice(true, "hi").len == 0); |
| 91 | 101 | try expect(peerTypeEmptyArrayAndSlice(false, "hi").len == 1); |
| 92 | 102 | comptime { |
| ... | ... | @@ -103,6 +113,7 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) []const u8 { |
| 103 | 113 | } |
| 104 | 114 | |
| 105 | 115 | test "implicitly cast from [N]T to ?[]const T" { |
| 116 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 106 | 117 | try expect(mem.eql(u8, castToOptionalSlice().?, "hi")); |
| 107 | 118 | comptime try expect(mem.eql(u8, castToOptionalSlice().?, "hi")); |
| 108 | 119 | } |
| ... | ... | @@ -112,6 +123,7 @@ fn castToOptionalSlice() ?[]const u8 { |
| 112 | 123 | } |
| 113 | 124 | |
| 114 | 125 | test "cast u128 to f128 and back" { |
| 126 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 115 | 127 | comptime try testCast128(); |
| 116 | 128 | try testCast128(); |
| 117 | 129 | } |
| ... | ... | @@ -129,6 +141,7 @@ fn cast128Float(x: u128) f128 { |
| 129 | 141 | } |
| 130 | 142 | |
| 131 | 143 | test "implicit cast from *[N]T to ?[*]T" { |
| 144 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 132 | 145 | var x: ?[*]u16 = null; |
| 133 | 146 | var y: [4]u16 = [4]u16{ 0, 1, 2, 3 }; |
| 134 | 147 | |
| ... | ... | @@ -140,6 +153,7 @@ test "implicit cast from *[N]T to ?[*]T" { |
| 140 | 153 | } |
| 141 | 154 | |
| 142 | 155 | test "implicit cast from *T to ?*anyopaque" { |
| 156 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 143 | 157 | var a: u8 = 1; |
| 144 | 158 | incrementVoidPtrValue(&a); |
| 145 | 159 | try std.testing.expect(a == 2); |
| ... | ... | @@ -150,6 +164,7 @@ fn incrementVoidPtrValue(value: ?*anyopaque) void { |
| 150 | 164 | } |
| 151 | 165 | |
| 152 | 166 | test "implicit cast *[0]T to E![]const u8" { |
| 167 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 153 | 168 | var x = @as(anyerror![]const u8, &[0]u8{}); |
| 154 | 169 | try expect((x catch unreachable).len == 0); |
| 155 | 170 | } |
| ... | ... | @@ -160,11 +175,13 @@ test "cast from array reference to fn: comptime fn ptr" { |
| 160 | 175 | try expect(@ptrToInt(f) == @ptrToInt(&global_array)); |
| 161 | 176 | } |
| 162 | 177 | test "cast from array reference to fn: runtime fn ptr" { |
| 178 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 163 | 179 | var f = @ptrCast(*const fn () callconv(.C) void, &global_array); |
| 164 | 180 | try expect(@ptrToInt(f) == @ptrToInt(&global_array)); |
| 165 | 181 | } |
| 166 | 182 | |
| 167 | 183 | test "*const [N]null u8 to ?[]const u8" { |
| 184 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 168 | 185 | const S = struct { |
| 169 | 186 | fn doTheTest() !void { |
| 170 | 187 | var a = "Hello"; |
| ... | ... | @@ -196,6 +213,7 @@ test "cast between [*c]T and ?[*:0]T on fn parameter" { |
| 196 | 213 | |
| 197 | 214 | var global_struct: struct { f0: usize } = undefined; |
| 198 | 215 | test "assignment to optional pointer result loc" { |
| 216 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 199 | 217 | var foo: struct { ptr: ?*anyopaque } = .{ .ptr = &global_struct }; |
| 200 | 218 | try expect(foo.ptr.? == @ptrCast(*anyopaque, &global_struct)); |
| 201 | 219 | } |
| ... | ... | @@ -217,6 +235,8 @@ fn boolToStr(b: bool) []const u8 { |
| 217 | 235 | } |
| 218 | 236 | |
| 219 | 237 | test "cast f16 to wider types" { |
| 238 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 239 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 220 | 240 | const S = struct { |
| 221 | 241 | fn doTheTest() !void { |
| 222 | 242 | var x: f16 = 1234.0; |
| ... | ... | @@ -230,6 +250,9 @@ test "cast f16 to wider types" { |
| 230 | 250 | } |
| 231 | 251 | |
| 232 | 252 | test "cast f128 to narrower types" { |
| 253 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 254 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 255 | |
| 233 | 256 | const S = struct { |
| 234 | 257 | fn doTheTest() !void { |
| 235 | 258 | var x: f128 = 1234.0; |
| ... | ... | @@ -243,6 +266,7 @@ test "cast f128 to narrower types" { |
| 243 | 266 | } |
| 244 | 267 | |
| 245 | 268 | test "peer type resolution: unreachable, null, slice" { |
| 269 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 246 | 270 | const S = struct { |
| 247 | 271 | fn doTheTest(num: usize, word: []const u8) !void { |
| 248 | 272 | const result = switch (num) { |