| ... | ... | @@ -15,6 +15,8 @@ test "empty function with comments" { |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | test "truncate" { |
| 18 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 19 | |
| 18 | 20 | try expect(testTruncate(0x10fd) == 0xfd); |
| 19 | 21 | comptime try expect(testTruncate(0x10fd) == 0xfd); |
| 20 | 22 | } |
| ... | ... | @@ -23,6 +25,9 @@ fn testTruncate(x: u32) u8 { |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 27 | test "truncate to non-power-of-two integers" { |
| 28 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 29 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 30 | |
| 26 | 31 | try testTrunc(u32, u1, 0b10101, 0b1); |
| 27 | 32 | try testTrunc(u32, u1, 0b10110, 0b0); |
| 28 | 33 | try testTrunc(u32, u2, 0b10101, 0b01); |
| ... | ... | @@ -108,14 +113,23 @@ fn first4KeysOfHomeRow() []const u8 { |
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | test "return string from function" { |
| 116 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 117 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 118 | |
| 111 | 119 | try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu")); |
| 112 | 120 | } |
| 113 | 121 | |
| 114 | 122 | test "hex escape" { |
| 123 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 124 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 125 | |
| 115 | 126 | try expect(mem.eql(u8, "\x68\x65\x6c\x6c\x6f", "hello")); |
| 116 | 127 | } |
| 117 | 128 | |
| 118 | 129 | test "multiline string" { |
| 130 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 131 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 132 | |
| 119 | 133 | const s1 = |
| 120 | 134 | \\one |
| 121 | 135 | \\two) |
| ... | ... | @@ -126,6 +140,9 @@ test "multiline string" { |
| 126 | 140 | } |
| 127 | 141 | |
| 128 | 142 | test "multiline string comments at start" { |
| 143 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 144 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 145 | |
| 129 | 146 | const s1 = |
| 130 | 147 | //\\one |
| 131 | 148 | \\two) |
| ... | ... | @@ -136,6 +153,9 @@ test "multiline string comments at start" { |
| 136 | 153 | } |
| 137 | 154 | |
| 138 | 155 | test "multiline string comments at end" { |
| 156 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 157 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 158 | |
| 139 | 159 | const s1 = |
| 140 | 160 | \\one |
| 141 | 161 | \\two) |
| ... | ... | @@ -146,6 +166,9 @@ test "multiline string comments at end" { |
| 146 | 166 | } |
| 147 | 167 | |
| 148 | 168 | test "multiline string comments in middle" { |
| 169 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 170 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 171 | |
| 149 | 172 | const s1 = |
| 150 | 173 | \\one |
| 151 | 174 | //\\two) |
| ... | ... | @@ -156,6 +179,9 @@ test "multiline string comments in middle" { |
| 156 | 179 | } |
| 157 | 180 | |
| 158 | 181 | test "multiline string comments at multiple places" { |
| 182 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 183 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 184 | |
| 159 | 185 | const s1 = |
| 160 | 186 | \\one |
| 161 | 187 | //\\two |
| ... | ... | @@ -172,6 +198,9 @@ test "string concatenation" { |
| 172 | 198 | } |
| 173 | 199 | |
| 174 | 200 | test "array mult operator" { |
| 201 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 202 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 203 | |
| 175 | 204 | try expect(mem.eql(u8, "ab" ** 5, "ababababab")); |
| 176 | 205 | } |
| 177 | 206 | |
| ... | ... | @@ -195,6 +224,9 @@ test "compile time global reinterpret" { |
| 195 | 224 | } |
| 196 | 225 | |
| 197 | 226 | test "cast undefined" { |
| 227 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 228 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 229 | |
| 198 | 230 | const array: [100]u8 = undefined; |
| 199 | 231 | const slice = @as([]const u8, &array); |
| 200 | 232 | testCastUndefined(slice); |
| ... | ... | @@ -204,6 +236,8 @@ fn testCastUndefined(x: []const u8) void { |
| 204 | 236 | } |
| 205 | 237 | |
| 206 | 238 | test "implicit cast after unreachable" { |
| 239 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 240 | |
| 207 | 241 | try expect(outer() == 1234); |
| 208 | 242 | } |
| 209 | 243 | fn inner() i32 { |
| ... | ... | @@ -259,6 +293,9 @@ fn fB() []const u8 { |
| 259 | 293 | } |
| 260 | 294 | |
| 261 | 295 | test "call function pointer in struct" { |
| 296 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 297 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 298 | |
| 262 | 299 | if (builtin.zig_backend == .stage1) return error.SkipZigTest; |
| 263 | 300 | |
| 264 | 301 | try expect(mem.eql(u8, f3(true), "a")); |
| ... | ... | @@ -282,6 +319,8 @@ const FnPtrWrapper = struct { |
| 282 | 319 | }; |
| 283 | 320 | |
| 284 | 321 | test "const ptr from var variable" { |
| 322 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 323 | |
| 285 | 324 | var x: u64 = undefined; |
| 286 | 325 | var y: u64 = undefined; |
| 287 | 326 | |
| ... | ... | @@ -296,6 +335,8 @@ fn copy(src: *const u64, dst: *u64) void { |
| 296 | 335 | } |
| 297 | 336 | |
| 298 | 337 | test "call result of if else expression" { |
| 338 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 339 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 299 | 340 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 300 | 341 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 301 | 342 | |
| ... | ... | @@ -307,6 +348,8 @@ fn f2(x: bool) []const u8 { |
| 307 | 348 | } |
| 308 | 349 | |
| 309 | 350 | test "memcpy and memset intrinsics" { |
| 351 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 352 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 310 | 353 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 311 | 354 | |
| 312 | 355 | try testMemcpyMemset(); |
| ... | ... | @@ -327,6 +370,8 @@ fn testMemcpyMemset() !void { |
| 327 | 370 | } |
| 328 | 371 | |
| 329 | 372 | test "variable is allowed to be a pointer to an opaque type" { |
| 373 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 374 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 330 | 375 | if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO |
| 331 | 376 | |
| 332 | 377 | var x: i32 = 1234; |
| ... | ... | @@ -338,6 +383,9 @@ fn hereIsAnOpaqueType(ptr: *OpaqueA) *OpaqueA { |
| 338 | 383 | } |
| 339 | 384 | |
| 340 | 385 | test "take address of parameter" { |
| 386 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 387 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 388 | |
| 341 | 389 | try testTakeAddressOfParameter(12.34); |
| 342 | 390 | } |
| 343 | 391 | fn testTakeAddressOfParameter(f: f32) !void { |
| ... | ... | @@ -360,6 +408,9 @@ fn testPointerToVoidReturnType2() *const void { |
| 360 | 408 | } |
| 361 | 409 | |
| 362 | 410 | test "array 2D const double ptr" { |
| 411 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 412 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 413 | |
| 363 | 414 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 364 | 415 | |
| 365 | 416 | const rect_2d_vertexes = [_][1]f32{ |
| ... | ... | @@ -376,6 +427,9 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void { |
| 376 | 427 | } |
| 377 | 428 | |
| 378 | 429 | test "double implicit cast in same expression" { |
| 430 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 431 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 432 | |
| 379 | 433 | var x = @as(i32, @as(u16, nine())); |
| 380 | 434 | try expect(x == 9); |
| 381 | 435 | } |
| ... | ... | @@ -384,6 +438,8 @@ fn nine() u8 { |
| 384 | 438 | } |
| 385 | 439 | |
| 386 | 440 | test "struct inside function" { |
| 441 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 442 | |
| 387 | 443 | try testStructInFn(); |
| 388 | 444 | comptime try testStructInFn(); |
| 389 | 445 | } |
| ... | ... | @@ -411,6 +467,8 @@ fn getNull() ?*i32 { |
| 411 | 467 | } |
| 412 | 468 | |
| 413 | 469 | test "global variable assignment with optional unwrapping with var initialized to undefined" { |
| 470 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 471 | |
| 414 | 472 | const S = struct { |
| 415 | 473 | var data: i32 = 1234; |
| 416 | 474 | fn foo() ?*i32 { |
| ... | ... | @@ -426,6 +484,9 @@ test "global variable assignment with optional unwrapping with var initialized t |
| 426 | 484 | var global_foo: *i32 = undefined; |
| 427 | 485 | |
| 428 | 486 | test "peer result location with typed parent, runtime condition, comptime prongs" { |
| 487 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 488 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 489 | |
| 429 | 490 | const S = struct { |
| 430 | 491 | fn doTheTest(arg: i32) i32 { |
| 431 | 492 | const st = Structy{ |
| ... | ... | @@ -523,6 +584,9 @@ test "self reference through fn ptr field" { |
| 523 | 584 | } |
| 524 | 585 | |
| 525 | 586 | test "global variable initialized to global variable array element" { |
| 587 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 588 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 589 | |
| 526 | 590 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; |
| 527 | 591 | |
| 528 | 592 | try expect(global_ptr == &gdt[0]); |
| ... | ... | @@ -537,6 +601,8 @@ var gdt = [_]GDTEntry{ |
| 537 | 601 | var global_ptr = &gdt[0]; |
| 538 | 602 | |
| 539 | 603 | test "global constant is loaded with a runtime-known index" { |
| 604 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 605 | |
| 540 | 606 | const S = struct { |
| 541 | 607 | fn doTheTest() !void { |
| 542 | 608 | var index: usize = 1; |
| ... | ... | @@ -552,6 +618,9 @@ test "global constant is loaded with a runtime-known index" { |
| 552 | 618 | } |
| 553 | 619 | |
| 554 | 620 | test "multiline string literal is null terminated" { |
| 621 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 622 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 623 | |
| 555 | 624 | const s1 = |
| 556 | 625 | \\one |
| 557 | 626 | \\two) |
| ... | ... | @@ -582,6 +651,9 @@ test "explicit cast optional pointers" { |
| 582 | 651 | } |
| 583 | 652 | |
| 584 | 653 | test "pointer comparison" { |
| 654 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 655 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 656 | |
| 585 | 657 | const a = @as([]const u8, "a"); |
| 586 | 658 | const b = &a; |
| 587 | 659 | try expect(ptrEql(b, b)); |
| ... | ... | @@ -591,6 +663,9 @@ fn ptrEql(a: *const []const u8, b: *const []const u8) bool { |
| 591 | 663 | } |
| 592 | 664 | |
| 593 | 665 | test "string concatenation" { |
| 666 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 667 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 668 | |
| 594 | 669 | const a = "OK" ++ " IT " ++ "WORKED"; |
| 595 | 670 | const b = "OK IT WORKED"; |
| 596 | 671 | |
| ... | ... | @@ -610,6 +685,8 @@ test "string concatenation" { |
| 610 | 685 | } |
| 611 | 686 | |
| 612 | 687 | test "thread local variable" { |
| 688 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 689 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 613 | 690 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| 614 | 691 | |
| 615 | 692 | const S = struct { |
| ... | ... | @@ -634,6 +711,8 @@ fn maybe(x: bool) anyerror!?u32 { |
| 634 | 711 | } |
| 635 | 712 | |
| 636 | 713 | test "pointer to thread local array" { |
| 714 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 715 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 637 | 716 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO |
| 638 | 717 | |
| 639 | 718 | const s = "Hello world"; |