| ... | @@ -5,6 +5,8 @@ const maxInt = std.math.maxInt; | ... | @@ -5,6 +5,8 @@ const maxInt = std.math.maxInt; |
| 5 | const builtin = @import("builtin"); | 5 | const builtin = @import("builtin"); |
| 6 | | 6 | |
| 7 | test "int to ptr cast" { | 7 | test "int to ptr cast" { |
| | 8 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 9 | |
| 8 | const x = @as(usize, 13); | 10 | const x = @as(usize, 13); |
| 9 | const y = @intToPtr(*u8, x); | 11 | const y = @intToPtr(*u8, x); |
| 10 | const z = @ptrToInt(y); | 12 | const z = @ptrToInt(y); |
| ... | @@ -12,11 +14,15 @@ test "int to ptr cast" { | ... | @@ -12,11 +14,15 @@ test "int to ptr cast" { |
| 12 | } | 14 | } |
| 13 | | 15 | |
| 14 | test "integer literal to pointer cast" { | 16 | test "integer literal to pointer cast" { |
| | 17 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| | 18 | |
| 15 | const vga_mem = @intToPtr(*u16, 0xB8000); | 19 | const vga_mem = @intToPtr(*u16, 0xB8000); |
| 16 | try expect(@ptrToInt(vga_mem) == 0xB8000); | 20 | try expect(@ptrToInt(vga_mem) == 0xB8000); |
| 17 | } | 21 | } |
| 18 | | 22 | |
| 19 | test "peer type resolution: ?T and T" { | 23 | test "peer type resolution: ?T and T" { |
| | 24 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 25 | |
| 20 | try expect(peerTypeTAndOptionalT(true, false).? == 0); | 26 | try expect(peerTypeTAndOptionalT(true, false).? == 0); |
| 21 | try expect(peerTypeTAndOptionalT(false, false).? == 3); | 27 | try expect(peerTypeTAndOptionalT(false, false).? == 3); |
| 22 | comptime { | 28 | comptime { |
| ... | @@ -33,6 +39,8 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize { | ... | @@ -33,6 +39,8 @@ fn peerTypeTAndOptionalT(c: bool, b: bool) ?usize { |
| 33 | } | 39 | } |
| 34 | | 40 | |
| 35 | test "resolve undefined with integer" { | 41 | test "resolve undefined with integer" { |
| | 42 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 43 | |
| 36 | try testResolveUndefWithInt(true, 1234); | 44 | try testResolveUndefWithInt(true, 1234); |
| 37 | comptime try testResolveUndefWithInt(true, 1234); | 45 | comptime try testResolveUndefWithInt(true, 1234); |
| 38 | } | 46 | } |
| ... | @@ -88,6 +96,8 @@ test "comptime_int @intToFloat" { | ... | @@ -88,6 +96,8 @@ test "comptime_int @intToFloat" { |
| 88 | } | 96 | } |
| 89 | | 97 | |
| 90 | test "@floatToInt" { | 98 | test "@floatToInt" { |
| | 99 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 100 | |
| 91 | try testFloatToInts(); | 101 | try testFloatToInts(); |
| 92 | comptime try testFloatToInts(); | 102 | comptime try testFloatToInts(); |
| 93 | } | 103 | } |
| ... | @@ -107,6 +117,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void { | ... | @@ -107,6 +117,8 @@ fn expectFloatToInt(comptime F: type, f: F, comptime I: type, i: I) !void { |
| 107 | } | 117 | } |
| 108 | | 118 | |
| 109 | test "implicitly cast indirect pointer to maybe-indirect pointer" { | 119 | test "implicitly cast indirect pointer to maybe-indirect pointer" { |
| | 120 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 121 | |
| 110 | const S = struct { | 122 | const S = struct { |
| 111 | const Self = @This(); | 123 | const Self = @This(); |
| 112 | x: u8, | 124 | x: u8, |
| ... | @@ -163,6 +175,8 @@ test "@floatCast comptime_int and comptime_float" { | ... | @@ -163,6 +175,8 @@ test "@floatCast comptime_int and comptime_float" { |
| 163 | } | 175 | } |
| 164 | | 176 | |
| 165 | test "coerce undefined to optional" { | 177 | test "coerce undefined to optional" { |
| | 178 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 179 | |
| 166 | try expect(MakeType(void).getNull() == null); | 180 | try expect(MakeType(void).getNull() == null); |
| 167 | try expect(MakeType(void).getNonNull() != null); | 181 | try expect(MakeType(void).getNonNull() != null); |
| 168 | } | 182 | } |
| ... | @@ -180,6 +194,8 @@ fn MakeType(comptime T: type) type { | ... | @@ -180,6 +194,8 @@ fn MakeType(comptime T: type) type { |
| 180 | } | 194 | } |
| 181 | | 195 | |
| 182 | test "implicit cast from *[N]T to [*c]T" { | 196 | test "implicit cast from *[N]T to [*c]T" { |
| | 197 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 198 | |
| 183 | var x: [4]u16 = [4]u16{ 0, 1, 2, 3 }; | 199 | var x: [4]u16 = [4]u16{ 0, 1, 2, 3 }; |
| 184 | var y: [*c]u16 = &x; | 200 | var y: [*c]u16 = &x; |
| 185 | | 201 | |
| ... | @@ -190,6 +206,8 @@ test "implicit cast from *[N]T to [*c]T" { | ... | @@ -190,6 +206,8 @@ test "implicit cast from *[N]T to [*c]T" { |
| 190 | } | 206 | } |
| 191 | | 207 | |
| 192 | test "*usize to *void" { | 208 | test "*usize to *void" { |
| | 209 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 210 | |
| 193 | var i = @as(usize, 0); | 211 | var i = @as(usize, 0); |
| 194 | var v = @ptrCast(*void, &i); | 212 | var v = @ptrCast(*void, &i); |
| 195 | v.* = {}; | 213 | v.* = {}; |
| ... | @@ -202,6 +220,8 @@ test "@intToEnum passed a comptime_int to an enum with one item" { | ... | @@ -202,6 +220,8 @@ test "@intToEnum passed a comptime_int to an enum with one item" { |
| 202 | } | 220 | } |
| 203 | | 221 | |
| 204 | test "@intCast to u0 and use the result" { | 222 | test "@intCast to u0 and use the result" { |
| | 223 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 224 | |
| 205 | const S = struct { | 225 | const S = struct { |
| 206 | fn doTheTest(zero: u1, one: u1, bigzero: i32) !void { | 226 | fn doTheTest(zero: u1, one: u1, bigzero: i32) !void { |
| 207 | try expect((one << @intCast(u0, bigzero)) == 1); | 227 | try expect((one << @intCast(u0, bigzero)) == 1); |
| ... | @@ -213,6 +233,8 @@ test "@intCast to u0 and use the result" { | ... | @@ -213,6 +233,8 @@ test "@intCast to u0 and use the result" { |
| 213 | } | 233 | } |
| 214 | | 234 | |
| 215 | test "peer result null and comptime_int" { | 235 | test "peer result null and comptime_int" { |
| | 236 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 237 | |
| 216 | const S = struct { | 238 | const S = struct { |
| 217 | fn blah(n: i32) ?i32 { | 239 | fn blah(n: i32) ?i32 { |
| 218 | if (n == 0) { | 240 | if (n == 0) { |
| ... | @@ -234,6 +256,8 @@ test "peer result null and comptime_int" { | ... | @@ -234,6 +256,8 @@ test "peer result null and comptime_int" { |
| 234 | } | 256 | } |
| 235 | | 257 | |
| 236 | test "*const ?[*]const T to [*c]const [*c]const T" { | 258 | test "*const ?[*]const T to [*c]const [*c]const T" { |
| | 259 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 260 | |
| 237 | var array = [_]u8{ 'o', 'k' }; | 261 | var array = [_]u8{ 'o', 'k' }; |
| 238 | const opt_array_ptr: ?[*]const u8 = &array; | 262 | const opt_array_ptr: ?[*]const u8 = &array; |
| 239 | const a: *const ?[*]const u8 = &opt_array_ptr; | 263 | const a: *const ?[*]const u8 = &opt_array_ptr; |
| ... | @@ -243,6 +267,8 @@ test "*const ?[*]const T to [*c]const [*c]const T" { | ... | @@ -243,6 +267,8 @@ test "*const ?[*]const T to [*c]const [*c]const T" { |
| 243 | } | 267 | } |
| 244 | | 268 | |
| 245 | test "array coersion to undefined at runtime" { | 269 | test "array coersion to undefined at runtime" { |
| | 270 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 271 | |
| 246 | @setRuntimeSafety(true); | 272 | @setRuntimeSafety(true); |
| 247 | | 273 | |
| 248 | // TODO implement @setRuntimeSafety in stage2 | 274 | // TODO implement @setRuntimeSafety in stage2 |
| ... | @@ -270,6 +296,8 @@ fn implicitIntLitToOptional() void { | ... | @@ -270,6 +296,8 @@ fn implicitIntLitToOptional() void { |
| 270 | } | 296 | } |
| 271 | | 297 | |
| 272 | test "return u8 coercing into ?u32 return type" { | 298 | test "return u8 coercing into ?u32 return type" { |
| | 299 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 300 | |
| 273 | const S = struct { | 301 | const S = struct { |
| 274 | fn doTheTest() !void { | 302 | fn doTheTest() !void { |
| 275 | try expect(foo(123).? == 123); | 303 | try expect(foo(123).? == 123); |
| ... | @@ -288,6 +316,8 @@ test "cast from ?[*]T to ??[*]T" { | ... | @@ -288,6 +316,8 @@ test "cast from ?[*]T to ??[*]T" { |
| 288 | } | 316 | } |
| 289 | | 317 | |
| 290 | test "peer type unsigned int to signed" { | 318 | test "peer type unsigned int to signed" { |
| | 319 | if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| | 320 | |
| 291 | var w: u31 = 5; | 321 | var w: u31 = 5; |
| 292 | var x: u8 = 7; | 322 | var x: u8 = 7; |
| 293 | var y: i32 = -5; | 323 | var y: i32 = -5; |