diff --git a/src/test.zig b/src/test.zig index 2f3389d7fffb7907aac0189092c985d45a35be22..8ede838a5ef762af8eb5a1dbd7504a579dc9459d 100644 --- a/src/test.zig +++ b/src/test.zig @@ -1012,18 +1012,18 @@ pub const TestContext = struct { ) !void { var cases = std.ArrayList(usize).init(ctx.arena); - var it = dir.iterate(); + var it = try dir.walk(ctx.arena); var filenames = std.ArrayList([]const u8).init(ctx.arena); while (try it.next()) |entry| { if (entry.kind != .File) continue; // Ignore stuff such as .swp files - switch (Compilation.classifyFileExt(entry.name)) { + switch (Compilation.classifyFileExt(entry.basename)) { .unknown => continue, else => {}, } - try filenames.append(try ctx.arena.dupe(u8, entry.name)); + try filenames.append(try ctx.arena.dupe(u8, entry.path)); } // Sort filenames, so that incremental tests are contiguous and in-order diff --git a/test/behavior.zig b/test/behavior.zig index 828a56a81f563215c22272173c7cfc84c86869ff..4d8b3587bc96df162541c97f535505618da233eb 100644 --- a/test/behavior.zig +++ b/test/behavior.zig @@ -69,8 +69,10 @@ test { _ = @import("behavior/bugs/7003.zig"); _ = @import("behavior/bugs/7027.zig"); _ = @import("behavior/bugs/7047.zig"); + _ = @import("behavior/bugs/7187.zig"); _ = @import("behavior/bugs/7250.zig"); _ = @import("behavior/bugs/9584.zig"); + _ = @import("behavior/bugs/10138.zig"); _ = @import("behavior/bugs/10147.zig"); _ = @import("behavior/bugs/10970.zig"); _ = @import("behavior/bugs/11046.zig"); diff --git a/test/behavior/bugs/10138.zig b/test/behavior/bugs/10138.zig new file mode 100644 index 0000000000000000000000000000000000000000..88dc5acde74fe2863011a3de993b24221da0e0eb --- /dev/null +++ b/test/behavior/bugs/10138.zig @@ -0,0 +1,34 @@ +const std = @import("std"); +const builtin = @import("builtin"); + +test "registers get overwritten when ignoring return" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + if (builtin.cpu.arch != .x86_64 or builtin.os.tag != .linux) return error.SkipZigTest; + + const fd = open(); + _ = write(fd, "a", 1); + _ = close(fd); +} + +fn open() usize { + return 42; +} + +fn write(fd: usize, a: [*]const u8, len: usize) usize { + return syscall4(.WRITE, fd, @ptrToInt(a), len); +} + +fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize { + _ = n; + _ = a; + _ = b; + _ = c; + return 23; +} + +fn close(fd: usize) usize { + if (fd != 42) + unreachable; + return 0; +} diff --git a/test/behavior/bugs/7187.zig b/test/behavior/bugs/7187.zig new file mode 100644 index 0000000000000000000000000000000000000000..86f5aa670643897c44738d43952697429c8e680a --- /dev/null +++ b/test/behavior/bugs/7187.zig @@ -0,0 +1,18 @@ +const std = @import("std"); +const builtin = @import("builtin"); +const expect = std.testing.expect; + +test "miscompilation with bool return type" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + + var x: usize = 1; + var y: bool = getFalse(); + _ = y; + + try expect(x == 1); +} + +fn getFalse() bool { + return false; +} diff --git a/test/incremental/access_slice_element_by_index_slice_elem_val.zig b/test/incremental/access_slice_element_by_index_slice_elem_val.zig deleted file mode 100644 index a0bdae0826aa8d982759c837e7e729766ab6a478..0000000000000000000000000000000000000000 --- a/test/incremental/access_slice_element_by_index_slice_elem_val.zig +++ /dev/null @@ -1,17 +0,0 @@ -var array = [_]usize{ 0, 42, 123, 34 }; -var slice: []const usize = &array; - -pub fn main() void { - assert(slice[0] == 0); - assert(slice[1] == 42); - assert(slice[2] == 123); - assert(slice[3] == 34); -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// target=x86_64-linux,x86_64-macos -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig b/test/incremental/hello_world_with_updates_x86_64_linux.0.zig deleted file mode 100644 index 960fae5e644fa67cb8f46decb7c774ae7a0719d1..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.0.zig +++ /dev/null @@ -1,5 +0,0 @@ -// error -// output_mode=Exe -// target=x86_64-linux -// -// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig b/test/incremental/hello_world_with_updates_x86_64_linux.1.zig deleted file mode 100644 index 0f347b7f5069ccefb13bd680334cbba2a4beb4e7..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.1.zig +++ /dev/null @@ -1,5 +0,0 @@ -pub export fn _start() noreturn {} - -// error -// -// :1:34: error: expected noreturn, found void diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig b/test/incremental/hello_world_with_updates_x86_64_linux.2.zig deleted file mode 100644 index fcea1870ce59ef67264c3be650beafabbd5a97e3..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.2.zig +++ /dev/null @@ -1,32 +0,0 @@ -pub export fn _start() noreturn { - print(); - - exit(); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - [arg3] "{rdx}" (14), - : "rcx", "r11", "memory" - ); - return; -} - -fn exit() noreturn { - asm volatile ("syscall" - : - : [number] "{rax}" (231), - [arg1] "{rdi}" (0), - : "rcx", "r11", "memory" - ); - unreachable; -} - -// run -// -// Hello, World! -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig b/test/incremental/hello_world_with_updates_x86_64_linux.3.zig deleted file mode 100644 index 7812023372e14acc9c4c93441e913126d1e7de1d..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.3.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - [arg3] "{rdx}" (14), - : "rcx", "r11", "memory" - ); - return; -} - -// run -// -// Hello, World! -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig b/test/incremental/hello_world_with_updates_x86_64_linux.4.zig deleted file mode 100644 index cdf47012b8306d2a234871842bfe00da550522de..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.4.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - [arg3] "{rdx}" (104), - : "rcx", "r11", "memory" - ); - return; -} - -// run -// -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// diff --git a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig b/test/incremental/hello_world_with_updates_x86_64_linux.5.zig deleted file mode 100644 index 68c1e305f713135321cd2000bdd9b50dc2020c8e..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_linux.5.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - print(); - print(); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), - [arg3] "{rdx}" (104), - : "rcx", "r11", "memory" - ); - return; -} - -// run -// -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig b/test/incremental/hello_world_with_updates_x86_64_macos.0.zig deleted file mode 100644 index 34440c4603e0c2164ad399efb03d59e4de9cf6ff..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.0.zig +++ /dev/null @@ -1,5 +0,0 @@ -// error -// output_mode=Exe -// target=x86_64-macos -// -// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig b/test/incremental/hello_world_with_updates_x86_64_macos.1.zig deleted file mode 100644 index 909fc9ccfbcb343f761414446c0ec4d52e98aeef..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.1.zig +++ /dev/null @@ -1,5 +0,0 @@ -pub export fn main() noreturn {} - -// error -// -// :1:32: error: expected noreturn, found void diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig b/test/incremental/hello_world_with_updates_x86_64_macos.2.zig deleted file mode 100644 index fb8cb39eddf859f843ce61b068c0f6f8f9feb387..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.2.zig +++ /dev/null @@ -1,19 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; -extern "c" fn exit(usize) noreturn; - -pub export fn main() noreturn { - print(); - - exit(0); -} - -fn print() void { - const msg = @ptrToInt("Hello, World!\n"); - const len = 14; - _ = write(1, msg, len); -} - -// run -// -// Hello, World! -// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig b/test/incremental/hello_world_with_updates_x86_64_macos.3.zig deleted file mode 100644 index f6e233886b0a7d616f92dd11ffb4232191c997de..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.3.zig +++ /dev/null @@ -1,16 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - print(); -} - -fn print() void { - const msg = @ptrToInt("Hello, World!\n"); - const len = 14; - _ = write(1, msg, len); -} - -// run -// -// Hello, World! -// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig b/test/incremental/hello_world_with_updates_x86_64_macos.4.zig deleted file mode 100644 index f89cef73543ce1f3e51a4e0152c0a8c367edf537..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.4.zig +++ /dev/null @@ -1,22 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - print(); - print(); - print(); - print(); -} - -fn print() void { - const msg = @ptrToInt("Hello, World!\n"); - const len = 14; - _ = write(1, msg, len); -} - -// run -// -// Hello, World! -// Hello, World! -// Hello, World! -// Hello, World! -// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig b/test/incremental/hello_world_with_updates_x86_64_macos.5.zig deleted file mode 100644 index 0d7f97578afe1274d1c8e3d356ce702992edca61..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.5.zig +++ /dev/null @@ -1,16 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - print(); -} - -fn print() void { - const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - const len = 104; - _ = write(1, msg, len); -} - -// run -// -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// diff --git a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig b/test/incremental/hello_world_with_updates_x86_64_macos.6.zig deleted file mode 100644 index 3ce2cb717639d663c2679dcdef2a4583c3c3f8ec..0000000000000000000000000000000000000000 --- a/test/incremental/hello_world_with_updates_x86_64_macos.6.zig +++ /dev/null @@ -1,18 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - print(); - print(); -} - -fn print() void { - const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); - const len = 104; - _ = write(1, msg, len); -} - -// run -// -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// What is up? This is a longer message that will force the data to be relocated in virtual address space. -// diff --git a/test/incremental/inline_assembly_x86_64_linux.0.zig b/test/incremental/inline_assembly_x86_64_linux.0.zig deleted file mode 100644 index e3c0f3badbb61fa8a53a63bcabb7b90edbe4657b..0000000000000000000000000000000000000000 --- a/test/incremental/inline_assembly_x86_64_linux.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - const number = 1234; - const x = asm volatile ("syscall" - : [o] "{rax}" (-> number), - : [number] "{rax}" (231), - [arg1] "{rdi}" (60), - : "rcx", "r11", "memory" - ); - _ = x; -} - -// error -// output_mode=Exe -// target=x86_64-linux -// -// :4:27: error: expected type, found comptime_int diff --git a/test/incremental/inline_assembly_x86_64_linux.1.zig b/test/incremental/inline_assembly_x86_64_linux.1.zig deleted file mode 100644 index b35014b0f6b6afa26cd92e7496edbc70c2b90dbf..0000000000000000000000000000000000000000 --- a/test/incremental/inline_assembly_x86_64_linux.1.zig +++ /dev/null @@ -1,15 +0,0 @@ -const S = struct { - comptime { - asm volatile ( - \\zig_moment: - \\syscall - ); - } -}; -pub fn main() void { - _ = S; -} - -// error -// -// :3:13: error: volatile is meaningless on global assembly diff --git a/test/incremental/inline_assembly_x86_64_linux.2.zig b/test/incremental/inline_assembly_x86_64_linux.2.zig deleted file mode 100644 index 1695265ab4ebcbb6a2625bb9abdffb0d751eec07..0000000000000000000000000000000000000000 --- a/test/incremental/inline_assembly_x86_64_linux.2.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() void { - var bruh: u32 = 1; - asm ("" - : - : [bruh] "{rax}" (4) - : "memory" - ); -} - -// error -// -// :3:5: error: assembly expression with no output must be marked volatile diff --git a/test/incremental/inline_assembly_x86_64_linux.3.zig b/test/incremental/inline_assembly_x86_64_linux.3.zig deleted file mode 100644 index 765eaeb97eb2f8373afff7399051a2fca6269070..0000000000000000000000000000000000000000 --- a/test/incremental/inline_assembly_x86_64_linux.3.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() void {} -comptime { - asm ("" - : - : [bruh] "{rax}" (4) - : "memory" - ); -} - -// error -// -// :3:5: error: global assembly cannot have inputs, outputs, or clobbers diff --git a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig b/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig deleted file mode 100644 index 4c045496da446fc709a1ba8ffe1cf16c46356104..0000000000000000000000000000000000000000 --- a/test/incremental/issue_10138_callee_preserved_regs_working_x86_64_linux.zig +++ /dev/null @@ -1,31 +0,0 @@ -pub fn main() void { - const fd = open(); - _ = write(fd, "a", 1); - _ = close(fd); -} - -fn open() usize { - return 42; -} - -fn write(fd: usize, a: [*]const u8, len: usize) usize { - return syscall4(.WRITE, fd, @ptrToInt(a), len); -} - -fn syscall4(n: enum { WRITE }, a: usize, b: usize, c: usize) usize { - _ = n; - _ = a; - _ = b; - _ = c; - return 23; -} - -fn close(fd: usize) usize { - if (fd != 42) - unreachable; - return 0; -} - -// run -// target=x86_64-linux -// diff --git a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig b/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig deleted file mode 100644 index 3aed8685bfb744da97bfc4cdf7f175daba803ac5..0000000000000000000000000000000000000000 --- a/test/incremental/issue_7187_miscompilation_with_bool_return_type.zig +++ /dev/null @@ -1,18 +0,0 @@ -pub fn main() void { - var x: usize = 1; - var y: bool = getFalse(); - _ = y; - - assert(x == 1); -} - -fn getFalse() bool { - return false; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.0.zig b/test/incremental/load_store_via_pointer_deref.0.zig deleted file mode 100644 index 96aedf3196a50338de8f90f084da7bbec8fdc8a2..0000000000000000000000000000000000000000 --- a/test/incremental/load_store_via_pointer_deref.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u32 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u32) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.1.zig b/test/incremental/load_store_via_pointer_deref.1.zig deleted file mode 100644 index e31109274448887f9d914324df19bfbc5963dca9..0000000000000000000000000000000000000000 --- a/test/incremental/load_store_via_pointer_deref.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u16 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u16) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/load_store_via_pointer_deref.2.zig b/test/incremental/load_store_via_pointer_deref.2.zig deleted file mode 100644 index 3b1484faa10ade80cdb7039c309b05ae4f58d860..0000000000000000000000000000000000000000 --- a/test/incremental/load_store_via_pointer_deref.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - var x: u8 = undefined; - set(&x); - assert(x == 123); -} - -fn set(x: *u8) void { - x.* = 123; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig deleted file mode 100644 index ecba1c8133714f48d0423b98c9a213a057550ad1..0000000000000000000000000000000000000000 --- a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.0.zig +++ /dev/null @@ -1,13 +0,0 @@ -pub export fn _start() noreturn { - asm volatile ("syscall" - : - : [number] "{rax}" (60), // exit - [arg1] "{rdi}" (0), - : "rcx", "r11", "memory" - ); - unreachable; -} - -// run -// target=x86_64-linux -// diff --git a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig b/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig deleted file mode 100644 index 529acbcf38132bb09f0a47adc2a128ac7c7b7ac5..0000000000000000000000000000000000000000 --- a/test/incremental/only_1_function_and_it_gets_updated_x86_64_linux.1.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub export fn _start() noreturn { - asm volatile ("syscall" - : - : [number] "{rax}" (231), // exit_group - [arg1] "{rdi}" (0), - : "rcx", "r11", "memory" - ); - unreachable; -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig deleted file mode 100644 index 6134622a0e6e1793b08c53b2b89356569e6bf0e4..0000000000000000000000000000000000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.0.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u8) u8 { - var b: u8 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig deleted file mode 100644 index 4d87d7b9c5d6cc99833537eeefa60ff250432ab0..0000000000000000000000000000000000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.1.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u16) u16 { - var b: u16 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig b/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig deleted file mode 100644 index b6652279624630d277f955d2b07366bb90a05afd..0000000000000000000000000000000000000000 --- a/test/incremental/saving_vars_of_different_abi_size_to_stack.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() void { - assert(callMe(2) == 24); -} - -fn callMe(a: u32) u32 { - var b: u32 = a + 10; - const c = 2 * b; - return c; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/incremental/subtracting_numbers_at_runtime.zig b/test/incremental/subtracting_numbers_at_runtime.zig deleted file mode 100644 index 5ea81a34b8468b99d7d4cdfc3ee27bdb9a14a18f..0000000000000000000000000000000000000000 --- a/test/incremental/subtracting_numbers_at_runtime.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - sub(7, 4); -} - -fn sub(a: u32, b: u32) void { - if (a - b != 3) unreachable; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.0.zig b/test/incremental/unwrap_error_union_simple_errors.0.zig deleted file mode 100644 index a1e2da9340d62b4e7401f5a1ccaba75b1832769a..0000000000000000000000000000000000000000 --- a/test/incremental/unwrap_error_union_simple_errors.0.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - maybeErr() catch unreachable; -} - -fn maybeErr() !void { - return; -} - -// run -// diff --git a/test/incremental/unwrap_error_union_simple_errors.1.zig b/test/incremental/unwrap_error_union_simple_errors.1.zig deleted file mode 100644 index 830ee629bce852b3957bff97e0d7d845d6d8dbee..0000000000000000000000000000000000000000 --- a/test/incremental/unwrap_error_union_simple_errors.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() void { - maybeErr() catch return; - unreachable; -} - -fn maybeErr() !void { - return error.NoWay; -} - -// run -// diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.0.zig b/test/incremental/x86_64-linux/hello_world_with_updates.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..960fae5e644fa67cb8f46decb7c774ae7a0719d1 --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.0.zig @@ -0,0 +1,5 @@ +// error +// output_mode=Exe +// target=x86_64-linux +// +// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.1.zig b/test/incremental/x86_64-linux/hello_world_with_updates.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..0f347b7f5069ccefb13bd680334cbba2a4beb4e7 --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.1.zig @@ -0,0 +1,5 @@ +pub export fn _start() noreturn {} + +// error +// +// :1:34: error: expected noreturn, found void diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.2.zig b/test/incremental/x86_64-linux/hello_world_with_updates.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..fcea1870ce59ef67264c3be650beafabbd5a97e3 --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.2.zig @@ -0,0 +1,32 @@ +pub export fn _start() noreturn { + print(); + + exit(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (14), + : "rcx", "r11", "memory" + ); + return; +} + +fn exit() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (231), + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.3.zig b/test/incremental/x86_64-linux/hello_world_with_updates.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..7812023372e14acc9c4c93441e913126d1e7de1d --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.3.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), + [arg3] "{rdx}" (14), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.4.zig b/test/incremental/x86_64-linux/hello_world_with_updates.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..cdf47012b8306d2a234871842bfe00da550522de --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.4.zig @@ -0,0 +1,20 @@ +pub fn main() void { + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), + [arg3] "{rdx}" (104), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/x86_64-linux/hello_world_with_updates.5.zig b/test/incremental/x86_64-linux/hello_world_with_updates.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..68c1e305f713135321cd2000bdd9b50dc2020c8e --- /dev/null +++ b/test/incremental/x86_64-linux/hello_world_with_updates.5.zig @@ -0,0 +1,22 @@ +pub fn main() void { + print(); + print(); +} + +fn print() void { + asm volatile ("syscall" + : + : [number] "{rax}" (1), + [arg1] "{rdi}" (1), + [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), + [arg3] "{rdx}" (104), + : "rcx", "r11", "memory" + ); + return; +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/x86_64-linux/inline_assembly.0.zig b/test/incremental/x86_64-linux/inline_assembly.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..e3c0f3badbb61fa8a53a63bcabb7b90edbe4657b --- /dev/null +++ b/test/incremental/x86_64-linux/inline_assembly.0.zig @@ -0,0 +1,16 @@ +pub fn main() void { + const number = 1234; + const x = asm volatile ("syscall" + : [o] "{rax}" (-> number), + : [number] "{rax}" (231), + [arg1] "{rdi}" (60), + : "rcx", "r11", "memory" + ); + _ = x; +} + +// error +// output_mode=Exe +// target=x86_64-linux +// +// :4:27: error: expected type, found comptime_int diff --git a/test/incremental/x86_64-linux/inline_assembly.1.zig b/test/incremental/x86_64-linux/inline_assembly.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..b35014b0f6b6afa26cd92e7496edbc70c2b90dbf --- /dev/null +++ b/test/incremental/x86_64-linux/inline_assembly.1.zig @@ -0,0 +1,15 @@ +const S = struct { + comptime { + asm volatile ( + \\zig_moment: + \\syscall + ); + } +}; +pub fn main() void { + _ = S; +} + +// error +// +// :3:13: error: volatile is meaningless on global assembly diff --git a/test/incremental/x86_64-linux/inline_assembly.2.zig b/test/incremental/x86_64-linux/inline_assembly.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..1695265ab4ebcbb6a2625bb9abdffb0d751eec07 --- /dev/null +++ b/test/incremental/x86_64-linux/inline_assembly.2.zig @@ -0,0 +1,12 @@ +pub fn main() void { + var bruh: u32 = 1; + asm ("" + : + : [bruh] "{rax}" (4) + : "memory" + ); +} + +// error +// +// :3:5: error: assembly expression with no output must be marked volatile diff --git a/test/incremental/x86_64-linux/inline_assembly.3.zig b/test/incremental/x86_64-linux/inline_assembly.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..765eaeb97eb2f8373afff7399051a2fca6269070 --- /dev/null +++ b/test/incremental/x86_64-linux/inline_assembly.3.zig @@ -0,0 +1,12 @@ +pub fn main() void {} +comptime { + asm ("" + : + : [bruh] "{rax}" (4) + : "memory" + ); +} + +// error +// +// :3:5: error: global assembly cannot have inputs, outputs, or clobbers diff --git a/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..ecba1c8133714f48d0423b98c9a213a057550ad1 --- /dev/null +++ b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.0.zig @@ -0,0 +1,13 @@ +pub export fn _start() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (60), // exit + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// target=x86_64-linux +// diff --git a/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..529acbcf38132bb09f0a47adc2a128ac7c7b7ac5 --- /dev/null +++ b/test/incremental/x86_64-linux/only_1_function_and_it_gets_updated.1.zig @@ -0,0 +1,12 @@ +pub export fn _start() noreturn { + asm volatile ("syscall" + : + : [number] "{rax}" (231), // exit_group + [arg1] "{rdi}" (0), + : "rcx", "r11", "memory" + ); + unreachable; +} + +// run +// diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.0.zig b/test/incremental/x86_64-macos/hello_world_with_updates.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..34440c4603e0c2164ad399efb03d59e4de9cf6ff --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.0.zig @@ -0,0 +1,5 @@ +// error +// output_mode=Exe +// target=x86_64-macos +// +// :109:9: error: struct 'tmp.tmp' has no member named 'main' diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.1.zig b/test/incremental/x86_64-macos/hello_world_with_updates.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..909fc9ccfbcb343f761414446c0ec4d52e98aeef --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.1.zig @@ -0,0 +1,5 @@ +pub export fn main() noreturn {} + +// error +// +// :1:32: error: expected noreturn, found void diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.2.zig b/test/incremental/x86_64-macos/hello_world_with_updates.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..fb8cb39eddf859f843ce61b068c0f6f8f9feb387 --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.2.zig @@ -0,0 +1,19 @@ +extern "c" fn write(usize, usize, usize) usize; +extern "c" fn exit(usize) noreturn; + +pub export fn main() noreturn { + print(); + + exit(0); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.3.zig b/test/incremental/x86_64-macos/hello_world_with_updates.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..f6e233886b0a7d616f92dd11ffb4232191c997de --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.3.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.4.zig b/test/incremental/x86_64-macos/hello_world_with_updates.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..f89cef73543ce1f3e51a4e0152c0a8c367edf537 --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.4.zig @@ -0,0 +1,22 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("Hello, World!\n"); + const len = 14; + _ = write(1, msg, len); +} + +// run +// +// Hello, World! +// Hello, World! +// Hello, World! +// Hello, World! +// diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.5.zig b/test/incremental/x86_64-macos/hello_world_with_updates.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..0d7f97578afe1274d1c8e3d356ce702992edca61 --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.5.zig @@ -0,0 +1,16 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// diff --git a/test/incremental/x86_64-macos/hello_world_with_updates.6.zig b/test/incremental/x86_64-macos/hello_world_with_updates.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..3ce2cb717639d663c2679dcdef2a4583c3c3f8ec --- /dev/null +++ b/test/incremental/x86_64-macos/hello_world_with_updates.6.zig @@ -0,0 +1,18 @@ +extern "c" fn write(usize, usize, usize) usize; + +pub fn main() void { + print(); + print(); +} + +fn print() void { + const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); + const len = 104; + _ = write(1, msg, len); +} + +// run +// +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +// What is up? This is a longer message that will force the data to be relocated in virtual address space. +//