diff --git a/test/cases/aarch64-linux/conditional_branches.0.zig b/test/cases/aarch64-linux/conditional_branches.0.zig deleted file mode 100644 index 28435b9d4a86940fb08eaf65bc8243a2488d4429..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-linux/conditional_branches.0.zig +++ /dev/null @@ -1,26 +0,0 @@ -pub fn main() void { - foo(123); -} - -fn foo(x: u64) void { - if (x > 42) { - print(); - } -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{x8}" (64), - [arg1] "{x0}" (1), - [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{x2}" ("Hello, World!\n".len), - : "memory", "cc" - ); -} - -// run -// target=aarch64-linux -// -// Hello, World! -// diff --git a/test/cases/aarch64-linux/conditional_branches.1.zig b/test/cases/aarch64-linux/conditional_branches.1.zig deleted file mode 100644 index e03758fcb7c99317c812e8ef06921fe5c43d4f19..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-linux/conditional_branches.1.zig +++ /dev/null @@ -1,25 +0,0 @@ -pub fn main() void { - foo(true); -} - -fn foo(x: bool) void { - if (x) { - print(); - } -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{x8}" (64), - [arg1] "{x0}" (1), - [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{x2}" ("Hello, World!\n".len), - : "memory", "cc" - ); -} - -// run -// -// Hello, World! -// diff --git a/test/cases/aarch64-linux/hello_world_with_updates.0.zig b/test/cases/aarch64-linux/hello_world_with_updates.0.zig deleted file mode 100644 index 7a87d74dc3063b0d16f4f12fa678a4d3e7e13953..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-linux/hello_world_with_updates.0.zig +++ /dev/null @@ -1,31 +0,0 @@ -pub export fn _start() noreturn { - print(); - exit(0); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{x8}" (64), - [arg1] "{x0}" (1), - [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{x2}" ("Hello, World!\n".len), - : "memory", "cc" - ); -} - -fn exit(ret: usize) noreturn { - asm volatile ("svc #0" - : - : [number] "{x8}" (93), - [arg1] "{x0}" (ret), - : "memory", "cc" - ); - unreachable; -} - -// run -// target=aarch64-linux -// -// Hello, World! -// diff --git a/test/cases/aarch64-linux/hello_world_with_updates.1.zig b/test/cases/aarch64-linux/hello_world_with_updates.1.zig deleted file mode 100644 index a5ca0d9926f62da4dcefb2ff2b30c902acbf1a38..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-linux/hello_world_with_updates.1.zig +++ /dev/null @@ -1,36 +0,0 @@ -pub export fn _start() noreturn { - print(); - print(); - print(); - print(); - exit(0); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{x8}" (64), - [arg1] "{x0}" (1), - [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{x2}" ("Hello, World!\n".len), - : "memory", "cc" - ); -} - -fn exit(ret: usize) noreturn { - asm volatile ("svc #0" - : - : [number] "{x8}" (93), - [arg1] "{x0}" (ret), - : "memory", "cc" - ); - unreachable; -} - -// run -// -// Hello, World! -// Hello, World! -// Hello, World! -// Hello, World! -// diff --git a/test/cases/aarch64-linux/hello_world_with_updates.2.zig b/test/cases/aarch64-linux/hello_world_with_updates.2.zig deleted file mode 100644 index 71f0f160bc6ba35df619c1875671515f7240ccf7..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-linux/hello_world_with_updates.2.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - print(); - print(); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{x8}" (64), - [arg1] "{x0}" (1), - [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{x2}" ("Hello, World!\n".len), - : "memory", "cc" - ); -} - -// run -// -// Hello, World! -// Hello, World! -// diff --git a/test/cases/aarch64-macos/hello_world_with_updates.0.zig b/test/cases/aarch64-macos/hello_world_with_updates.0.zig deleted file mode 100644 index f939a7fa712e2c175d5e1d120e2875f871b5a27c..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.0.zig +++ /dev/null @@ -1,5 +0,0 @@ -// error -// output_mode=Exe -// target=aarch64-macos -// -// :?:?: error: root struct of file 'tmp' has no member named 'main' diff --git a/test/cases/aarch64-macos/hello_world_with_updates.1.zig b/test/cases/aarch64-macos/hello_world_with_updates.1.zig deleted file mode 100644 index dcf18bbf87713e6dcaa556378643fc88664023da..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.1.zig +++ /dev/null @@ -1,6 +0,0 @@ -pub export fn main() noreturn {} - -// error -// -// :1:22: error: function declared 'noreturn' implicitly returns -// :1:32: note: control flow reaches end of body here diff --git a/test/cases/aarch64-macos/hello_world_with_updates.2.zig b/test/cases/aarch64-macos/hello_world_with_updates.2.zig deleted file mode 100644 index fb8cb39eddf859f843ce61b068c0f6f8f9feb387..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.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/cases/aarch64-macos/hello_world_with_updates.3.zig b/test/cases/aarch64-macos/hello_world_with_updates.3.zig deleted file mode 100644 index f6e233886b0a7d616f92dd11ffb4232191c997de..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.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/cases/aarch64-macos/hello_world_with_updates.4.zig b/test/cases/aarch64-macos/hello_world_with_updates.4.zig deleted file mode 100644 index f89cef73543ce1f3e51a4e0152c0a8c367edf537..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.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/cases/aarch64-macos/hello_world_with_updates.5.zig b/test/cases/aarch64-macos/hello_world_with_updates.5.zig deleted file mode 100644 index 0d7f97578afe1274d1c8e3d356ce702992edca61..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.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/cases/aarch64-macos/hello_world_with_updates.6.zig b/test/cases/aarch64-macos/hello_world_with_updates.6.zig deleted file mode 100644 index 3ce2cb717639d663c2679dcdef2a4583c3c3f8ec..0000000000000000000000000000000000000000 --- a/test/cases/aarch64-macos/hello_world_with_updates.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/cases/arithmetic_operations.0.zig b/test/cases/arithmetic_operations.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..405c19d86aa47055da5fcab118a3a7b42a94e7b5 --- /dev/null +++ b/test/cases/arithmetic_operations.0.zig @@ -0,0 +1,17 @@ +const std = @import("std"); + +pub fn main() void { + print(2, 4); + print(1, 7); +} + +fn print(a: u32, b: u32) void { + const str = "123456789"; + const len = a + b; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// target=x86_64-linux,x86_64-macos +// +// 12345612345678 diff --git a/test/cases/arithmetic_operations.1.zig b/test/cases/arithmetic_operations.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..ba2520abe9c8c97c140aad002b046ac10cdc7da0 --- /dev/null +++ b/test/cases/arithmetic_operations.1.zig @@ -0,0 +1,16 @@ +const std = @import("std"); + +pub fn main() void { + print(10, 5); + print(4, 3); +} + +fn print(a: u32, b: u32) void { + const str = "123456789"; + const len = a - b; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// +// 123451 diff --git a/test/cases/arithmetic_operations.2.zig b/test/cases/arithmetic_operations.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..be4ec466f18dadab06cbdd4e86785e6886ed5d55 --- /dev/null +++ b/test/cases/arithmetic_operations.2.zig @@ -0,0 +1,16 @@ +const std = @import("std"); + +pub fn main() void { + print(8, 9); + print(3, 7); +} + +fn print(a: u32, b: u32) void { + const str = "123456789"; + const len = a & b; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// +// 12345678123 diff --git a/test/cases/arithmetic_operations.3.zig b/test/cases/arithmetic_operations.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..b939950730404b33867668b45f0dc087f49309a6 --- /dev/null +++ b/test/cases/arithmetic_operations.3.zig @@ -0,0 +1,16 @@ +const std = @import("std"); + +pub fn main() void { + print(4, 2); + print(3, 7); +} + +fn print(a: u32, b: u32) void { + const str = "123456789"; + const len = a | b; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// +// 1234561234567 diff --git a/test/cases/arithmetic_operations.4.zig b/test/cases/arithmetic_operations.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..50bf0df0ce530f6a861a00247ea80f57279326ab --- /dev/null +++ b/test/cases/arithmetic_operations.4.zig @@ -0,0 +1,16 @@ +const std = @import("std"); + +pub fn main() void { + print(42, 42); + print(3, 5); +} + +fn print(a: u32, b: u32) void { + const str = "123456789"; + const len = a ^ b; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// +// 123456 diff --git a/test/cases/arithmetic_operations.5.zig b/test/cases/arithmetic_operations.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..b1c18ca7da2ffed288f42f414fc64b42e6e552be --- /dev/null +++ b/test/cases/arithmetic_operations.5.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var x: u32 = 1; + assert(x << 1 == 2); + + x <<= 1; + assert(x << 2 == 8); + assert(x << 3 == 16); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/arithmetic_operations.6.zig b/test/cases/arithmetic_operations.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..e03731173c613aa1f3aaf5b9dd114e076eac6e7c --- /dev/null +++ b/test/cases/arithmetic_operations.6.zig @@ -0,0 +1,21 @@ +pub fn main() void { + var a: u32 = 1024; + assert(a >> 1 == 512); + + a >>= 1; + assert(a >> 2 == 128); + assert(a >> 3 == 64); + assert(a >> 4 == 32); + assert(a >> 5 == 16); + assert(a >> 6 == 8); + assert(a >> 7 == 4); + assert(a >> 8 == 2); + assert(a >> 9 == 1); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/arm-linux/arithmetic_operations.0.zig b/test/cases/arm-linux/arithmetic_operations.0.zig deleted file mode 100644 index 51a2dbd700ff528ea70db8cac4f4a3faf0605b1a..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.0.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - print(2, 4); - print(1, 7); -} - -fn print(a: u32, b: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (a + b), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("123456789")), - : "memory" - ); - return; -} - -// run -// target=arm-linux -// -// 12345612345678 diff --git a/test/cases/arm-linux/arithmetic_operations.1.zig b/test/cases/arm-linux/arithmetic_operations.1.zig deleted file mode 100644 index 1e3793ed38f2cf4e554de59233f13fbcccc542c7..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.1.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(10, 5); - print(4, 3); -} - -fn print(a: u32, b: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (a - b), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("123456789")), - : "memory" - ); - return; -} - -// run -// -// 123451 diff --git a/test/cases/arm-linux/arithmetic_operations.2.zig b/test/cases/arm-linux/arithmetic_operations.2.zig deleted file mode 100644 index 6b81e62198b665f8d3928069425df20bc79812bb..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.2.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(8, 9); - print(3, 7); -} - -fn print(a: u32, b: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (a & b), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("123456789")), - : "memory" - ); - return; -} - -// run -// -// 12345678123 diff --git a/test/cases/arm-linux/arithmetic_operations.3.zig b/test/cases/arm-linux/arithmetic_operations.3.zig deleted file mode 100644 index 23089127f53aa331ed08030caa524b9627fdba2e..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.3.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(4, 2); - print(3, 7); -} - -fn print(a: u32, b: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (a | b), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("123456789")), - : "memory" - ); - return; -} - -// run -// -// 1234561234567 diff --git a/test/cases/arm-linux/arithmetic_operations.4.zig b/test/cases/arm-linux/arithmetic_operations.4.zig deleted file mode 100644 index ce5133c4653da4568d1bdae16edf56fa418e4fb1..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.4.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - print(42, 42); - print(3, 5); -} - -fn print(a: u32, b: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (a ^ b), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("123456789")), - : "memory" - ); - return; -} - -// run -// -// 123456 diff --git a/test/cases/arm-linux/arithmetic_operations.5.zig b/test/cases/arm-linux/arithmetic_operations.5.zig deleted file mode 100644 index b1c18ca7da2ffed288f42f414fc64b42e6e552be..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.5.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - var x: u32 = 1; - assert(x << 1 == 2); - - x <<= 1; - assert(x << 2 == 8); - assert(x << 3 == 16); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/arm-linux/arithmetic_operations.6.zig b/test/cases/arm-linux/arithmetic_operations.6.zig deleted file mode 100644 index e03731173c613aa1f3aaf5b9dd114e076eac6e7c..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/arithmetic_operations.6.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - var a: u32 = 1024; - assert(a >> 1 == 512); - - a >>= 1; - assert(a >> 2 == 128); - assert(a >> 3 == 64); - assert(a >> 4 == 32); - assert(a >> 5 == 16); - assert(a >> 6 == 8); - assert(a >> 7 == 4); - assert(a >> 8 == 2); - assert(a >> 9 == 1); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/arm-linux/errors.0.zig b/test/cases/arm-linux/errors.0.zig deleted file mode 100644 index 3e20d1d9737652b33f030e6f4b51abe819e222ec..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/errors.0.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - foo() catch print(); -} - -fn foo() anyerror!void {} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{r2}" ("Hello, World!\n".len), - : "memory" - ); - return; -} - -// run -// target=arm-linux -// diff --git a/test/cases/arm-linux/errors.1.zig b/test/cases/arm-linux/errors.1.zig deleted file mode 100644 index 43fbb12675581ef874e92d08f360ee68263e0e4f..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/errors.1.zig +++ /dev/null @@ -1,24 +0,0 @@ -pub fn main() void { - foo() catch print(); -} - -fn foo() anyerror!void { - return error.Test; -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{r2}" ("Hello, World!\n".len), - : "memory" - ); - return; -} - -// run -// -// Hello, World! -// diff --git a/test/cases/arm-linux/errors.2.zig b/test/cases/arm-linux/errors.2.zig deleted file mode 100644 index a1b9aef97dc4396e8e89bf1394592f260cce3743..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/errors.2.zig +++ /dev/null @@ -1,27 +0,0 @@ -pub fn main() void { - foo() catch |err| { - assert(err == error.Foo); - assert(err != error.Bar); - assert(err != error.Baz); - }; - bar() catch |err| { - assert(err != error.Foo); - assert(err == error.Bar); - assert(err != error.Baz); - }; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -fn foo() anyerror!void { - return error.Foo; -} - -fn bar() anyerror!void { - return error.Bar; -} - -// run -// diff --git a/test/cases/arm-linux/errors.3.zig b/test/cases/arm-linux/errors.3.zig deleted file mode 100644 index 390696fcfcb261ea6c8383d13c0bec8c9e85c445..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/errors.3.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() void { - foo() catch unreachable; -} - -fn foo() anyerror!void { - try bar(); -} - -fn bar() anyerror!void {} - -// run -// diff --git a/test/cases/arm-linux/function_pointers.zig b/test/cases/arm-linux/function_pointers.zig deleted file mode 100644 index 0ef5df6745d804633632e894b586811e0636216d..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/function_pointers.zig +++ /dev/null @@ -1,44 +0,0 @@ -const PrintFn = *const fn () void; - -pub fn main() void { - var printFn: PrintFn = stopSayingThat; - var i: u32 = 0; - while (i < 4) : (i += 1) printFn(); - - printFn = moveEveryZig; - printFn(); -} - -fn stopSayingThat() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")), - [arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len), - : "memory" - ); - return; -} - -fn moveEveryZig() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")), - [arg3] "{r2}" ("All your codebase are belong to us\n".len), - : "memory" - ); - return; -} - -// run -// target=arm-linux -// -// Hello, my name is Inigo Montoya; you killed my father, prepare to die. -// Hello, my name is Inigo Montoya; you killed my father, prepare to die. -// Hello, my name is Inigo Montoya; you killed my father, prepare to die. -// Hello, my name is Inigo Montoya; you killed my father, prepare to die. -// All your codebase are belong to us -// diff --git a/test/cases/arm-linux/hello_world_with_updates.0.zig b/test/cases/arm-linux/hello_world_with_updates.0.zig deleted file mode 100644 index 4ffdc2ae0f6d372aa809c590737536d468cabae1..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/hello_world_with_updates.0.zig +++ /dev/null @@ -1,32 +0,0 @@ -pub export fn _start() noreturn { - print(); - exit(); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{r2}" (14), - : "memory" - ); - return; -} - -fn exit() noreturn { - asm volatile ("svc #0" - : - : [number] "{r7}" (1), - [arg1] "{r0}" (0), - : "memory" - ); - unreachable; -} - -// run -// target=arm-linux -// -// Hello, World! -// diff --git a/test/cases/arm-linux/hello_world_with_updates.1.zig b/test/cases/arm-linux/hello_world_with_updates.1.zig deleted file mode 100644 index 8372d757ad8e448ab76cb5a2608e25307ffab904..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/hello_world_with_updates.1.zig +++ /dev/null @@ -1,37 +0,0 @@ -pub export fn _start() noreturn { - print(); - print(); - print(); - print(); - exit(); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{r2}" (14), - : "memory" - ); - return; -} - -fn exit() noreturn { - asm volatile ("svc #0" - : - : [number] "{r7}" (1), - [arg1] "{r0}" (0), - : "memory" - ); - unreachable; -} - -// run -// -// Hello, World! -// Hello, World! -// Hello, World! -// Hello, World! -// diff --git a/test/cases/arm-linux/hello_world_with_updates.2.zig b/test/cases/arm-linux/hello_world_with_updates.2.zig deleted file mode 100644 index 0b97bf2360149f324a7314208e43cb31b74a39ee..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/hello_world_with_updates.2.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - print(); - print(); -} - -fn print() void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - [arg3] "{r2}" (14), - : "memory" - ); - return; -} - -// run -// -// Hello, World! -// Hello, World! -// diff --git a/test/cases/arm-linux/parameters_and_return_values.0.zig b/test/cases/arm-linux/parameters_and_return_values.0.zig deleted file mode 100644 index 6a306d802c2ad01609c73cc79cf6c81d9c6b7b07..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/parameters_and_return_values.0.zig +++ /dev/null @@ -1,28 +0,0 @@ -pub fn main() void { - print(id(14)); -} - -fn id(x: u32) u32 { - return x; -} - -// TODO: The parameters to the asm statement in print() had to -// be in a specific order because otherwise the write to r0 -// would overwrite the len parameter which resides in r0 -fn print(len: u32) void { - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg3] "{r2}" (len), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), - : "memory" - ); - return; -} - -// run -// target=arm-linux -// -// Hello, World! -// diff --git a/test/cases/arm-linux/parameters_and_return_values.1.zig b/test/cases/arm-linux/parameters_and_return_values.1.zig deleted file mode 100644 index f2bc35d22ec6a7ac0b203bf257d10805815dc931..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/parameters_and_return_values.1.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub fn main() void { - assert(add(1, 2, 3, 4, 5, 6) == 21); -} - -fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { - return a + b + c + d + e + f; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/arm-linux/print_u32s.zig b/test/cases/arm-linux/print_u32s.zig deleted file mode 100644 index 92fad75ddf0a1f75e5d3c0ac6d04052166771cde..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/print_u32s.zig +++ /dev/null @@ -1,40 +0,0 @@ -pub fn main() void { - printNumberHex(0x00000000); - printNumberHex(0xaaaaaaaa); - printNumberHex(0xdeadbeef); - printNumberHex(0x31415926); -} - -fn printNumberHex(x: u32) void { - var i: u5 = 28; - while (true) : (i -= 4) { - const digit = (x >> i) & 0xf; - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit), - [arg3] "{r2}" (1), - : "memory" - ); - - if (i == 0) break; - } - asm volatile ("svc #0" - : - : [number] "{r7}" (4), - [arg1] "{r0}" (1), - [arg2] "{r1}" (@ptrToInt("\n")), - [arg3] "{r2}" (1), - : "memory" - ); -} - -// run -// target=arm-linux -// -// 00000000 -// aaaaaaaa -// deadbeef -// 31415926 -// diff --git a/test/cases/arm-linux/spilling_registers.0.zig b/test/cases/arm-linux/spilling_registers.0.zig deleted file mode 100644 index ac74e071ad70f03a2d90f76c8d9cd9ca66f76095..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/spilling_registers.0.zig +++ /dev/null @@ -1,38 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 791); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = k + c; // 217 - const m = l + d; // 227 - const n = m + e; // 241 - const o = n + f; // 265 - const p = o + g; // 303 - const q = p + h; // 365 - const r = q + i; // 465 - const s = r + j; // 575 - const t = s + k; // 785 - break :blk t; - }; - const y = x + a; // 788 - const z = y + a; // 791 - return z; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// target=arm-linux -// diff --git a/test/cases/arm-linux/spilling_registers.1.zig b/test/cases/arm-linux/spilling_registers.1.zig deleted file mode 100644 index f401a5d7b7d1f29a9dc628315cff7e5b4e85d21c..0000000000000000000000000000000000000000 --- a/test/cases/arm-linux/spilling_registers.1.zig +++ /dev/null @@ -1,37 +0,0 @@ -pub fn main() void { - assert(addMul(3, 4) == 357747496); -} - -fn addMul(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = k + c; // 217 - const m = l * d; // 2170 - const n = m + e; // 2184 - const o = n * f; // 52416 - const p = o + g; // 52454 - const q = p * h; // 3252148 - const r = q + i; // 3252248 - const s = r * j; // 357747280 - const t = s + k; // 357747490 - break :blk t; - }; - const y = x + a; // 357747493 - const z = y + a; // 357747496 - return z; -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -// run -// diff --git a/test/cases/assert_function.0.zig b/test/cases/assert_function.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..7a832e522b32bcdd7c01c712db81d38df913c2a6 --- /dev/null +++ b/test/cases/assert_function.0.zig @@ -0,0 +1,15 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 7); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// target=x86_64-macos,x86_64-linux +// link_libc=true diff --git a/test/cases/assert_function.1.zig b/test/cases/assert_function.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..ac2df25d8556c661b48a9382d200283073d5d00b --- /dev/null +++ b/test/cases/assert_function.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + assert(e == 14); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.10.zig b/test/cases/assert_function.10.zig new file mode 100644 index 0000000000000000000000000000000000000000..b3f1610cd62b71553f20959ef9cf4cec51d8f498 --- /dev/null +++ b/test/cases/assert_function.10.zig @@ -0,0 +1,27 @@ +pub fn main() void { + assert(add(3, 4) == 116); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + break :blk j; + }; + const y = x + a; // 113 + const z = y + a; // 116 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.11.zig b/test/cases/assert_function.11.zig new file mode 100644 index 0000000000000000000000000000000000000000..d64130a6775b250ca18a5900e912391dc732a7f7 --- /dev/null +++ b/test/cases/assert_function.11.zig @@ -0,0 +1,66 @@ +pub fn main() void { + assert(add(3, 4) == 1221); + assert(mul(3, 4) == 21609); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = j + k; // 320 + const m = l + c; // 327 + const n = m + d; // 337 + const o = n + e; // 351 + const p = o + f; // 375 + const q = p + g; // 413 + const r = q + h; // 475 + const s = r + i; // 575 + const t = s + j; // 685 + const u = t + k; // 895 + const v = u + l; // 1215 + break :blk v; + }; + const y = x + a; // 1218 + const z = y + a; // 1221 + return z; +} + +fn mul(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a * a * a * a; // 81 + const d = a * a * a * b; // 108 + const e = a * a * b * a; // 108 + const f = a * a * b * b; // 144 + const g = a * b * a * a; // 108 + const h = a * b * a * b; // 144 + const i = a * b * b * a; // 144 + const j = a * b * b * b; // 192 + const k = b * a * a * a; // 108 + const l = b * a * a * b; // 144 + const m = b * a * b * a; // 144 + const n = b * a * b * b; // 192 + const o = b * b * a * a; // 144 + const p = b * b * a * b; // 192 + const q = b * b * b * a; // 192 + const r = b * b * b * b; // 256 + const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 + break :blk s; + }; + const y = x * a; // 7203 + const z = y * a; // 21609 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.12.zig b/test/cases/assert_function.12.zig new file mode 100644 index 0000000000000000000000000000000000000000..4f64c1e0626879a2004d66080292dc7cf962065d --- /dev/null +++ b/test/cases/assert_function.12.zig @@ -0,0 +1,47 @@ +pub fn main() void { + assert(add(3, 4) == 791); + assert(add(4, 3) == 79); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = if (a < b) blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + } else blk: { + const t = b + b + a; // 10 + const c = a + t; // 14 + const d = c + t; // 24 + const e = d + t; // 34 + const f = e + t; // 44 + const g = f + t; // 54 + const h = c + g; // 68 + break :blk h + b; // 71 + }; + const y = x + a; // 788, 75 + const z = y + a; // 791, 79 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.13.zig b/test/cases/assert_function.13.zig new file mode 100644 index 0000000000000000000000000000000000000000..240abf0108dbe8c08040533524872e543fd6d621 --- /dev/null +++ b/test/cases/assert_function.13.zig @@ -0,0 +1,19 @@ +pub fn main() void { + const ignore = + \\ cool thx + \\ + ; + _ = ignore; + add('ぁ', '\x03'); +} + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.14.zig b/test/cases/assert_function.14.zig new file mode 100644 index 0000000000000000000000000000000000000000..d25100dccee2bda1f615c2d870ee477c1252bed3 --- /dev/null +++ b/test/cases/assert_function.14.zig @@ -0,0 +1,17 @@ +pub fn main() void { + add(aa, bb); +} + +const aa = 'ぁ'; +const bb = '\x03'; + +fn add(a: u32, b: u32) void { + assert(a + b == 12356); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.15.zig b/test/cases/assert_function.15.zig new file mode 100644 index 0000000000000000000000000000000000000000..33ae1ed5af1279b74f089003e7b9665b55c2489b --- /dev/null +++ b/test/cases/assert_function.15.zig @@ -0,0 +1,10 @@ +pub fn main() void { + assert("hello"[0] == 'h'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.16.zig b/test/cases/assert_function.16.zig new file mode 100644 index 0000000000000000000000000000000000000000..eef113642324434c4af1723aac512a57192ce726 --- /dev/null +++ b/test/cases/assert_function.16.zig @@ -0,0 +1,11 @@ +const hello = "hello".*; +pub fn main() void { + assert(hello[1] == 'e'); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.17.zig b/test/cases/assert_function.17.zig new file mode 100644 index 0000000000000000000000000000000000000000..ac9dce3079f6444476afd65757675726390946cf --- /dev/null +++ b/test/cases/assert_function.17.zig @@ -0,0 +1,11 @@ +pub fn main() void { + var i: u64 = 0xFFEEDDCCBBAA9988; + assert(i == 0xFFEEDDCCBBAA9988); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.18.zig b/test/cases/assert_function.18.zig new file mode 100644 index 0000000000000000000000000000000000000000..5f05e4ae70141f78452b88c2872ce3685649be2d --- /dev/null +++ b/test/cases/assert_function.18.zig @@ -0,0 +1,20 @@ +const builtin = @import("builtin"); + +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + for ("hello") |_| print(); +} + +fn print() void { + _ = write(1, @ptrToInt("hello\n"), 6); +} + +// run +// +// hello +// hello +// hello +// hello +// hello +// diff --git a/test/cases/assert_function.2.zig b/test/cases/assert_function.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..8c1c510486185f4116841577473c901e13528283 --- /dev/null +++ b/test/cases/assert_function.2.zig @@ -0,0 +1,21 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + assert(i == 100); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.3.zig b/test/cases/assert_function.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..a6829f8e0239f8c01f0a1e4e1cf42e9ed035176b --- /dev/null +++ b/test/cases/assert_function.3.zig @@ -0,0 +1,22 @@ +pub fn main() void { + add(3, 4); +} + +fn add(a: u32, b: u32) void { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + assert(j == 110); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.4.zig b/test/cases/assert_function.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..69df4354c3eb8d72d4c91b226fbf4b4c0eddedaf --- /dev/null +++ b/test/cases/assert_function.4.zig @@ -0,0 +1,15 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + return a + b; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.5.zig b/test/cases/assert_function.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..89f3f7df4fd3f42da6650c27dff3c8160b281860 --- /dev/null +++ b/test/cases/assert_function.5.zig @@ -0,0 +1,19 @@ +pub fn main() void { + assert(add(3, 4) == 7); + assert(add(20, 10) == 30); +} + +fn add(a: u32, b: u32) u32 { + var x: u32 = undefined; + x = 0; + x += a; + x += b; + return x; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/assert_function.6.zig b/test/cases/assert_function.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..1b1b75e68ea72902208bd0889c38202922b89a51 --- /dev/null +++ b/test/cases/assert_function.6.zig @@ -0,0 +1,9 @@ +pub fn main() void { + const a: u32 = 2; + const b: ?u32 = a; + const c = b.?; + if (c != 2) unreachable; +} + +// run +// diff --git a/test/cases/assert_function.7.zig b/test/cases/assert_function.7.zig new file mode 100644 index 0000000000000000000000000000000000000000..0004435db6f3a703918b73ff72b0f04511a0370b --- /dev/null +++ b/test/cases/assert_function.7.zig @@ -0,0 +1,23 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + _ = write(1, @ptrToInt("hello\n"), 6); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// +// hello +// hello +// hello +// hello +// diff --git a/test/cases/assert_function.8.zig b/test/cases/assert_function.8.zig new file mode 100644 index 0000000000000000000000000000000000000000..3e8e247dacf8410b69f9a8669ed459661ef78f8c --- /dev/null +++ b/test/cases/assert_function.8.zig @@ -0,0 +1,20 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + var i: u32 = 0; + inline while (i < 4) : (i += 1) print(); + assert(i == 4); +} + +fn print() void { + _ = write(1, @ptrToInt("hello\n"), 6); +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// error +// +// :5:21: error: unable to resolve comptime value +// :5:21: note: condition in comptime branch must be comptime-known diff --git a/test/cases/assert_function.9.zig b/test/cases/assert_function.9.zig new file mode 100644 index 0000000000000000000000000000000000000000..c754bb771133d8b3a595ec9fe46c48c4c6408e61 --- /dev/null +++ b/test/cases/assert_function.9.zig @@ -0,0 +1,22 @@ +pub fn main() void { + assert(add(3, 4) == 20); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + break :blk e; + }; + const y = x + a; // 17 + const z = y + a; // 20 + return z; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/break_continue.0.zig b/test/cases/break_continue.0.zig index ac0abdb52dadc98760d9ac2d1b466b185e8bd90d..6684bcb0d09e1d48c65bbfee75254d27833042cb 100644 --- a/test/cases/break_continue.0.zig +++ b/test/cases/break_continue.0.zig @@ -5,5 +5,5 @@ pub fn main() void { } // run -// target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos +// target=x86_64-linux,x86_64-macos // diff --git a/test/cases/comptime_var.0.zig b/test/cases/comptime_var.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..14fb074c76ab2c079565e96a6b2847640115a3fb --- /dev/null +++ b/test/cases/comptime_var.0.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + if (a == 0) b = 3; +} + +// error +// output_mode=Exe +// target=x86_64-macos,x86_64-linux +// link_libc=true +// +// :4:19: error: store to comptime variable depends on runtime condition +// :4:11: note: runtime condition here diff --git a/test/cases/comptime_var.1.zig b/test/cases/comptime_var.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..054d69250c38b5c2faba39e67db1b203d7b6eec7 --- /dev/null +++ b/test/cases/comptime_var.1.zig @@ -0,0 +1,13 @@ +pub fn main() void { + var a: u32 = 0; + comptime var b: u32 = 0; + switch (a) { + 0 => {}, + else => b = 3, + } +} + +// error +// +// :6:19: error: store to comptime variable depends on runtime condition +// :4:13: note: runtime condition here diff --git a/test/cases/comptime_var.2.zig b/test/cases/comptime_var.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..7c99aba6258476efeb21485f06808a5adab44062 --- /dev/null +++ b/test/cases/comptime_var.2.zig @@ -0,0 +1,17 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + comptime var len: u32 = 5; + print(len); + len += 9; + print(len); +} + +fn print(len: usize) void { + _ = write(1, @ptrToInt("Hello, World!\n"), len); +} + +// run +// +// HelloHello, World! +// diff --git a/test/cases/comptime_var.3.zig b/test/cases/comptime_var.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..5d25d6556e4f378d4288acda9ceffcb19397230f --- /dev/null +++ b/test/cases/comptime_var.3.zig @@ -0,0 +1,10 @@ +comptime { + var x: i32 = 1; + x += 1; + if (x != 1) unreachable; +} +pub fn main() void {} + +// error +// +// :4:17: error: reached unreachable code diff --git a/test/cases/comptime_var.4.zig b/test/cases/comptime_var.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..74da6ef448edd5534b49b1f850673863b4188b99 --- /dev/null +++ b/test/cases/comptime_var.4.zig @@ -0,0 +1,9 @@ +pub fn main() void { + comptime var i: u64 = 0; + while (i < 5) : (i += 1) {} +} + +// error +// +// :3:24: error: cannot store to comptime variable in non-inline loop +// :3:5: note: non-inline loop here diff --git a/test/cases/comptime_var.5.zig b/test/cases/comptime_var.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..76a06f3d4b5931e8fd23271dcc593e07ff414a7f --- /dev/null +++ b/test/cases/comptime_var.5.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var a: u32 = 0; + if (a == 0) { + comptime var b: u32 = 0; + b = 1; + } +} +comptime { + var x: i32 = 1; + x += 1; + if (x != 2) unreachable; +} + +// run +// diff --git a/test/cases/comptime_var.6.zig b/test/cases/comptime_var.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..3b655e381e69f75999dcc8df231f51a3a457e55b --- /dev/null +++ b/test/cases/comptime_var.6.zig @@ -0,0 +1,15 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + comptime var i: u64 = 2; + inline while (i < 6) : (i += 1) { + print(i); + } +} +fn print(len: usize) void { + _ = write(1, @ptrToInt("Hello"), len); +} + +// run +// +// HeHelHellHello diff --git a/test/cases/conditional_branches.0.zig b/test/cases/conditional_branches.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..61c9fdd50ea2f2c40f3a492c3d5baa93c556ab89 --- /dev/null +++ b/test/cases/conditional_branches.0.zig @@ -0,0 +1,23 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + foo(123); +} + +fn foo(x: u64) void { + if (x > 42) { + print(); + } +} + +fn print() void { + const str = "Hello, World!\n"; + _ = write(1, @ptrToInt(str.ptr), ptr.len); +} + +// run +// target=x86_64-linux,x86_64-macos +// link_libc=true +// +// Hello, World! +// diff --git a/test/cases/conditional_branches.1.zig b/test/cases/conditional_branches.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..2668133a7c9c2a9deba907954f28708ee9d6b099 --- /dev/null +++ b/test/cases/conditional_branches.1.zig @@ -0,0 +1,25 @@ +extern "c" fn write(c_int, usize, usize) usize; + +pub fn main() void { + foo(true); +} + +fn foo(x: bool) void { + if (x) { + print(); + print(); + } else { + print(); + } +} + +fn print() void { + const str = "Hello, World!\n"; + _ = write(1, @ptrToInt(str.ptr), ptr.len); +} + +// run +// +// Hello, World! +// Hello, World! +// diff --git a/test/cases/conditions.0.zig b/test/cases/conditions.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..1167ea85a4413757b8d481b1d672703b2a2ebd2f --- /dev/null +++ b/test/cases/conditions.0.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i > @as(u8, 4)) { + i += 10; + } + return i - 15; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/conditions.1.zig b/test/cases/conditions.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..f9f03808b97a134f78276875979f483e8ad317e5 --- /dev/null +++ b/test/cases/conditions.1.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i < @as(u8, 4)) { + i += 10; + } else { + i = 2; + } + return i - 2; +} + +// run +// diff --git a/test/cases/conditions.2.zig b/test/cases/conditions.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..a80ead9ea54084317c55da133d91bf72f305909f --- /dev/null +++ b/test/cases/conditions.2.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 5; + if (i < @as(u8, 4)) { + i += 10; + } else if (i == @as(u8, 5)) { + i = 20; + } + return i - 20; +} + +// run +// diff --git a/test/cases/conditions.3.zig b/test/cases/conditions.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..bd016a47f3c78ec39512ad91d0cd373f35a8bed2 --- /dev/null +++ b/test/cases/conditions.3.zig @@ -0,0 +1,16 @@ +pub fn main() u8 { + var i: u8 = 11; + if (i < @as(u8, 4)) { + i += 10; + } else { + if (i > @as(u8, 10)) { + i += 20; + } else { + i = 20; + } + } + return i - 31; +} + +// run +// diff --git a/test/cases/conditions.4.zig b/test/cases/conditions.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..e1bd9ce0f7b6b397c997f416143b0eac10ac7551 --- /dev/null +++ b/test/cases/conditions.4.zig @@ -0,0 +1,15 @@ +pub fn main() void { + assert(foo(true) != @as(i32, 30)); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + const x = if (ok) @as(i32, 20) else @as(i32, 10); + return x; +} + +// run +// diff --git a/test/cases/conditions.5.zig b/test/cases/conditions.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..2d5ba338c7aea87a6f059d6f119bd1e0f7641793 --- /dev/null +++ b/test/cases/conditions.5.zig @@ -0,0 +1,20 @@ +pub fn main() void { + assert(foo(false) == @as(i32, 20)); + assert(foo(true) == @as(i32, 30)); +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo(ok: bool) i32 { + const val: i32 = blk: { + var x: i32 = 1; + if (!ok) break :blk x + @as(i32, 9); + break :blk x + @as(i32, 19); + }; + return val + 10; +} + +// run +// diff --git a/test/cases/error_unions.0.zig b/test/cases/error_unions.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..355698e4b66b7e43c16c1c0b4c92b9161f1c9a11 --- /dev/null +++ b/test/cases/error_unions.0.zig @@ -0,0 +1,15 @@ +pub fn main() void { + var e1 = error.Foo; + var e2 = error.Bar; + assert(e1 != e2); + assert(e1 == error.Foo); + assert(e2 == error.Bar); +} + +fn assert(b: bool) void { + if (!b) unreachable; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/error_unions.1.zig b/test/cases/error_unions.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..526e1a110d4c74415d9c3036ae99b828efd133c7 --- /dev/null +++ b/test/cases/error_unions.1.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var e: anyerror!u8 = 5; + const i = e catch 10; + return i - 5; +} + +// run +// diff --git a/test/cases/error_unions.2.zig b/test/cases/error_unions.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..b66c7d78c073bb0ef4cd4365fed5873fb66901af --- /dev/null +++ b/test/cases/error_unions.2.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var e: anyerror!u8 = error.Foo; + const i = e catch 10; + return i - 10; +} + +// run +// diff --git a/test/cases/error_unions.3.zig b/test/cases/error_unions.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..d37f826272dc32f990891837ed1a1a202a81fbd4 --- /dev/null +++ b/test/cases/error_unions.3.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 69; + return i - 5; +} + +fn foo() anyerror!u8 { + return 5; +} + +// run +// diff --git a/test/cases/error_unions.4.zig b/test/cases/error_unions.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..bbc8dd34da3b637871424a45678b5f5c5f67620c --- /dev/null +++ b/test/cases/error_unions.4.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 69; + return i - 69; +} + +fn foo() anyerror!u8 { + return error.Bruh; +} + +// run +// diff --git a/test/cases/error_unions.5.zig b/test/cases/error_unions.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..96d52d1de1f3a3eb31741f0bfdd8f8791f92e232 --- /dev/null +++ b/test/cases/error_unions.5.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var e = foo(); + const i = e catch 42; + return i - 42; +} + +fn foo() anyerror!u8 { + return error.Dab; +} + +// run +// diff --git a/test/cases/errors.0.zig b/test/cases/errors.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..5e6940ac3e80e56fbcdd9ee84e45fe4d5862e6b0 --- /dev/null +++ b/test/cases/errors.0.zig @@ -0,0 +1,15 @@ +const std = @import("std"); + +pub fn main() void { + foo() catch print(); +} + +fn foo() anyerror!void {} + +fn print() void { + _ = std.os.write(1, "Hello, World!\n") catch {}; +} + +// run +// target=x86_64-macos +// diff --git a/test/cases/errors.1.zig b/test/cases/errors.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..5f9582df8a1e9fd2331c1c4aaf1a5792f7bef49e --- /dev/null +++ b/test/cases/errors.1.zig @@ -0,0 +1,18 @@ +const std = @import("std"); + +pub fn main() void { + foo() catch print(); +} + +fn foo() anyerror!void { + return error.Test; +} + +fn print() void { + _ = std.os.write(1, "Hello, World!\n") catch {}; +} + +// run +// +// Hello, World! +// diff --git a/test/cases/errors.2.zig b/test/cases/errors.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..a1b9aef97dc4396e8e89bf1394592f260cce3743 --- /dev/null +++ b/test/cases/errors.2.zig @@ -0,0 +1,27 @@ +pub fn main() void { + foo() catch |err| { + assert(err == error.Foo); + assert(err != error.Bar); + assert(err != error.Baz); + }; + bar() catch |err| { + assert(err != error.Foo); + assert(err == error.Bar); + assert(err != error.Baz); + }; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +fn foo() anyerror!void { + return error.Foo; +} + +fn bar() anyerror!void { + return error.Bar; +} + +// run +// diff --git a/test/cases/errors.3.zig b/test/cases/errors.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..390696fcfcb261ea6c8383d13c0bec8c9e85c445 --- /dev/null +++ b/test/cases/errors.3.zig @@ -0,0 +1,12 @@ +pub fn main() void { + foo() catch unreachable; +} + +fn foo() anyerror!void { + try bar(); +} + +fn bar() anyerror!void {} + +// run +// diff --git a/test/cases/exit.zig b/test/cases/exit.zig new file mode 100644 index 0000000000000000000000000000000000000000..23d17afe1120671e89b5700b8261f1977000692e --- /dev/null +++ b/test/cases/exit.zig @@ -0,0 +1,5 @@ +pub fn main() void {} + +// run +// target=x86_64-linux,x86_64-macos,x86_64-windows,x86_64-plan9 +// diff --git a/test/cases/function_pointers.zig b/test/cases/function_pointers.zig new file mode 100644 index 0000000000000000000000000000000000000000..d48dc0da957d7398a4b75663e58a2af31376f67f --- /dev/null +++ b/test/cases/function_pointers.zig @@ -0,0 +1,30 @@ +const std = @import("std"); + +const PrintFn = *const fn () void; + +pub fn main() void { + var printFn: PrintFn = stopSayingThat; + var i: u32 = 0; + while (i < 4) : (i += 1) printFn(); + + printFn = moveEveryZig; + printFn(); +} + +fn stopSayingThat() void { + _ = std.os.write(1, "Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n") catch {}; +} + +fn moveEveryZig() void { + _ = std.os.write(1, "All your codebase are belong to us\n") catch {}; +} + +// run +// target=x86_64-macos +// +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// Hello, my name is Inigo Montoya; you killed my father, prepare to die. +// All your codebase are belong to us +// diff --git a/test/cases/hello_world_with_updates.0.zig b/test/cases/hello_world_with_updates.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..bcd09204d0fd4ab3707b2bf07f6c0f0eba99e265 --- /dev/null +++ b/test/cases/hello_world_with_updates.0.zig @@ -0,0 +1,6 @@ +// error +// output_mode=Exe +// target=x86_64-linux,x86_64-macos +// link_libc=true +// +// :?:?: error: root struct of file 'tmp' has no member named 'main' diff --git a/test/cases/hello_world_with_updates.1.zig b/test/cases/hello_world_with_updates.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..dcf18bbf87713e6dcaa556378643fc88664023da --- /dev/null +++ b/test/cases/hello_world_with_updates.1.zig @@ -0,0 +1,6 @@ +pub export fn main() noreturn {} + +// error +// +// :1:22: error: function declared 'noreturn' implicitly returns +// :1:32: note: control flow reaches end of body here diff --git a/test/cases/hello_world_with_updates.2.zig b/test/cases/hello_world_with_updates.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..be6dc58c743972d9b0aac98ec8bb8ae764bb0a7c --- /dev/null +++ b/test/cases/hello_world_with_updates.2.zig @@ -0,0 +1,19 @@ +extern "c" fn write(c_int, usize, usize) usize; +extern "c" fn exit(c_int) 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/cases/hello_world_with_updates.3.zig b/test/cases/hello_world_with_updates.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..f464c379aa6cae62097c315afb59e3f8b2803893 --- /dev/null +++ b/test/cases/hello_world_with_updates.3.zig @@ -0,0 +1,16 @@ +extern "c" fn write(c_int, 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/cases/hello_world_with_updates.4.zig b/test/cases/hello_world_with_updates.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..c9efbd0f35d27d17f93a7cd48ab254863a4723e5 --- /dev/null +++ b/test/cases/hello_world_with_updates.4.zig @@ -0,0 +1,22 @@ +extern "c" fn write(c_int, 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/cases/hello_world_with_updates.5.zig b/test/cases/hello_world_with_updates.5.zig new file mode 100644 index 0000000000000000000000000000000000000000..5070ea457c3eaf7d1786662651ae058fd21e564c --- /dev/null +++ b/test/cases/hello_world_with_updates.5.zig @@ -0,0 +1,16 @@ +extern "c" fn write(c_int, 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/cases/hello_world_with_updates.6.zig b/test/cases/hello_world_with_updates.6.zig new file mode 100644 index 0000000000000000000000000000000000000000..a33f2954e5f7a873b3771c67464d4ad14bf24505 --- /dev/null +++ b/test/cases/hello_world_with_updates.6.zig @@ -0,0 +1,20 @@ +const builtin = @import("builtin"); + +extern "c" fn write(c_int, 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/cases/large_add_function.zig b/test/cases/large_add_function.zig index 8b0e9b879b2f9309f29ef99823f5d26e783124c7..61201d154588de96e3acbdc525c6bf4fc19d485a 100644 --- a/test/cases/large_add_function.zig +++ b/test/cases/large_add_function.zig @@ -33,6 +33,8 @@ fn assert(ok: bool) void { if (!ok) unreachable; } +// TODO: enable this for native backend + // run +// backend=llvm // target=aarch64-linux,aarch64-macos -// diff --git a/test/cases/locals.0.zig b/test/cases/locals.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..f2df242792c6249864477ac4a69614f5032d6ceb --- /dev/null +++ b/test/cases/locals.0.zig @@ -0,0 +1,14 @@ +pub fn main() void { + var i: u8 = 5; + var y: f32 = 42.0; + var x: u8 = 10; + if (false) { + y; + x; + } + if (i != 5) unreachable; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/locals.1.zig b/test/cases/locals.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..f7e59e1c02e8a328b3bc84e7d0f1820c92b22d22 --- /dev/null +++ b/test/cases/locals.1.zig @@ -0,0 +1,17 @@ +pub fn main() void { + var i: u8 = 5; + var y: f32 = 42.0; + _ = y; + var x: u8 = 10; + foo(i, x); + i = x; + if (i != 10) unreachable; +} +fn foo(x: u8, y: u8) void { + _ = y; + var i: u8 = 10; + i = x; +} + +// run +// diff --git a/test/cases/only_1_function_and_it_gets_updated.0.zig b/test/cases/only_1_function_and_it_gets_updated.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..eada595db815cc30b8663a723cf6c0cb8b012857 --- /dev/null +++ b/test/cases/only_1_function_and_it_gets_updated.0.zig @@ -0,0 +1,7 @@ +pub export fn _start() noreturn { + while (true) {} +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/cases/only_1_function_and_it_gets_updated.1.zig b/test/cases/only_1_function_and_it_gets_updated.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..39909f93b8221f3085df667860dd63e7995f3e98 --- /dev/null +++ b/test/cases/only_1_function_and_it_gets_updated.1.zig @@ -0,0 +1,8 @@ +pub export fn _start() noreturn { + var dummy: u32 = 10; + _ = dummy; + while (true) {} +} + +// run +// diff --git a/test/cases/optionals.0.zig b/test/cases/optionals.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..e602bf1c8047d4b39bd8bb669df837b7842c3e5d --- /dev/null +++ b/test/cases/optionals.0.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var x: ?u8 = 5; + var y: u8 = 0; + if (x) |val| { + y = val; + } + return y - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/optionals.1.zig b/test/cases/optionals.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..26e81b890983755980f6e5701d04faec506ff49d --- /dev/null +++ b/test/cases/optionals.1.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var x: ?u8 = null; + var y: u8 = 0; + if (x) |val| { + y = val; + } + return y; +} + +// run +// diff --git a/test/cases/optionals.2.zig b/test/cases/optionals.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..b610c6d2e9669ccbbe921cce11695c0200e2ba25 --- /dev/null +++ b/test/cases/optionals.2.zig @@ -0,0 +1,7 @@ +pub fn main() u8 { + var x: ?u8 = 5; + return x.? - 5; +} + +// run +// diff --git a/test/cases/optionals.3.zig b/test/cases/optionals.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..d513c102827858be70c41f43bda1f6698fad19ed --- /dev/null +++ b/test/cases/optionals.3.zig @@ -0,0 +1,8 @@ +pub fn main() u8 { + var x: u8 = 5; + var y: ?u8 = x; + return y.? - 5; +} + +// run +// diff --git a/test/cases/optionals.4.zig b/test/cases/optionals.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..af3400b322a9b9cec82f8a3798c1806e93aae4c4 --- /dev/null +++ b/test/cases/optionals.4.zig @@ -0,0 +1,13 @@ +pub fn main() u8 { + var val: ?u8 = 5; + while (val) |*v| { + v.* -= 1; + if (v.* == 2) { + val = null; + } + } + return 0; +} + +// run +// diff --git a/test/cases/parameters_and_return_values.0.zig b/test/cases/parameters_and_return_values.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..45f0813e3ddf96f1e5348091b339c3dfdedacc82 --- /dev/null +++ b/test/cases/parameters_and_return_values.0.zig @@ -0,0 +1,20 @@ +const std = @import("std"); + +pub fn main() void { + print(id(14)); +} + +fn id(x: u32) u32 { + return x; +} + +fn print(len: u32) void { + const str = "Hello, World!\n"; + _ = std.os.write(1, str[0..len]) catch {}; +} + +// run +// target=x86_64-macos +// +// Hello, World! +// diff --git a/test/cases/parameters_and_return_values.1.zig b/test/cases/parameters_and_return_values.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..f2bc35d22ec6a7ac0b203bf257d10805815dc931 --- /dev/null +++ b/test/cases/parameters_and_return_values.1.zig @@ -0,0 +1,14 @@ +pub fn main() void { + assert(add(1, 2, 3, 4, 5, 6) == 21); +} + +fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { + return a + b + c + d + e + f; +} + +pub fn assert(ok: bool) void { + if (!ok) unreachable; // assertion failure +} + +// run +// diff --git a/test/cases/plan9/exit.zig b/test/cases/plan9/exit.zig deleted file mode 100644 index 5c5cf21765855e54898589a34ce8ee5093c032c0..0000000000000000000000000000000000000000 --- a/test/cases/plan9/exit.zig +++ /dev/null @@ -1,5 +0,0 @@ -pub fn main() void {} - -// run -// target=x86_64-plan9 -// diff --git a/test/cases/plan9/hello_world_with_updates.0.zig b/test/cases/plan9/hello_world_with_updates.0.zig deleted file mode 100644 index 7e7c3732518c776f31450f33083af7289c7f6e19..0000000000000000000000000000000000000000 --- a/test/cases/plan9/hello_world_with_updates.0.zig +++ /dev/null @@ -1,28 +0,0 @@ -pub fn main() void { - const str = "Hello World!\n"; - asm volatile ( - \\push $0 - \\push %%r10 - \\push %%r11 - \\push $1 - \\push $0 - \\syscall - \\pop %%r11 - \\pop %%r11 - \\pop %%r11 - \\pop %%r11 - \\pop %%r11 - : - // pwrite - : [syscall_number] "{rbp}" (51), - [hey] "{r11}" (@ptrToInt(str)), - [strlen] "{r10}" (str.len), - : "rcx", "rbp", "r11", "memory" - ); -} - -// run -// target=x86_64-plan9 -// -// Hello World -// diff --git a/test/cases/plan9/hello_world_with_updates.1.zig b/test/cases/plan9/hello_world_with_updates.1.zig deleted file mode 100644 index 410045ab79d734ea3e1fbad4737550539ea34c05..0000000000000000000000000000000000000000 --- a/test/cases/plan9/hello_world_with_updates.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -const std = @import("std"); -pub fn main() void { - const str = "Hello World!\n"; - _ = std.os.plan9.pwrite(1, str, str.len, 0); -} - -// run -// target=x86_64-plan9 -// -// Hello World -// diff --git a/test/cases/pointers.0.zig b/test/cases/pointers.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..958ee5ac8860225eb4b5d5bfb051a8fb9ea97699 --- /dev/null +++ b/test/cases/pointers.0.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var x: u8 = 0; + + foo(&x); + return x - 2; +} + +fn foo(x: *u8) void { + x.* = 2; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/pointers.1.zig b/test/cases/pointers.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..b3649cf5204313da4d2979866de590a04d4494a1 --- /dev/null +++ b/test/cases/pointers.1.zig @@ -0,0 +1,18 @@ +pub fn main() u8 { + var x: u8 = 0; + + foo(&x); + bar(&x); + return x - 4; +} + +fn foo(x: *u8) void { + x.* = 2; +} + +fn bar(x: *u8) void { + x.* += 2; +} + +// run +// diff --git a/test/cases/print_u32s.zig b/test/cases/print_u32s.zig new file mode 100644 index 0000000000000000000000000000000000000000..f50e85d0aada7f66c8378d03d97eb0bf4e4030a4 --- /dev/null +++ b/test/cases/print_u32s.zig @@ -0,0 +1,28 @@ +const std = @import("std"); + +pub fn main() void { + printNumberHex(0x00000000); + printNumberHex(0xaaaaaaaa); + printNumberHex(0xdeadbeef); + printNumberHex(0x31415926); +} + +fn printNumberHex(x: u32) void { + const digit_chars = "0123456789abcdef"; + var i: u5 = 28; + while (true) : (i -= 4) { + const digit = (x >> i) & 0xf; + _ = std.os.write(1, &.{digit_chars[digit]}) catch {}; + if (i == 0) break; + } + _ = std.os.write(1, "\n") catch {}; +} + +// run +// target=x86_64-macos +// +// 00000000 +// aaaaaaaa +// deadbeef +// 31415926 +// diff --git a/test/cases/recursive_fibonacci.zig b/test/cases/recursive_fibonacci.zig index 24a7f7566694777f3eca72b257e67dfbb3e86f68..a2b8436dd79bdca6065b18458b828df5708180cb 100644 --- a/test/cases/recursive_fibonacci.zig +++ b/test/cases/recursive_fibonacci.zig @@ -20,5 +20,5 @@ fn assert(ok: bool) void { } // run -// target=x86_64-linux,x86_64-macos,arm-linux,wasm32-wasi +// target=x86_64-linux,x86_64-macos,wasm32-wasi // diff --git a/test/cases/spilling_registers.0.zig b/test/cases/spilling_registers.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..eb580cf5d81127bed53d1cc3ef5aea437d7b7fe8 --- /dev/null +++ b/test/cases/spilling_registers.0.zig @@ -0,0 +1,38 @@ +pub fn main() void { + assert(add(3, 4) == 791); +} + +fn add(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l + d; // 227 + const n = m + e; // 241 + const o = n + f; // 265 + const p = o + g; // 303 + const q = p + h; // 365 + const r = q + i; // 465 + const s = r + j; // 575 + const t = s + k; // 785 + break :blk t; + }; + const y = x + a; // 788 + const z = y + a; // 791 + return z; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// target=x86_64-linux,x86_64-macos +// diff --git a/test/cases/spilling_registers.1.zig b/test/cases/spilling_registers.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..f401a5d7b7d1f29a9dc628315cff7e5b4e85d21c --- /dev/null +++ b/test/cases/spilling_registers.1.zig @@ -0,0 +1,37 @@ +pub fn main() void { + assert(addMul(3, 4) == 357747496); +} + +fn addMul(a: u32, b: u32) u32 { + const x: u32 = blk: { + const c = a + b; // 7 + const d = a + c; // 10 + const e = d + b; // 14 + const f = d + e; // 24 + const g = e + f; // 38 + const h = f + g; // 62 + const i = g + h; // 100 + const j = i + d; // 110 + const k = i + j; // 210 + const l = k + c; // 217 + const m = l * d; // 2170 + const n = m + e; // 2184 + const o = n * f; // 52416 + const p = o + g; // 52454 + const q = p * h; // 3252148 + const r = q + i; // 3252248 + const s = r * j; // 357747280 + const t = s + k; // 357747490 + break :blk t; + }; + const y = x + a; // 357747493 + const z = y + a; // 357747496 + return z; +} + +fn assert(ok: bool) void { + if (!ok) unreachable; +} + +// run +// diff --git a/test/cases/structs.0.zig b/test/cases/structs.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..03a8938d9ebcf80db462bb7f98d093b97a28003d --- /dev/null +++ b/test/cases/structs.0.zig @@ -0,0 +1,10 @@ +const Example = struct { x: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5 }; + return example.x - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/structs.1.zig b/test/cases/structs.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..8d4250e4a2ac87a7271f06275f2bd951f211180c --- /dev/null +++ b/test/cases/structs.1.zig @@ -0,0 +1,10 @@ +const Example = struct { x: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5 }; + example.x = 10; + return example.x - 10; +} + +// run +// diff --git a/test/cases/structs.2.zig b/test/cases/structs.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..b1d3cbf080accc76edd40158f4f7c5946f9c7c79 --- /dev/null +++ b/test/cases/structs.2.zig @@ -0,0 +1,9 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + return example.y + example.x - 15; +} + +// run +// diff --git a/test/cases/structs.3.zig b/test/cases/structs.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..558b5a1e2d7109fdf53d0c9b862718588178440e --- /dev/null +++ b/test/cases/structs.3.zig @@ -0,0 +1,12 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + var example2: Example = .{ .x = 10, .y = 20 }; + + example = example2; + return example.y + example.x - 30; +} + +// run +// diff --git a/test/cases/structs.4.zig b/test/cases/structs.4.zig new file mode 100644 index 0000000000000000000000000000000000000000..2d37446c5692f49b68d0de55488e995b1011e075 --- /dev/null +++ b/test/cases/structs.4.zig @@ -0,0 +1,11 @@ +const Example = struct { x: u8, y: u8 }; + +pub fn main() u8 { + var example: Example = .{ .x = 5, .y = 10 }; + + example = .{ .x = 10, .y = 20 }; + return example.y + example.x - 30; +} + +// run +// diff --git a/test/cases/switch.0.zig b/test/cases/switch.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..d0c0e43f8fb8d9a5cc41e1636c41ec24e9ffce71 --- /dev/null +++ b/test/cases/switch.0.zig @@ -0,0 +1,15 @@ +pub fn main() u8 { + var val: u8 = 1; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 2; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/switch.1.zig b/test/cases/switch.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..fe503bf212e45fb1c74940b227b33221868e146e --- /dev/null +++ b/test/cases/switch.1.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var val: u8 = 2; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 3; +} + +// run +// diff --git a/test/cases/switch.2.zig b/test/cases/switch.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..24f40d8402ca658e294b45e1d771b9f5697efb90 --- /dev/null +++ b/test/cases/switch.2.zig @@ -0,0 +1,14 @@ +pub fn main() u8 { + var val: u8 = 10; + var a: u8 = switch (val) { + 0, 1 => 2, + 2 => 3, + 3 => 4, + else => 5, + }; + + return a - 5; +} + +// run +// diff --git a/test/cases/switch.3.zig b/test/cases/switch.3.zig new file mode 100644 index 0000000000000000000000000000000000000000..e0b55db3bff6a6809e7ce5285ccce49f40b8c82b --- /dev/null +++ b/test/cases/switch.3.zig @@ -0,0 +1,15 @@ +const MyEnum = enum { One, Two, Three }; + +pub fn main() u8 { + var val: MyEnum = .Two; + var a: u8 = switch (val) { + .One => 1, + .Two => 2, + .Three => 3, + }; + + return a - 2; +} + +// run +// diff --git a/test/cases/wasm-wasi/conditions.0.zig b/test/cases/wasm-wasi/conditions.0.zig deleted file mode 100644 index 1167ea85a4413757b8d481b1d672703b2a2ebd2f..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.0.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() u8 { - var i: u8 = 5; - if (i > @as(u8, 4)) { - i += 10; - } - return i - 15; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/conditions.1.zig b/test/cases/wasm-wasi/conditions.1.zig deleted file mode 100644 index f9f03808b97a134f78276875979f483e8ad317e5..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.1.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var i: u8 = 5; - if (i < @as(u8, 4)) { - i += 10; - } else { - i = 2; - } - return i - 2; -} - -// run -// diff --git a/test/cases/wasm-wasi/conditions.2.zig b/test/cases/wasm-wasi/conditions.2.zig deleted file mode 100644 index a80ead9ea54084317c55da133d91bf72f305909f..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.2.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var i: u8 = 5; - if (i < @as(u8, 4)) { - i += 10; - } else if (i == @as(u8, 5)) { - i = 20; - } - return i - 20; -} - -// run -// diff --git a/test/cases/wasm-wasi/conditions.3.zig b/test/cases/wasm-wasi/conditions.3.zig deleted file mode 100644 index bd016a47f3c78ec39512ad91d0cd373f35a8bed2..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.3.zig +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() u8 { - var i: u8 = 11; - if (i < @as(u8, 4)) { - i += 10; - } else { - if (i > @as(u8, 10)) { - i += 20; - } else { - i = 20; - } - } - return i - 31; -} - -// run -// diff --git a/test/cases/wasm-wasi/conditions.4.zig b/test/cases/wasm-wasi/conditions.4.zig deleted file mode 100644 index e1bd9ce0f7b6b397c997f416143b0eac10ac7551..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.4.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - assert(foo(true) != @as(i32, 30)); -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -fn foo(ok: bool) i32 { - const x = if (ok) @as(i32, 20) else @as(i32, 10); - return x; -} - -// run -// diff --git a/test/cases/wasm-wasi/conditions.5.zig b/test/cases/wasm-wasi/conditions.5.zig deleted file mode 100644 index 2d5ba338c7aea87a6f059d6f119bd1e0f7641793..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/conditions.5.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - assert(foo(false) == @as(i32, 20)); - assert(foo(true) == @as(i32, 30)); -} - -fn assert(ok: bool) void { - if (!ok) unreachable; -} - -fn foo(ok: bool) i32 { - const val: i32 = blk: { - var x: i32 = 1; - if (!ok) break :blk x + @as(i32, 9); - break :blk x + @as(i32, 19); - }; - return val + 10; -} - -// run -// diff --git a/test/cases/wasm-wasi/error_unions.0.zig b/test/cases/wasm-wasi/error_unions.0.zig deleted file mode 100644 index 355698e4b66b7e43c16c1c0b4c92b9161f1c9a11..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.0.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - var e1 = error.Foo; - var e2 = error.Bar; - assert(e1 != e2); - assert(e1 == error.Foo); - assert(e2 == error.Bar); -} - -fn assert(b: bool) void { - if (!b) unreachable; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/error_unions.1.zig b/test/cases/wasm-wasi/error_unions.1.zig deleted file mode 100644 index 526e1a110d4c74415d9c3036ae99b828efd133c7..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.1.zig +++ /dev/null @@ -1,8 +0,0 @@ -pub fn main() u8 { - var e: anyerror!u8 = 5; - const i = e catch 10; - return i - 5; -} - -// run -// diff --git a/test/cases/wasm-wasi/error_unions.2.zig b/test/cases/wasm-wasi/error_unions.2.zig deleted file mode 100644 index b66c7d78c073bb0ef4cd4365fed5873fb66901af..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.2.zig +++ /dev/null @@ -1,8 +0,0 @@ -pub fn main() u8 { - var e: anyerror!u8 = error.Foo; - const i = e catch 10; - return i - 10; -} - -// run -// diff --git a/test/cases/wasm-wasi/error_unions.3.zig b/test/cases/wasm-wasi/error_unions.3.zig deleted file mode 100644 index d37f826272dc32f990891837ed1a1a202a81fbd4..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.3.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var e = foo(); - const i = e catch 69; - return i - 5; -} - -fn foo() anyerror!u8 { - return 5; -} - -// run -// diff --git a/test/cases/wasm-wasi/error_unions.4.zig b/test/cases/wasm-wasi/error_unions.4.zig deleted file mode 100644 index bbc8dd34da3b637871424a45678b5f5c5f67620c..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.4.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var e = foo(); - const i = e catch 69; - return i - 69; -} - -fn foo() anyerror!u8 { - return error.Bruh; -} - -// run -// diff --git a/test/cases/wasm-wasi/error_unions.5.zig b/test/cases/wasm-wasi/error_unions.5.zig deleted file mode 100644 index 96d52d1de1f3a3eb31741f0bfdd8f8791f92e232..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/error_unions.5.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var e = foo(); - const i = e catch 42; - return i - 42; -} - -fn foo() anyerror!u8 { - return error.Dab; -} - -// run -// diff --git a/test/cases/wasm-wasi/locals.0.zig b/test/cases/wasm-wasi/locals.0.zig deleted file mode 100644 index f2df242792c6249864477ac4a69614f5032d6ceb..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/locals.0.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub fn main() void { - var i: u8 = 5; - var y: f32 = 42.0; - var x: u8 = 10; - if (false) { - y; - x; - } - if (i != 5) unreachable; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/locals.1.zig b/test/cases/wasm-wasi/locals.1.zig deleted file mode 100644 index f7e59e1c02e8a328b3bc84e7d0f1820c92b22d22..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/locals.1.zig +++ /dev/null @@ -1,17 +0,0 @@ -pub fn main() void { - var i: u8 = 5; - var y: f32 = 42.0; - _ = y; - var x: u8 = 10; - foo(i, x); - i = x; - if (i != 10) unreachable; -} -fn foo(x: u8, y: u8) void { - _ = y; - var i: u8 = 10; - i = x; -} - -// run -// diff --git a/test/cases/wasm-wasi/optionals.0.zig b/test/cases/wasm-wasi/optionals.0.zig deleted file mode 100644 index e602bf1c8047d4b39bd8bb669df837b7842c3e5d..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/optionals.0.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var x: ?u8 = 5; - var y: u8 = 0; - if (x) |val| { - y = val; - } - return y - 5; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/optionals.1.zig b/test/cases/wasm-wasi/optionals.1.zig deleted file mode 100644 index 26e81b890983755980f6e5701d04faec506ff49d..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/optionals.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() u8 { - var x: ?u8 = null; - var y: u8 = 0; - if (x) |val| { - y = val; - } - return y; -} - -// run -// diff --git a/test/cases/wasm-wasi/optionals.2.zig b/test/cases/wasm-wasi/optionals.2.zig deleted file mode 100644 index b610c6d2e9669ccbbe921cce11695c0200e2ba25..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/optionals.2.zig +++ /dev/null @@ -1,7 +0,0 @@ -pub fn main() u8 { - var x: ?u8 = 5; - return x.? - 5; -} - -// run -// diff --git a/test/cases/wasm-wasi/optionals.3.zig b/test/cases/wasm-wasi/optionals.3.zig deleted file mode 100644 index d513c102827858be70c41f43bda1f6698fad19ed..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/optionals.3.zig +++ /dev/null @@ -1,8 +0,0 @@ -pub fn main() u8 { - var x: u8 = 5; - var y: ?u8 = x; - return y.? - 5; -} - -// run -// diff --git a/test/cases/wasm-wasi/optionals.4.zig b/test/cases/wasm-wasi/optionals.4.zig deleted file mode 100644 index af3400b322a9b9cec82f8a3798c1806e93aae4c4..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/optionals.4.zig +++ /dev/null @@ -1,13 +0,0 @@ -pub fn main() u8 { - var val: ?u8 = 5; - while (val) |*v| { - v.* -= 1; - if (v.* == 2) { - val = null; - } - } - return 0; -} - -// run -// diff --git a/test/cases/wasm-wasi/pointers.0.zig b/test/cases/wasm-wasi/pointers.0.zig deleted file mode 100644 index 958ee5ac8860225eb4b5d5bfb051a8fb9ea97699..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/pointers.0.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub fn main() u8 { - var x: u8 = 0; - - foo(&x); - return x - 2; -} - -fn foo(x: *u8) void { - x.* = 2; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/pointers.1.zig b/test/cases/wasm-wasi/pointers.1.zig deleted file mode 100644 index b3649cf5204313da4d2979866de590a04d4494a1..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/pointers.1.zig +++ /dev/null @@ -1,18 +0,0 @@ -pub fn main() u8 { - var x: u8 = 0; - - foo(&x); - bar(&x); - return x - 4; -} - -fn foo(x: *u8) void { - x.* = 2; -} - -fn bar(x: *u8) void { - x.* += 2; -} - -// run -// diff --git a/test/cases/wasm-wasi/structs.0.zig b/test/cases/wasm-wasi/structs.0.zig deleted file mode 100644 index 03a8938d9ebcf80db462bb7f98d093b97a28003d..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/structs.0.zig +++ /dev/null @@ -1,10 +0,0 @@ -const Example = struct { x: u8 }; - -pub fn main() u8 { - var example: Example = .{ .x = 5 }; - return example.x - 5; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/structs.1.zig b/test/cases/wasm-wasi/structs.1.zig deleted file mode 100644 index 8d4250e4a2ac87a7271f06275f2bd951f211180c..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/structs.1.zig +++ /dev/null @@ -1,10 +0,0 @@ -const Example = struct { x: u8 }; - -pub fn main() u8 { - var example: Example = .{ .x = 5 }; - example.x = 10; - return example.x - 10; -} - -// run -// diff --git a/test/cases/wasm-wasi/structs.2.zig b/test/cases/wasm-wasi/structs.2.zig deleted file mode 100644 index b1d3cbf080accc76edd40158f4f7c5946f9c7c79..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/structs.2.zig +++ /dev/null @@ -1,9 +0,0 @@ -const Example = struct { x: u8, y: u8 }; - -pub fn main() u8 { - var example: Example = .{ .x = 5, .y = 10 }; - return example.y + example.x - 15; -} - -// run -// diff --git a/test/cases/wasm-wasi/structs.3.zig b/test/cases/wasm-wasi/structs.3.zig deleted file mode 100644 index 558b5a1e2d7109fdf53d0c9b862718588178440e..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/structs.3.zig +++ /dev/null @@ -1,12 +0,0 @@ -const Example = struct { x: u8, y: u8 }; - -pub fn main() u8 { - var example: Example = .{ .x = 5, .y = 10 }; - var example2: Example = .{ .x = 10, .y = 20 }; - - example = example2; - return example.y + example.x - 30; -} - -// run -// diff --git a/test/cases/wasm-wasi/structs.4.zig b/test/cases/wasm-wasi/structs.4.zig deleted file mode 100644 index 2d37446c5692f49b68d0de55488e995b1011e075..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/structs.4.zig +++ /dev/null @@ -1,11 +0,0 @@ -const Example = struct { x: u8, y: u8 }; - -pub fn main() u8 { - var example: Example = .{ .x = 5, .y = 10 }; - - example = .{ .x = 10, .y = 20 }; - return example.y + example.x - 30; -} - -// run -// diff --git a/test/cases/wasm-wasi/switch.0.zig b/test/cases/wasm-wasi/switch.0.zig deleted file mode 100644 index d0c0e43f8fb8d9a5cc41e1636c41ec24e9ffce71..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/switch.0.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() u8 { - var val: u8 = 1; - var a: u8 = switch (val) { - 0, 1 => 2, - 2 => 3, - 3 => 4, - else => 5, - }; - - return a - 2; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/switch.1.zig b/test/cases/wasm-wasi/switch.1.zig deleted file mode 100644 index fe503bf212e45fb1c74940b227b33221868e146e..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/switch.1.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub fn main() u8 { - var val: u8 = 2; - var a: u8 = switch (val) { - 0, 1 => 2, - 2 => 3, - 3 => 4, - else => 5, - }; - - return a - 3; -} - -// run -// diff --git a/test/cases/wasm-wasi/switch.2.zig b/test/cases/wasm-wasi/switch.2.zig deleted file mode 100644 index 24f40d8402ca658e294b45e1d771b9f5697efb90..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/switch.2.zig +++ /dev/null @@ -1,14 +0,0 @@ -pub fn main() u8 { - var val: u8 = 10; - var a: u8 = switch (val) { - 0, 1 => 2, - 2 => 3, - 3 => 4, - else => 5, - }; - - return a - 5; -} - -// run -// diff --git a/test/cases/wasm-wasi/switch.3.zig b/test/cases/wasm-wasi/switch.3.zig deleted file mode 100644 index e0b55db3bff6a6809e7ce5285ccce49f40b8c82b..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/switch.3.zig +++ /dev/null @@ -1,15 +0,0 @@ -const MyEnum = enum { One, Two, Three }; - -pub fn main() u8 { - var val: MyEnum = .Two; - var a: u8 = switch (val) { - .One => 1, - .Two => 2, - .Three => 3, - }; - - return a - 2; -} - -// run -// diff --git a/test/cases/wasm-wasi/while_loops.0.zig b/test/cases/wasm-wasi/while_loops.0.zig deleted file mode 100644 index 721b127ff54aeb2d65f03dd4cfdc8315445529f6..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/while_loops.0.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var i: u8 = 0; - while (i < @as(u8, 5)) { - i += 1; - } - - return i - 5; -} - -// run -// target=wasm32-wasi -// diff --git a/test/cases/wasm-wasi/while_loops.1.zig b/test/cases/wasm-wasi/while_loops.1.zig deleted file mode 100644 index 715a813b65e66c4b1f42e4b00b397b5933b0de35..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/while_loops.1.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() u8 { - var i: u8 = 0; - while (i < @as(u8, 10)) { - var x: u8 = 1; - i += x; - } - return i - 10; -} - -// run -// diff --git a/test/cases/wasm-wasi/while_loops.2.zig b/test/cases/wasm-wasi/while_loops.2.zig deleted file mode 100644 index 7ad8101c3777d2a94289fedd8406693f4b7c0861..0000000000000000000000000000000000000000 --- a/test/cases/wasm-wasi/while_loops.2.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() u8 { - var i: u8 = 0; - while (i < @as(u8, 10)) { - var x: u8 = 1; - i += x; - if (i == @as(u8, 5)) break; - } - return i - 5; -} - -// run -// diff --git a/test/cases/while_loops.0.zig b/test/cases/while_loops.0.zig new file mode 100644 index 0000000000000000000000000000000000000000..721b127ff54aeb2d65f03dd4cfdc8315445529f6 --- /dev/null +++ b/test/cases/while_loops.0.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 5)) { + i += 1; + } + + return i - 5; +} + +// run +// target=wasm32-wasi +// diff --git a/test/cases/while_loops.1.zig b/test/cases/while_loops.1.zig new file mode 100644 index 0000000000000000000000000000000000000000..715a813b65e66c4b1f42e4b00b397b5933b0de35 --- /dev/null +++ b/test/cases/while_loops.1.zig @@ -0,0 +1,11 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 10)) { + var x: u8 = 1; + i += x; + } + return i - 10; +} + +// run +// diff --git a/test/cases/while_loops.2.zig b/test/cases/while_loops.2.zig new file mode 100644 index 0000000000000000000000000000000000000000..7ad8101c3777d2a94289fedd8406693f4b7c0861 --- /dev/null +++ b/test/cases/while_loops.2.zig @@ -0,0 +1,12 @@ +pub fn main() u8 { + var i: u8 = 0; + while (i < @as(u8, 10)) { + var x: u8 = 1; + i += x; + if (i == @as(u8, 5)) break; + } + return i - 5; +} + +// run +// diff --git a/test/cases/x86_64-linux/assert_function.0.zig b/test/cases/x86_64-linux/assert_function.0.zig deleted file mode 100644 index ab34f5328dc90498078384ce434c0e11905f0487..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.0.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - assert(a + b == 7); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// target=x86_64-linux -// diff --git a/test/cases/x86_64-linux/assert_function.1.zig b/test/cases/x86_64-linux/assert_function.1.zig deleted file mode 100644 index ac2df25d8556c661b48a9382d200283073d5d00b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.1.zig +++ /dev/null @@ -1,17 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - assert(e == 14); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.10.zig b/test/cases/x86_64-linux/assert_function.10.zig deleted file mode 100644 index b3f1610cd62b71553f20959ef9cf4cec51d8f498..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.10.zig +++ /dev/null @@ -1,27 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 116); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - break :blk j; - }; - const y = x + a; // 113 - const z = y + a; // 116 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.11.zig b/test/cases/x86_64-linux/assert_function.11.zig deleted file mode 100644 index d64130a6775b250ca18a5900e912391dc732a7f7..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.11.zig +++ /dev/null @@ -1,66 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 1221); - assert(mul(3, 4) == 21609); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = j + k; // 320 - const m = l + c; // 327 - const n = m + d; // 337 - const o = n + e; // 351 - const p = o + f; // 375 - const q = p + g; // 413 - const r = q + h; // 475 - const s = r + i; // 575 - const t = s + j; // 685 - const u = t + k; // 895 - const v = u + l; // 1215 - break :blk v; - }; - const y = x + a; // 1218 - const z = y + a; // 1221 - return z; -} - -fn mul(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a * a * a * a; // 81 - const d = a * a * a * b; // 108 - const e = a * a * b * a; // 108 - const f = a * a * b * b; // 144 - const g = a * b * a * a; // 108 - const h = a * b * a * b; // 144 - const i = a * b * b * a; // 144 - const j = a * b * b * b; // 192 - const k = b * a * a * a; // 108 - const l = b * a * a * b; // 144 - const m = b * a * b * a; // 144 - const n = b * a * b * b; // 192 - const o = b * b * a * a; // 144 - const p = b * b * a * b; // 192 - const q = b * b * b * a; // 192 - const r = b * b * b * b; // 256 - const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 - break :blk s; - }; - const y = x * a; // 7203 - const z = y * a; // 21609 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.12.zig b/test/cases/x86_64-linux/assert_function.12.zig deleted file mode 100644 index 4f64c1e0626879a2004d66080292dc7cf962065d..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.12.zig +++ /dev/null @@ -1,47 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 791); - assert(add(4, 3) == 79); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = if (a < b) blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = k + c; // 217 - const m = l + d; // 227 - const n = m + e; // 241 - const o = n + f; // 265 - const p = o + g; // 303 - const q = p + h; // 365 - const r = q + i; // 465 - const s = r + j; // 575 - const t = s + k; // 785 - break :blk t; - } else blk: { - const t = b + b + a; // 10 - const c = a + t; // 14 - const d = c + t; // 24 - const e = d + t; // 34 - const f = e + t; // 44 - const g = f + t; // 54 - const h = c + g; // 68 - break :blk h + b; // 71 - }; - const y = x + a; // 788, 75 - const z = y + a; // 791, 79 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.13.zig b/test/cases/x86_64-linux/assert_function.13.zig deleted file mode 100644 index 240abf0108dbe8c08040533524872e543fd6d621..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.13.zig +++ /dev/null @@ -1,19 +0,0 @@ -pub fn main() void { - const ignore = - \\ cool thx - \\ - ; - _ = ignore; - add('ぁ', '\x03'); -} - -fn add(a: u32, b: u32) void { - assert(a + b == 12356); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.14.zig b/test/cases/x86_64-linux/assert_function.14.zig deleted file mode 100644 index d25100dccee2bda1f615c2d870ee477c1252bed3..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.14.zig +++ /dev/null @@ -1,17 +0,0 @@ -pub fn main() void { - add(aa, bb); -} - -const aa = 'ぁ'; -const bb = '\x03'; - -fn add(a: u32, b: u32) void { - assert(a + b == 12356); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.15.zig b/test/cases/x86_64-linux/assert_function.15.zig deleted file mode 100644 index 33ae1ed5af1279b74f089003e7b9665b55c2489b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.15.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - assert("hello"[0] == 'h'); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.16.zig b/test/cases/x86_64-linux/assert_function.16.zig deleted file mode 100644 index eef113642324434c4af1723aac512a57192ce726..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.16.zig +++ /dev/null @@ -1,11 +0,0 @@ -const hello = "hello".*; -pub fn main() void { - assert(hello[1] == 'e'); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.17.zig b/test/cases/x86_64-linux/assert_function.17.zig deleted file mode 100644 index ac9dce3079f6444476afd65757675726390946cf..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.17.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() void { - var i: u64 = 0xFFEEDDCCBBAA9988; - assert(i == 0xFFEEDDCCBBAA9988); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.18.zig b/test/cases/x86_64-linux/assert_function.18.zig deleted file mode 100644 index 31cf1207f3dc07541a4210641ee136eb0ba385b0..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.18.zig +++ /dev/null @@ -1,35 +0,0 @@ -const builtin = @import("builtin"); - -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - for ("hello") |_| print(); -} - -fn print() void { - switch (builtin.os.tag) { - .linux => { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("hello\n")), - [arg3] "{rdx}" (6), - : "rcx", "r11", "memory" - ); - }, - .macos => { - _ = write(1, @ptrToInt("hello\n"), 6); - }, - else => unreachable, - } -} - -// run -// -// hello -// hello -// hello -// hello -// hello -// diff --git a/test/cases/x86_64-linux/assert_function.2.zig b/test/cases/x86_64-linux/assert_function.2.zig deleted file mode 100644 index 8c1c510486185f4116841577473c901e13528283..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.2.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - assert(i == 100); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.3.zig b/test/cases/x86_64-linux/assert_function.3.zig deleted file mode 100644 index a6829f8e0239f8c01f0a1e4e1cf42e9ed035176b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.3.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - assert(j == 110); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.4.zig b/test/cases/x86_64-linux/assert_function.4.zig deleted file mode 100644 index 69df4354c3eb8d72d4c91b226fbf4b4c0eddedaf..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.4.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 7); - assert(add(20, 10) == 30); -} - -fn add(a: u32, b: u32) u32 { - return a + b; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.5.zig b/test/cases/x86_64-linux/assert_function.5.zig deleted file mode 100644 index 89f3f7df4fd3f42da6650c27dff3c8160b281860..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.5.zig +++ /dev/null @@ -1,19 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 7); - assert(add(20, 10) == 30); -} - -fn add(a: u32, b: u32) u32 { - var x: u32 = undefined; - x = 0; - x += a; - x += b; - return x; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.6.zig b/test/cases/x86_64-linux/assert_function.6.zig deleted file mode 100644 index 1b1b75e68ea72902208bd0889c38202922b89a51..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.6.zig +++ /dev/null @@ -1,9 +0,0 @@ -pub fn main() void { - const a: u32 = 2; - const b: ?u32 = a; - const c = b.?; - if (c != 2) unreachable; -} - -// run -// diff --git a/test/cases/x86_64-linux/assert_function.7.zig b/test/cases/x86_64-linux/assert_function.7.zig deleted file mode 100644 index e6d18a5c3f7e1f2f71ffce96c309b8f862541fb0..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.7.zig +++ /dev/null @@ -1,28 +0,0 @@ -pub fn main() void { - var i: u32 = 0; - while (i < 4) : (i += 1) print(); - assert(i == 4); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("hello\n")), - [arg3] "{rdx}" (6), - : "rcx", "r11", "memory" - ); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// -// hello -// hello -// hello -// hello -// diff --git a/test/cases/x86_64-linux/assert_function.8.zig b/test/cases/x86_64-linux/assert_function.8.zig deleted file mode 100644 index 1619452009fe5df5c5481f3704dfcb8f85584229..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.8.zig +++ /dev/null @@ -1,25 +0,0 @@ -pub fn main() void { - var i: u32 = 0; - inline while (i < 4) : (i += 1) print(); - assert(i == 4); -} - -fn print() void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("hello\n")), - [arg3] "{rdx}" (6), - : "rcx", "r11", "memory" - ); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// error -// -// :3:21: error: unable to resolve comptime value -// :3:21: note: condition in comptime branch must be comptime-known diff --git a/test/cases/x86_64-linux/assert_function.9.zig b/test/cases/x86_64-linux/assert_function.9.zig deleted file mode 100644 index c754bb771133d8b3a595ec9fe46c48c4c6408e61..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/assert_function.9.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 20); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - break :blk e; - }; - const y = x + a; // 17 - const z = y + a; // 20 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-linux/comptime_var.0.zig b/test/cases/x86_64-linux/comptime_var.0.zig deleted file mode 100644 index 70504eb36488bec18379fca889019b65a9389ffe..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.0.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - comptime var b: u32 = 0; - if (a == 0) b = 3; -} - -// error -// output_mode=Exe -// target=x86_64-linux -// -// :4:19: error: store to comptime variable depends on runtime condition -// :4:11: note: runtime condition here diff --git a/test/cases/x86_64-linux/comptime_var.1.zig b/test/cases/x86_64-linux/comptime_var.1.zig deleted file mode 100644 index 054d69250c38b5c2faba39e67db1b203d7b6eec7..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.1.zig +++ /dev/null @@ -1,13 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - comptime var b: u32 = 0; - switch (a) { - 0 => {}, - else => b = 3, - } -} - -// error -// -// :6:19: error: store to comptime variable depends on runtime condition -// :4:13: note: runtime condition here diff --git a/test/cases/x86_64-linux/comptime_var.2.zig b/test/cases/x86_64-linux/comptime_var.2.zig deleted file mode 100644 index 72bdfad90c34a452e3be002cc82ad7315e9fe7d3..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.2.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - comptime var len: u32 = 5; - print(len); - len += 9; - print(len); -} - -fn print(len: usize) void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), - [arg3] "{rdx}" (len), - : "rcx", "r11", "memory" - ); -} - -// run -// -// HelloHello, World! -// diff --git a/test/cases/x86_64-linux/comptime_var.3.zig b/test/cases/x86_64-linux/comptime_var.3.zig deleted file mode 100644 index 5d25d6556e4f378d4288acda9ceffcb19397230f..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.3.zig +++ /dev/null @@ -1,10 +0,0 @@ -comptime { - var x: i32 = 1; - x += 1; - if (x != 1) unreachable; -} -pub fn main() void {} - -// error -// -// :4:17: error: reached unreachable code diff --git a/test/cases/x86_64-linux/comptime_var.4.zig b/test/cases/x86_64-linux/comptime_var.4.zig deleted file mode 100644 index 74da6ef448edd5534b49b1f850673863b4188b99..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.4.zig +++ /dev/null @@ -1,9 +0,0 @@ -pub fn main() void { - comptime var i: u64 = 0; - while (i < 5) : (i += 1) {} -} - -// error -// -// :3:24: error: cannot store to comptime variable in non-inline loop -// :3:5: note: non-inline loop here diff --git a/test/cases/x86_64-linux/comptime_var.5.zig b/test/cases/x86_64-linux/comptime_var.5.zig deleted file mode 100644 index 76a06f3d4b5931e8fd23271dcc593e07ff414a7f..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.5.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - if (a == 0) { - comptime var b: u32 = 0; - b = 1; - } -} -comptime { - var x: i32 = 1; - x += 1; - if (x != 2) unreachable; -} - -// run -// diff --git a/test/cases/x86_64-linux/comptime_var.6.zig b/test/cases/x86_64-linux/comptime_var.6.zig deleted file mode 100644 index 2790949561cb9d11c777288410d34feebc35a1f0..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/comptime_var.6.zig +++ /dev/null @@ -1,20 +0,0 @@ -pub fn main() void { - comptime var i: u64 = 2; - inline while (i < 6) : (i += 1) { - print(i); - } -} -fn print(len: usize) void { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("Hello")), - [arg3] "{rdx}" (len), - : "rcx", "r11", "memory" - ); -} - -// run -// -// HeHelHellHello diff --git a/test/cases/x86_64-linux/hello_world_with_updates.0.zig b/test/cases/x86_64-linux/hello_world_with_updates.0.zig deleted file mode 100644 index c330234fdbb4abc98756b3205aa7e3d39d857ddc..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.0.zig +++ /dev/null @@ -1,8 +0,0 @@ -// error -// output_mode=Exe -// target=x86_64-linux -// -// :?:?: error: root struct of file 'tmp' has no member named 'main' -// :?:?: note: called from here -// :?:?: note: called from here -// :?:?: note: called from here diff --git a/test/cases/x86_64-linux/hello_world_with_updates.1.zig b/test/cases/x86_64-linux/hello_world_with_updates.1.zig deleted file mode 100644 index dcf18bbf87713e6dcaa556378643fc88664023da..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.1.zig +++ /dev/null @@ -1,6 +0,0 @@ -pub export fn main() noreturn {} - -// error -// -// :1:22: error: function declared 'noreturn' implicitly returns -// :1:32: note: control flow reaches end of body here diff --git a/test/cases/x86_64-linux/hello_world_with_updates.2.zig b/test/cases/x86_64-linux/hello_world_with_updates.2.zig deleted file mode 100644 index fcea1870ce59ef67264c3be650beafabbd5a97e3..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.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/cases/x86_64-linux/hello_world_with_updates.3.zig b/test/cases/x86_64-linux/hello_world_with_updates.3.zig deleted file mode 100644 index 7812023372e14acc9c4c93441e913126d1e7de1d..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.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/cases/x86_64-linux/hello_world_with_updates.4.zig b/test/cases/x86_64-linux/hello_world_with_updates.4.zig deleted file mode 100644 index cdf47012b8306d2a234871842bfe00da550522de..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.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/cases/x86_64-linux/hello_world_with_updates.5.zig b/test/cases/x86_64-linux/hello_world_with_updates.5.zig deleted file mode 100644 index 68c1e305f713135321cd2000bdd9b50dc2020c8e..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/hello_world_with_updates.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/cases/x86_64-linux/only_1_function_and_it_gets_updated.0.zig b/test/cases/x86_64-linux/only_1_function_and_it_gets_updated.0.zig deleted file mode 100644 index ecba1c8133714f48d0423b98c9a213a057550ad1..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/only_1_function_and_it_gets_updated.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/cases/x86_64-linux/only_1_function_and_it_gets_updated.1.zig b/test/cases/x86_64-linux/only_1_function_and_it_gets_updated.1.zig deleted file mode 100644 index 529acbcf38132bb09f0a47adc2a128ac7c7b7ac5..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-linux/only_1_function_and_it_gets_updated.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/cases/x86_64-macos/assert_function.0.zig b/test/cases/x86_64-macos/assert_function.0.zig deleted file mode 100644 index 20e5cf0b97a96116457be9805f66190f5d7f8b4c..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.0.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - assert(a + b == 7); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// target=x86_64-macos -// diff --git a/test/cases/x86_64-macos/assert_function.1.zig b/test/cases/x86_64-macos/assert_function.1.zig deleted file mode 100644 index ac2df25d8556c661b48a9382d200283073d5d00b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.1.zig +++ /dev/null @@ -1,17 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - assert(e == 14); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.10.zig b/test/cases/x86_64-macos/assert_function.10.zig deleted file mode 100644 index b3f1610cd62b71553f20959ef9cf4cec51d8f498..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.10.zig +++ /dev/null @@ -1,27 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 116); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - break :blk j; - }; - const y = x + a; // 113 - const z = y + a; // 116 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.11.zig b/test/cases/x86_64-macos/assert_function.11.zig deleted file mode 100644 index d64130a6775b250ca18a5900e912391dc732a7f7..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.11.zig +++ /dev/null @@ -1,66 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 1221); - assert(mul(3, 4) == 21609); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = j + k; // 320 - const m = l + c; // 327 - const n = m + d; // 337 - const o = n + e; // 351 - const p = o + f; // 375 - const q = p + g; // 413 - const r = q + h; // 475 - const s = r + i; // 575 - const t = s + j; // 685 - const u = t + k; // 895 - const v = u + l; // 1215 - break :blk v; - }; - const y = x + a; // 1218 - const z = y + a; // 1221 - return z; -} - -fn mul(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a * a * a * a; // 81 - const d = a * a * a * b; // 108 - const e = a * a * b * a; // 108 - const f = a * a * b * b; // 144 - const g = a * b * a * a; // 108 - const h = a * b * a * b; // 144 - const i = a * b * b * a; // 144 - const j = a * b * b * b; // 192 - const k = b * a * a * a; // 108 - const l = b * a * a * b; // 144 - const m = b * a * b * a; // 144 - const n = b * a * b * b; // 192 - const o = b * b * a * a; // 144 - const p = b * b * a * b; // 192 - const q = b * b * b * a; // 192 - const r = b * b * b * b; // 256 - const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 - break :blk s; - }; - const y = x * a; // 7203 - const z = y * a; // 21609 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.12.zig b/test/cases/x86_64-macos/assert_function.12.zig deleted file mode 100644 index 4f64c1e0626879a2004d66080292dc7cf962065d..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.12.zig +++ /dev/null @@ -1,47 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 791); - assert(add(4, 3) == 79); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = if (a < b) blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - const k = i + j; // 210 - const l = k + c; // 217 - const m = l + d; // 227 - const n = m + e; // 241 - const o = n + f; // 265 - const p = o + g; // 303 - const q = p + h; // 365 - const r = q + i; // 465 - const s = r + j; // 575 - const t = s + k; // 785 - break :blk t; - } else blk: { - const t = b + b + a; // 10 - const c = a + t; // 14 - const d = c + t; // 24 - const e = d + t; // 34 - const f = e + t; // 44 - const g = f + t; // 54 - const h = c + g; // 68 - break :blk h + b; // 71 - }; - const y = x + a; // 788, 75 - const z = y + a; // 791, 79 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.13.zig b/test/cases/x86_64-macos/assert_function.13.zig deleted file mode 100644 index 240abf0108dbe8c08040533524872e543fd6d621..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.13.zig +++ /dev/null @@ -1,19 +0,0 @@ -pub fn main() void { - const ignore = - \\ cool thx - \\ - ; - _ = ignore; - add('ぁ', '\x03'); -} - -fn add(a: u32, b: u32) void { - assert(a + b == 12356); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.14.zig b/test/cases/x86_64-macos/assert_function.14.zig deleted file mode 100644 index d25100dccee2bda1f615c2d870ee477c1252bed3..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.14.zig +++ /dev/null @@ -1,17 +0,0 @@ -pub fn main() void { - add(aa, bb); -} - -const aa = 'ぁ'; -const bb = '\x03'; - -fn add(a: u32, b: u32) void { - assert(a + b == 12356); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.15.zig b/test/cases/x86_64-macos/assert_function.15.zig deleted file mode 100644 index 33ae1ed5af1279b74f089003e7b9665b55c2489b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.15.zig +++ /dev/null @@ -1,10 +0,0 @@ -pub fn main() void { - assert("hello"[0] == 'h'); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.16.zig b/test/cases/x86_64-macos/assert_function.16.zig deleted file mode 100644 index eef113642324434c4af1723aac512a57192ce726..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.16.zig +++ /dev/null @@ -1,11 +0,0 @@ -const hello = "hello".*; -pub fn main() void { - assert(hello[1] == 'e'); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.17.zig b/test/cases/x86_64-macos/assert_function.17.zig deleted file mode 100644 index ac9dce3079f6444476afd65757675726390946cf..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.17.zig +++ /dev/null @@ -1,11 +0,0 @@ -pub fn main() void { - var i: u64 = 0xFFEEDDCCBBAA9988; - assert(i == 0xFFEEDDCCBBAA9988); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.18.zig b/test/cases/x86_64-macos/assert_function.18.zig deleted file mode 100644 index 31cf1207f3dc07541a4210641ee136eb0ba385b0..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.18.zig +++ /dev/null @@ -1,35 +0,0 @@ -const builtin = @import("builtin"); - -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - for ("hello") |_| print(); -} - -fn print() void { - switch (builtin.os.tag) { - .linux => { - asm volatile ("syscall" - : - : [number] "{rax}" (1), - [arg1] "{rdi}" (1), - [arg2] "{rsi}" (@ptrToInt("hello\n")), - [arg3] "{rdx}" (6), - : "rcx", "r11", "memory" - ); - }, - .macos => { - _ = write(1, @ptrToInt("hello\n"), 6); - }, - else => unreachable, - } -} - -// run -// -// hello -// hello -// hello -// hello -// hello -// diff --git a/test/cases/x86_64-macos/assert_function.2.zig b/test/cases/x86_64-macos/assert_function.2.zig deleted file mode 100644 index 8c1c510486185f4116841577473c901e13528283..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.2.zig +++ /dev/null @@ -1,21 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - assert(i == 100); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.3.zig b/test/cases/x86_64-macos/assert_function.3.zig deleted file mode 100644 index a6829f8e0239f8c01f0a1e4e1cf42e9ed035176b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.3.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - add(3, 4); -} - -fn add(a: u32, b: u32) void { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - const f = d + e; // 24 - const g = e + f; // 38 - const h = f + g; // 62 - const i = g + h; // 100 - const j = i + d; // 110 - assert(j == 110); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.4.zig b/test/cases/x86_64-macos/assert_function.4.zig deleted file mode 100644 index 69df4354c3eb8d72d4c91b226fbf4b4c0eddedaf..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.4.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 7); - assert(add(20, 10) == 30); -} - -fn add(a: u32, b: u32) u32 { - return a + b; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.5.zig b/test/cases/x86_64-macos/assert_function.5.zig deleted file mode 100644 index 89f3f7df4fd3f42da6650c27dff3c8160b281860..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.5.zig +++ /dev/null @@ -1,19 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 7); - assert(add(20, 10) == 30); -} - -fn add(a: u32, b: u32) u32 { - var x: u32 = undefined; - x = 0; - x += a; - x += b; - return x; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.6.zig b/test/cases/x86_64-macos/assert_function.6.zig deleted file mode 100644 index 1b1b75e68ea72902208bd0889c38202922b89a51..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.6.zig +++ /dev/null @@ -1,9 +0,0 @@ -pub fn main() void { - const a: u32 = 2; - const b: ?u32 = a; - const c = b.?; - if (c != 2) unreachable; -} - -// run -// diff --git a/test/cases/x86_64-macos/assert_function.7.zig b/test/cases/x86_64-macos/assert_function.7.zig deleted file mode 100644 index 27ba37029a8bee825a2676c78bcbeded35108033..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.7.zig +++ /dev/null @@ -1,23 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - var i: u32 = 0; - while (i < 4) : (i += 1) print(); - assert(i == 4); -} - -fn print() void { - _ = write(1, @ptrToInt("hello\n"), 6); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// -// hello -// hello -// hello -// hello -// diff --git a/test/cases/x86_64-macos/assert_function.8.zig b/test/cases/x86_64-macos/assert_function.8.zig deleted file mode 100644 index 3942a3e24b70a53c1ca54194a032a83ccca416fb..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.8.zig +++ /dev/null @@ -1,20 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - var i: u32 = 0; - inline while (i < 4) : (i += 1) print(); - assert(i == 4); -} - -fn print() void { - _ = write(1, @ptrToInt("hello\n"), 6); -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// error -// -// :5:21: error: unable to resolve comptime value -// :5:21: note: condition in comptime branch must be comptime-known diff --git a/test/cases/x86_64-macos/assert_function.9.zig b/test/cases/x86_64-macos/assert_function.9.zig deleted file mode 100644 index c754bb771133d8b3a595ec9fe46c48c4c6408e61..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/assert_function.9.zig +++ /dev/null @@ -1,22 +0,0 @@ -pub fn main() void { - assert(add(3, 4) == 20); -} - -fn add(a: u32, b: u32) u32 { - const x: u32 = blk: { - const c = a + b; // 7 - const d = a + c; // 10 - const e = d + b; // 14 - break :blk e; - }; - const y = x + a; // 17 - const z = y + a; // 20 - return z; -} - -pub fn assert(ok: bool) void { - if (!ok) unreachable; // assertion failure -} - -// run -// diff --git a/test/cases/x86_64-macos/comptime_var.0.zig b/test/cases/x86_64-macos/comptime_var.0.zig deleted file mode 100644 index b7bf9ebb14c37aa3b5e2c26ba4835c1069d8decd..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.0.zig +++ /dev/null @@ -1,12 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - comptime var b: u32 = 0; - if (a == 0) b = 3; -} - -// error -// output_mode=Exe -// target=x86_64-macos -// -// :4:19: error: store to comptime variable depends on runtime condition -// :4:11: note: runtime condition here diff --git a/test/cases/x86_64-macos/comptime_var.1.zig b/test/cases/x86_64-macos/comptime_var.1.zig deleted file mode 100644 index 054d69250c38b5c2faba39e67db1b203d7b6eec7..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.1.zig +++ /dev/null @@ -1,13 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - comptime var b: u32 = 0; - switch (a) { - 0 => {}, - else => b = 3, - } -} - -// error -// -// :6:19: error: store to comptime variable depends on runtime condition -// :4:13: note: runtime condition here diff --git a/test/cases/x86_64-macos/comptime_var.2.zig b/test/cases/x86_64-macos/comptime_var.2.zig deleted file mode 100644 index abd34255cdc70c519f9166c8a686d0febf5a9669..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.2.zig +++ /dev/null @@ -1,17 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - comptime var len: u32 = 5; - print(len); - len += 9; - print(len); -} - -fn print(len: usize) void { - _ = write(1, @ptrToInt("Hello, World!\n"), len); -} - -// run -// -// HelloHello, World! -// diff --git a/test/cases/x86_64-macos/comptime_var.3.zig b/test/cases/x86_64-macos/comptime_var.3.zig deleted file mode 100644 index 5d25d6556e4f378d4288acda9ceffcb19397230f..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.3.zig +++ /dev/null @@ -1,10 +0,0 @@ -comptime { - var x: i32 = 1; - x += 1; - if (x != 1) unreachable; -} -pub fn main() void {} - -// error -// -// :4:17: error: reached unreachable code diff --git a/test/cases/x86_64-macos/comptime_var.4.zig b/test/cases/x86_64-macos/comptime_var.4.zig deleted file mode 100644 index 74da6ef448edd5534b49b1f850673863b4188b99..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.4.zig +++ /dev/null @@ -1,9 +0,0 @@ -pub fn main() void { - comptime var i: u64 = 0; - while (i < 5) : (i += 1) {} -} - -// error -// -// :3:24: error: cannot store to comptime variable in non-inline loop -// :3:5: note: non-inline loop here diff --git a/test/cases/x86_64-macos/comptime_var.5.zig b/test/cases/x86_64-macos/comptime_var.5.zig deleted file mode 100644 index 76a06f3d4b5931e8fd23271dcc593e07ff414a7f..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.5.zig +++ /dev/null @@ -1,15 +0,0 @@ -pub fn main() void { - var a: u32 = 0; - if (a == 0) { - comptime var b: u32 = 0; - b = 1; - } -} -comptime { - var x: i32 = 1; - x += 1; - if (x != 2) unreachable; -} - -// run -// diff --git a/test/cases/x86_64-macos/comptime_var.6.zig b/test/cases/x86_64-macos/comptime_var.6.zig deleted file mode 100644 index 381e609bd1143f8284d3323ec63266e604d6719b..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/comptime_var.6.zig +++ /dev/null @@ -1,15 +0,0 @@ -extern "c" fn write(usize, usize, usize) usize; - -pub fn main() void { - comptime var i: u64 = 2; - inline while (i < 6) : (i += 1) { - print(i); - } -} -fn print(len: usize) void { - _ = write(1, @ptrToInt("Hello"), len); -} - -// run -// -// HeHelHellHello diff --git a/test/cases/x86_64-macos/hello_world_with_updates.0.zig b/test/cases/x86_64-macos/hello_world_with_updates.0.zig deleted file mode 100644 index 7fc13a4fa567ceacaf31b9e8f8916322ab987532..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.0.zig +++ /dev/null @@ -1,5 +0,0 @@ -// error -// output_mode=Exe -// target=x86_64-macos -// -// :?:?: error: root struct of file 'tmp' has no member named 'main' diff --git a/test/cases/x86_64-macos/hello_world_with_updates.1.zig b/test/cases/x86_64-macos/hello_world_with_updates.1.zig deleted file mode 100644 index dcf18bbf87713e6dcaa556378643fc88664023da..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.1.zig +++ /dev/null @@ -1,6 +0,0 @@ -pub export fn main() noreturn {} - -// error -// -// :1:22: error: function declared 'noreturn' implicitly returns -// :1:32: note: control flow reaches end of body here diff --git a/test/cases/x86_64-macos/hello_world_with_updates.2.zig b/test/cases/x86_64-macos/hello_world_with_updates.2.zig deleted file mode 100644 index fb8cb39eddf859f843ce61b068c0f6f8f9feb387..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.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/cases/x86_64-macos/hello_world_with_updates.3.zig b/test/cases/x86_64-macos/hello_world_with_updates.3.zig deleted file mode 100644 index f6e233886b0a7d616f92dd11ffb4232191c997de..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.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/cases/x86_64-macos/hello_world_with_updates.4.zig b/test/cases/x86_64-macos/hello_world_with_updates.4.zig deleted file mode 100644 index f89cef73543ce1f3e51a4e0152c0a8c367edf537..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.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/cases/x86_64-macos/hello_world_with_updates.5.zig b/test/cases/x86_64-macos/hello_world_with_updates.5.zig deleted file mode 100644 index 0d7f97578afe1274d1c8e3d356ce702992edca61..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.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/cases/x86_64-macos/hello_world_with_updates.6.zig b/test/cases/x86_64-macos/hello_world_with_updates.6.zig deleted file mode 100644 index 3ce2cb717639d663c2679dcdef2a4583c3c3f8ec..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-macos/hello_world_with_updates.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/cases/x86_64-windows/hello_world_with_updates.0.zig b/test/cases/x86_64-windows/hello_world_with_updates.0.zig deleted file mode 100644 index d322de2d1b48b596a6e0f68078f178ad3014b5b4..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-windows/hello_world_with_updates.0.zig +++ /dev/null @@ -1,7 +0,0 @@ -// error -// output_mode=Exe -// target=x86_64-windows -// -// :?:?: error: root struct of file 'tmp' has no member named 'main' -// :?:?: note: called from here -// :?:?: note: called from here diff --git a/test/cases/x86_64-windows/hello_world_with_updates.1.zig b/test/cases/x86_64-windows/hello_world_with_updates.1.zig deleted file mode 100644 index dcf18bbf87713e6dcaa556378643fc88664023da..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-windows/hello_world_with_updates.1.zig +++ /dev/null @@ -1,6 +0,0 @@ -pub export fn main() noreturn {} - -// error -// -// :1:22: error: function declared 'noreturn' implicitly returns -// :1:32: note: control flow reaches end of body here diff --git a/test/cases/x86_64-windows/hello_world_with_updates.2.zig b/test/cases/x86_64-windows/hello_world_with_updates.2.zig deleted file mode 100644 index 6c2fd5b24efe37dfa2f6f899fbe54898624cea88..0000000000000000000000000000000000000000 --- a/test/cases/x86_64-windows/hello_world_with_updates.2.zig +++ /dev/null @@ -1,16 +0,0 @@ -const std = @import("std"); - -pub fn main() void { - print(); -} - -fn print() void { - const msg = "Hello, World!\n"; - const stdout = std.io.getStdOut(); - stdout.writeAll(msg) catch unreachable; -} - -// run -// -// Hello, World! -//