| author | |
| committer | |
| log | b3f9fe6d0439bcbb5c6baa77c0646c4da2e06dd7 |
| tree | a995c358ec71a2c562cf72a13bf24b5d6af3533e |
| parent | 52fe2ebee8023944c6e701f32ab161e0c30aed5b |
| signature | Commit is signed but in an unrecognized format. |
The self-hosted aarch64 backend is not currently functional due to the
Liveness changes. A previous commit disabled aarch64 on the behavior
tests; this commit disables it and arm for the test cases. Moreover, all
incremental test cases have been unified into shared cross-platform
cases, which can be gradually enabled as the backends improve.229 files changed, 1449 insertions(+), 2531 deletions(-)
test/cases/aarch64-linux/conditional_branches.0.zig deleted-26| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo(123); | |
| 3 | } | |
| 4 | ||
| 5 | fn foo(x: u64) void { | |
| 6 | if (x > 42) { | |
| 7 | print(); | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | fn print() void { | |
| 12 | asm volatile ("svc #0" | |
| 13 | : | |
| 14 | : [number] "{x8}" (64), | |
| 15 | [arg1] "{x0}" (1), | |
| 16 | [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | |
| 17 | [arg3] "{x2}" ("Hello, World!\n".len), | |
| 18 | : "memory", "cc" | |
| 19 | ); | |
| 20 | } | |
| 21 | ||
| 22 | // run | |
| 23 | // target=aarch64-linux | |
| 24 | // | |
| 25 | // Hello, World! | |
| 26 | // |
test/cases/aarch64-linux/conditional_branches.1.zig deleted-25| ... | ... | @@ -1,25 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo(true); | |
| 3 | } | |
| 4 | ||
| 5 | fn foo(x: bool) void { | |
| 6 | if (x) { | |
| 7 | print(); | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | fn print() void { | |
| 12 | asm volatile ("svc #0" | |
| 13 | : | |
| 14 | : [number] "{x8}" (64), | |
| 15 | [arg1] "{x0}" (1), | |
| 16 | [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | |
| 17 | [arg3] "{x2}" ("Hello, World!\n".len), | |
| 18 | : "memory", "cc" | |
| 19 | ); | |
| 20 | } | |
| 21 | ||
| 22 | // run | |
| 23 | // | |
| 24 | // Hello, World! | |
| 25 | // |
test/cases/aarch64-linux/hello_world_with_updates.0.zig deleted-31| ... | ... | @@ -1,31 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | print(); | |
| 3 | exit(0); | |
| 4 | } | |
| 5 | ||
| 6 | fn print() void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{x8}" (64), | |
| 10 | [arg1] "{x0}" (1), | |
| 11 | [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | |
| 12 | [arg3] "{x2}" ("Hello, World!\n".len), | |
| 13 | : "memory", "cc" | |
| 14 | ); | |
| 15 | } | |
| 16 | ||
| 17 | fn exit(ret: usize) noreturn { | |
| 18 | asm volatile ("svc #0" | |
| 19 | : | |
| 20 | : [number] "{x8}" (93), | |
| 21 | [arg1] "{x0}" (ret), | |
| 22 | : "memory", "cc" | |
| 23 | ); | |
| 24 | unreachable; | |
| 25 | } | |
| 26 | ||
| 27 | // run | |
| 28 | // target=aarch64-linux | |
| 29 | // | |
| 30 | // Hello, World! | |
| 31 | // |
test/cases/aarch64-linux/hello_world_with_updates.1.zig deleted-36| ... | ... | @@ -1,36 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | print(); | |
| 3 | print(); | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | exit(0); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | asm volatile ("svc #0" | |
| 11 | : | |
| 12 | : [number] "{x8}" (64), | |
| 13 | [arg1] "{x0}" (1), | |
| 14 | [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | |
| 15 | [arg3] "{x2}" ("Hello, World!\n".len), | |
| 16 | : "memory", "cc" | |
| 17 | ); | |
| 18 | } | |
| 19 | ||
| 20 | fn exit(ret: usize) noreturn { | |
| 21 | asm volatile ("svc #0" | |
| 22 | : | |
| 23 | : [number] "{x8}" (93), | |
| 24 | [arg1] "{x0}" (ret), | |
| 25 | : "memory", "cc" | |
| 26 | ); | |
| 27 | unreachable; | |
| 28 | } | |
| 29 | ||
| 30 | // run | |
| 31 | // | |
| 32 | // Hello, World! | |
| 33 | // Hello, World! | |
| 34 | // Hello, World! | |
| 35 | // Hello, World! | |
| 36 | // |
test/cases/aarch64-linux/hello_world_with_updates.2.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(); | |
| 3 | print(); | |
| 4 | } | |
| 5 | ||
| 6 | fn print() void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{x8}" (64), | |
| 10 | [arg1] "{x0}" (1), | |
| 11 | [arg2] "{x1}" (@ptrToInt("Hello, World!\n")), | |
| 12 | [arg3] "{x2}" ("Hello, World!\n".len), | |
| 13 | : "memory", "cc" | |
| 14 | ); | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // | |
| 19 | // Hello, World! | |
| 20 | // Hello, World! | |
| 21 | // |
test/cases/aarch64-macos/hello_world_with_updates.0.zig deleted-5| ... | ... | @@ -1,5 +0,0 @@ |
| 1 | // error | |
| 2 | // output_mode=Exe | |
| 3 | // target=aarch64-macos | |
| 4 | // | |
| 5 | // :?:?: error: root struct of file 'tmp' has no member named 'main' |
test/cases/aarch64-macos/hello_world_with_updates.1.zig deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | pub export fn main() noreturn {} | |
| 2 | ||
| 3 | // error | |
| 4 | // | |
| 5 | // :1:22: error: function declared 'noreturn' implicitly returns | |
| 6 | // :1:32: note: control flow reaches end of body here |
test/cases/aarch64-macos/hello_world_with_updates.2.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | extern "c" fn exit(usize) noreturn; | |
| 3 | ||
| 4 | pub export fn main() noreturn { | |
| 5 | print(); | |
| 6 | ||
| 7 | exit(0); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // |
test/cases/aarch64-macos/hello_world_with_updates.3.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("Hello, World!\n"); | |
| 9 | const len = 14; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // Hello, World! | |
| 16 | // |
test/cases/aarch64-macos/hello_world_with_updates.4.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | print(); | |
| 7 | print(); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // Hello, World! | |
| 20 | // Hello, World! | |
| 21 | // Hello, World! | |
| 22 | // |
test/cases/aarch64-macos/hello_world_with_updates.5.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 9 | const len = 104; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 16 | // |
test/cases/aarch64-macos/hello_world_with_updates.6.zig deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | } | |
| 7 | ||
| 8 | fn print() void { | |
| 9 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 10 | const len = 104; | |
| 11 | _ = write(1, msg, len); | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 17 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 18 | // |
test/cases/arithmetic_operations.0.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(2, 4); | |
| 5 | print(1, 7); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(a: u32, b: u32) void { | |
| 9 | const str = "123456789"; | |
| 10 | const len = a + b; | |
| 11 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // target=x86_64-linux,x86_64-macos | |
| 16 | // | |
| 17 | // 12345612345678 |
test/cases/arithmetic_operations.1.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(10, 5); | |
| 5 | print(4, 3); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(a: u32, b: u32) void { | |
| 9 | const str = "123456789"; | |
| 10 | const len = a - b; | |
| 11 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // 123451 |
test/cases/arithmetic_operations.2.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(8, 9); | |
| 5 | print(3, 7); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(a: u32, b: u32) void { | |
| 9 | const str = "123456789"; | |
| 10 | const len = a & b; | |
| 11 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // 12345678123 |
test/cases/arithmetic_operations.3.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(4, 2); | |
| 5 | print(3, 7); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(a: u32, b: u32) void { | |
| 9 | const str = "123456789"; | |
| 10 | const len = a | b; | |
| 11 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // 1234561234567 |
test/cases/arithmetic_operations.4.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(42, 42); | |
| 5 | print(3, 5); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(a: u32, b: u32) void { | |
| 9 | const str = "123456789"; | |
| 10 | const len = a ^ b; | |
| 11 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // 123456 |
test/cases/arithmetic_operations.5.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | var x: u32 = 1; | |
| 3 | assert(x << 1 == 2); | |
| 4 | ||
| 5 | x <<= 1; | |
| 6 | assert(x << 2 == 8); | |
| 7 | assert(x << 3 == 16); | |
| 8 | } | |
| 9 | ||
| 10 | pub fn assert(ok: bool) void { | |
| 11 | if (!ok) unreachable; // assertion failure | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/arithmetic_operations.6.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 1024; | |
| 3 | assert(a >> 1 == 512); | |
| 4 | ||
| 5 | a >>= 1; | |
| 6 | assert(a >> 2 == 128); | |
| 7 | assert(a >> 3 == 64); | |
| 8 | assert(a >> 4 == 32); | |
| 9 | assert(a >> 5 == 16); | |
| 10 | assert(a >> 6 == 8); | |
| 11 | assert(a >> 7 == 4); | |
| 12 | assert(a >> 8 == 2); | |
| 13 | assert(a >> 9 == 1); | |
| 14 | } | |
| 15 | ||
| 16 | pub fn assert(ok: bool) void { | |
| 17 | if (!ok) unreachable; // assertion failure | |
| 18 | } | |
| 19 | ||
| 20 | // run | |
| 21 | // |
test/cases/arm-linux/arithmetic_operations.0.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(2, 4); | |
| 3 | print(1, 7); | |
| 4 | } | |
| 5 | ||
| 6 | fn print(a: u32, b: u32) void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg3] "{r2}" (a + b), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("123456789")), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // target=arm-linux | |
| 20 | // | |
| 21 | // 12345612345678 |
test/cases/arm-linux/arithmetic_operations.1.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(10, 5); | |
| 3 | print(4, 3); | |
| 4 | } | |
| 5 | ||
| 6 | fn print(a: u32, b: u32) void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg3] "{r2}" (a - b), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("123456789")), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // 123451 |
test/cases/arm-linux/arithmetic_operations.2.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(8, 9); | |
| 3 | print(3, 7); | |
| 4 | } | |
| 5 | ||
| 6 | fn print(a: u32, b: u32) void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg3] "{r2}" (a & b), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("123456789")), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // 12345678123 |
test/cases/arm-linux/arithmetic_operations.3.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(4, 2); | |
| 3 | print(3, 7); | |
| 4 | } | |
| 5 | ||
| 6 | fn print(a: u32, b: u32) void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg3] "{r2}" (a | b), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("123456789")), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // 1234561234567 |
test/cases/arm-linux/arithmetic_operations.4.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(42, 42); | |
| 3 | print(3, 5); | |
| 4 | } | |
| 5 | ||
| 6 | fn print(a: u32, b: u32) void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg3] "{r2}" (a ^ b), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("123456789")), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // 123456 |
test/cases/arm-linux/arithmetic_operations.5.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var x: u32 = 1; | |
| 3 | assert(x << 1 == 2); | |
| 4 | ||
| 5 | x <<= 1; | |
| 6 | assert(x << 2 == 8); | |
| 7 | assert(x << 3 == 16); | |
| 8 | } | |
| 9 | ||
| 10 | pub fn assert(ok: bool) void { | |
| 11 | if (!ok) unreachable; // assertion failure | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/arm-linux/arithmetic_operations.6.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 1024; | |
| 3 | assert(a >> 1 == 512); | |
| 4 | ||
| 5 | a >>= 1; | |
| 6 | assert(a >> 2 == 128); | |
| 7 | assert(a >> 3 == 64); | |
| 8 | assert(a >> 4 == 32); | |
| 9 | assert(a >> 5 == 16); | |
| 10 | assert(a >> 6 == 8); | |
| 11 | assert(a >> 7 == 4); | |
| 12 | assert(a >> 8 == 2); | |
| 13 | assert(a >> 9 == 1); | |
| 14 | } | |
| 15 | ||
| 16 | pub fn assert(ok: bool) void { | |
| 17 | if (!ok) unreachable; // assertion failure | |
| 18 | } | |
| 19 | ||
| 20 | // run | |
| 21 | // |
test/cases/arm-linux/errors.0.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch print(); | |
| 3 | } | |
| 4 | ||
| 5 | fn foo() anyerror!void {} | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | asm volatile ("svc #0" | |
| 9 | : | |
| 10 | : [number] "{r7}" (4), | |
| 11 | [arg1] "{r0}" (1), | |
| 12 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 13 | [arg3] "{r2}" ("Hello, World!\n".len), | |
| 14 | : "memory" | |
| 15 | ); | |
| 16 | return; | |
| 17 | } | |
| 18 | ||
| 19 | // run | |
| 20 | // target=arm-linux | |
| 21 | // |
test/cases/arm-linux/errors.1.zig deleted-24| ... | ... | @@ -1,24 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch print(); | |
| 3 | } | |
| 4 | ||
| 5 | fn foo() anyerror!void { | |
| 6 | return error.Test; | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | asm volatile ("svc #0" | |
| 11 | : | |
| 12 | : [number] "{r7}" (4), | |
| 13 | [arg1] "{r0}" (1), | |
| 14 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 15 | [arg3] "{r2}" ("Hello, World!\n".len), | |
| 16 | : "memory" | |
| 17 | ); | |
| 18 | return; | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // | |
| 23 | // Hello, World! | |
| 24 | // |
test/cases/arm-linux/errors.2.zig deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch |err| { | |
| 3 | assert(err == error.Foo); | |
| 4 | assert(err != error.Bar); | |
| 5 | assert(err != error.Baz); | |
| 6 | }; | |
| 7 | bar() catch |err| { | |
| 8 | assert(err != error.Foo); | |
| 9 | assert(err == error.Bar); | |
| 10 | assert(err != error.Baz); | |
| 11 | }; | |
| 12 | } | |
| 13 | ||
| 14 | fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; | |
| 16 | } | |
| 17 | ||
| 18 | fn foo() anyerror!void { | |
| 19 | return error.Foo; | |
| 20 | } | |
| 21 | ||
| 22 | fn bar() anyerror!void { | |
| 23 | return error.Bar; | |
| 24 | } | |
| 25 | ||
| 26 | // run | |
| 27 | // |
test/cases/arm-linux/errors.3.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch unreachable; | |
| 3 | } | |
| 4 | ||
| 5 | fn foo() anyerror!void { | |
| 6 | try bar(); | |
| 7 | } | |
| 8 | ||
| 9 | fn bar() anyerror!void {} | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/arm-linux/function_pointers.zig deleted-44| ... | ... | @@ -1,44 +0,0 @@ |
| 1 | const PrintFn = *const fn () void; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var printFn: PrintFn = stopSayingThat; | |
| 5 | var i: u32 = 0; | |
| 6 | while (i < 4) : (i += 1) printFn(); | |
| 7 | ||
| 8 | printFn = moveEveryZig; | |
| 9 | printFn(); | |
| 10 | } | |
| 11 | ||
| 12 | fn stopSayingThat() void { | |
| 13 | asm volatile ("svc #0" | |
| 14 | : | |
| 15 | : [number] "{r7}" (4), | |
| 16 | [arg1] "{r0}" (1), | |
| 17 | [arg2] "{r1}" (@ptrToInt("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n")), | |
| 18 | [arg3] "{r2}" ("Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n".len), | |
| 19 | : "memory" | |
| 20 | ); | |
| 21 | return; | |
| 22 | } | |
| 23 | ||
| 24 | fn moveEveryZig() void { | |
| 25 | asm volatile ("svc #0" | |
| 26 | : | |
| 27 | : [number] "{r7}" (4), | |
| 28 | [arg1] "{r0}" (1), | |
| 29 | [arg2] "{r1}" (@ptrToInt("All your codebase are belong to us\n")), | |
| 30 | [arg3] "{r2}" ("All your codebase are belong to us\n".len), | |
| 31 | : "memory" | |
| 32 | ); | |
| 33 | return; | |
| 34 | } | |
| 35 | ||
| 36 | // run | |
| 37 | // target=arm-linux | |
| 38 | // | |
| 39 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 40 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 41 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 42 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 43 | // All your codebase are belong to us | |
| 44 | // |
test/cases/arm-linux/hello_world_with_updates.0.zig deleted-32| ... | ... | @@ -1,32 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | print(); | |
| 3 | exit(); | |
| 4 | } | |
| 5 | ||
| 6 | fn print() void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg1] "{r0}" (1), | |
| 11 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 12 | [arg3] "{r2}" (14), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | fn exit() noreturn { | |
| 19 | asm volatile ("svc #0" | |
| 20 | : | |
| 21 | : [number] "{r7}" (1), | |
| 22 | [arg1] "{r0}" (0), | |
| 23 | : "memory" | |
| 24 | ); | |
| 25 | unreachable; | |
| 26 | } | |
| 27 | ||
| 28 | // run | |
| 29 | // target=arm-linux | |
| 30 | // | |
| 31 | // Hello, World! | |
| 32 | // |
test/cases/arm-linux/hello_world_with_updates.1.zig deleted-37| ... | ... | @@ -1,37 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | print(); | |
| 3 | print(); | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | exit(); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | asm volatile ("svc #0" | |
| 11 | : | |
| 12 | : [number] "{r7}" (4), | |
| 13 | [arg1] "{r0}" (1), | |
| 14 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 15 | [arg3] "{r2}" (14), | |
| 16 | : "memory" | |
| 17 | ); | |
| 18 | return; | |
| 19 | } | |
| 20 | ||
| 21 | fn exit() noreturn { | |
| 22 | asm volatile ("svc #0" | |
| 23 | : | |
| 24 | : [number] "{r7}" (1), | |
| 25 | [arg1] "{r0}" (0), | |
| 26 | : "memory" | |
| 27 | ); | |
| 28 | unreachable; | |
| 29 | } | |
| 30 | ||
| 31 | // run | |
| 32 | // | |
| 33 | // Hello, World! | |
| 34 | // Hello, World! | |
| 35 | // Hello, World! | |
| 36 | // Hello, World! | |
| 37 | // |
test/cases/arm-linux/hello_world_with_updates.2.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(); | |
| 3 | print(); | |
| 4 | } | |
| 5 | ||
| 6 | fn print() void { | |
| 7 | asm volatile ("svc #0" | |
| 8 | : | |
| 9 | : [number] "{r7}" (4), | |
| 10 | [arg1] "{r0}" (1), | |
| 11 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 12 | [arg3] "{r2}" (14), | |
| 13 | : "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // Hello, World! | |
| 21 | // Hello, World! | |
| 22 | // |
test/cases/arm-linux/parameters_and_return_values.0.zig deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(id(14)); | |
| 3 | } | |
| 4 | ||
| 5 | fn id(x: u32) u32 { | |
| 6 | return x; | |
| 7 | } | |
| 8 | ||
| 9 | // TODO: The parameters to the asm statement in print() had to | |
| 10 | // be in a specific order because otherwise the write to r0 | |
| 11 | // would overwrite the len parameter which resides in r0 | |
| 12 | fn print(len: u32) void { | |
| 13 | asm volatile ("svc #0" | |
| 14 | : | |
| 15 | : [number] "{r7}" (4), | |
| 16 | [arg3] "{r2}" (len), | |
| 17 | [arg1] "{r0}" (1), | |
| 18 | [arg2] "{r1}" (@ptrToInt("Hello, World!\n")), | |
| 19 | : "memory" | |
| 20 | ); | |
| 21 | return; | |
| 22 | } | |
| 23 | ||
| 24 | // run | |
| 25 | // target=arm-linux | |
| 26 | // | |
| 27 | // Hello, World! | |
| 28 | // |
test/cases/arm-linux/parameters_and_return_values.1.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(1, 2, 3, 4, 5, 6) == 21); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { | |
| 6 | return a + b + c + d + e + f; | |
| 7 | } | |
| 8 | ||
| 9 | pub fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; // assertion failure | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/arm-linux/print_u32s.zig deleted-40| ... | ... | @@ -1,40 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | printNumberHex(0x00000000); | |
| 3 | printNumberHex(0xaaaaaaaa); | |
| 4 | printNumberHex(0xdeadbeef); | |
| 5 | printNumberHex(0x31415926); | |
| 6 | } | |
| 7 | ||
| 8 | fn printNumberHex(x: u32) void { | |
| 9 | var i: u5 = 28; | |
| 10 | while (true) : (i -= 4) { | |
| 11 | const digit = (x >> i) & 0xf; | |
| 12 | asm volatile ("svc #0" | |
| 13 | : | |
| 14 | : [number] "{r7}" (4), | |
| 15 | [arg1] "{r0}" (1), | |
| 16 | [arg2] "{r1}" (@ptrToInt("0123456789abcdef") + digit), | |
| 17 | [arg3] "{r2}" (1), | |
| 18 | : "memory" | |
| 19 | ); | |
| 20 | ||
| 21 | if (i == 0) break; | |
| 22 | } | |
| 23 | asm volatile ("svc #0" | |
| 24 | : | |
| 25 | : [number] "{r7}" (4), | |
| 26 | [arg1] "{r0}" (1), | |
| 27 | [arg2] "{r1}" (@ptrToInt("\n")), | |
| 28 | [arg3] "{r2}" (1), | |
| 29 | : "memory" | |
| 30 | ); | |
| 31 | } | |
| 32 | ||
| 33 | // run | |
| 34 | // target=arm-linux | |
| 35 | // | |
| 36 | // 00000000 | |
| 37 | // aaaaaaaa | |
| 38 | // deadbeef | |
| 39 | // 31415926 | |
| 40 | // |
test/cases/arm-linux/spilling_registers.0.zig deleted-38| ... | ... | @@ -1,38 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 791); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | const k = i + j; // 210 | |
| 16 | const l = k + c; // 217 | |
| 17 | const m = l + d; // 227 | |
| 18 | const n = m + e; // 241 | |
| 19 | const o = n + f; // 265 | |
| 20 | const p = o + g; // 303 | |
| 21 | const q = p + h; // 365 | |
| 22 | const r = q + i; // 465 | |
| 23 | const s = r + j; // 575 | |
| 24 | const t = s + k; // 785 | |
| 25 | break :blk t; | |
| 26 | }; | |
| 27 | const y = x + a; // 788 | |
| 28 | const z = y + a; // 791 | |
| 29 | return z; | |
| 30 | } | |
| 31 | ||
| 32 | fn assert(ok: bool) void { | |
| 33 | if (!ok) unreachable; | |
| 34 | } | |
| 35 | ||
| 36 | // run | |
| 37 | // target=arm-linux | |
| 38 | // |
test/cases/arm-linux/spilling_registers.1.zig deleted-37| ... | ... | @@ -1,37 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(addMul(3, 4) == 357747496); | |
| 3 | } | |
| 4 | ||
| 5 | fn addMul(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | const k = i + j; // 210 | |
| 16 | const l = k + c; // 217 | |
| 17 | const m = l * d; // 2170 | |
| 18 | const n = m + e; // 2184 | |
| 19 | const o = n * f; // 52416 | |
| 20 | const p = o + g; // 52454 | |
| 21 | const q = p * h; // 3252148 | |
| 22 | const r = q + i; // 3252248 | |
| 23 | const s = r * j; // 357747280 | |
| 24 | const t = s + k; // 357747490 | |
| 25 | break :blk t; | |
| 26 | }; | |
| 27 | const y = x + a; // 357747493 | |
| 28 | const z = y + a; // 357747496 | |
| 29 | return z; | |
| 30 | } | |
| 31 | ||
| 32 | fn assert(ok: bool) void { | |
| 33 | if (!ok) unreachable; | |
| 34 | } | |
| 35 | ||
| 36 | // run | |
| 37 | // |
test/cases/assert_function.0.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | assert(a + b == 7); | |
| 7 | } | |
| 8 | ||
| 9 | pub fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; // assertion failure | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=x86_64-macos,x86_64-linux | |
| 15 | // link_libc=true |
test/cases/assert_function.1.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | assert(e == 14); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/assert_function.10.zig created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 116); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | break :blk j; | |
| 16 | }; | |
| 17 | const y = x + a; // 113 | |
| 18 | const z = y + a; // 116 | |
| 19 | return z; | |
| 20 | } | |
| 21 | ||
| 22 | pub fn assert(ok: bool) void { | |
| 23 | if (!ok) unreachable; // assertion failure | |
| 24 | } | |
| 25 | ||
| 26 | // run | |
| 27 | // |
test/cases/assert_function.11.zig created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 1221); | |
| 3 | assert(mul(3, 4) == 21609); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = j + k; // 320 | |
| 18 | const m = l + c; // 327 | |
| 19 | const n = m + d; // 337 | |
| 20 | const o = n + e; // 351 | |
| 21 | const p = o + f; // 375 | |
| 22 | const q = p + g; // 413 | |
| 23 | const r = q + h; // 475 | |
| 24 | const s = r + i; // 575 | |
| 25 | const t = s + j; // 685 | |
| 26 | const u = t + k; // 895 | |
| 27 | const v = u + l; // 1215 | |
| 28 | break :blk v; | |
| 29 | }; | |
| 30 | const y = x + a; // 1218 | |
| 31 | const z = y + a; // 1221 | |
| 32 | return z; | |
| 33 | } | |
| 34 | ||
| 35 | fn mul(a: u32, b: u32) u32 { | |
| 36 | const x: u32 = blk: { | |
| 37 | const c = a * a * a * a; // 81 | |
| 38 | const d = a * a * a * b; // 108 | |
| 39 | const e = a * a * b * a; // 108 | |
| 40 | const f = a * a * b * b; // 144 | |
| 41 | const g = a * b * a * a; // 108 | |
| 42 | const h = a * b * a * b; // 144 | |
| 43 | const i = a * b * b * a; // 144 | |
| 44 | const j = a * b * b * b; // 192 | |
| 45 | const k = b * a * a * a; // 108 | |
| 46 | const l = b * a * a * b; // 144 | |
| 47 | const m = b * a * b * a; // 144 | |
| 48 | const n = b * a * b * b; // 192 | |
| 49 | const o = b * b * a * a; // 144 | |
| 50 | const p = b * b * a * b; // 192 | |
| 51 | const q = b * b * b * a; // 192 | |
| 52 | const r = b * b * b * b; // 256 | |
| 53 | const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 | |
| 54 | break :blk s; | |
| 55 | }; | |
| 56 | const y = x * a; // 7203 | |
| 57 | const z = y * a; // 21609 | |
| 58 | return z; | |
| 59 | } | |
| 60 | ||
| 61 | pub fn assert(ok: bool) void { | |
| 62 | if (!ok) unreachable; // assertion failure | |
| 63 | } | |
| 64 | ||
| 65 | // run | |
| 66 | // |
test/cases/assert_function.12.zig created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 791); | |
| 3 | assert(add(4, 3) == 79); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = if (a < b) blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = k + c; // 217 | |
| 18 | const m = l + d; // 227 | |
| 19 | const n = m + e; // 241 | |
| 20 | const o = n + f; // 265 | |
| 21 | const p = o + g; // 303 | |
| 22 | const q = p + h; // 365 | |
| 23 | const r = q + i; // 465 | |
| 24 | const s = r + j; // 575 | |
| 25 | const t = s + k; // 785 | |
| 26 | break :blk t; | |
| 27 | } else blk: { | |
| 28 | const t = b + b + a; // 10 | |
| 29 | const c = a + t; // 14 | |
| 30 | const d = c + t; // 24 | |
| 31 | const e = d + t; // 34 | |
| 32 | const f = e + t; // 44 | |
| 33 | const g = f + t; // 54 | |
| 34 | const h = c + g; // 68 | |
| 35 | break :blk h + b; // 71 | |
| 36 | }; | |
| 37 | const y = x + a; // 788, 75 | |
| 38 | const z = y + a; // 791, 79 | |
| 39 | return z; | |
| 40 | } | |
| 41 | ||
| 42 | pub fn assert(ok: bool) void { | |
| 43 | if (!ok) unreachable; // assertion failure | |
| 44 | } | |
| 45 | ||
| 46 | // run | |
| 47 | // |
test/cases/assert_function.13.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | pub fn main() void { | |
| 2 | const ignore = | |
| 3 | \\ cool thx | |
| 4 | \\ | |
| 5 | ; | |
| 6 | _ = ignore; | |
| 7 | add('ぁ', '\x03'); | |
| 8 | } | |
| 9 | ||
| 10 | fn add(a: u32, b: u32) void { | |
| 11 | assert(a + b == 12356); | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/assert_function.14.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | pub fn main() void { | |
| 2 | add(aa, bb); | |
| 3 | } | |
| 4 | ||
| 5 | const aa = 'ぁ'; | |
| 6 | const bb = '\x03'; | |
| 7 | ||
| 8 | fn add(a: u32, b: u32) void { | |
| 9 | assert(a + b == 12356); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/assert_function.15.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | pub fn main() void { | |
| 2 | assert("hello"[0] == 'h'); | |
| 3 | } | |
| 4 | ||
| 5 | pub fn assert(ok: bool) void { | |
| 6 | if (!ok) unreachable; // assertion failure | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // |
test/cases/assert_function.16.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const hello = "hello".*; | |
| 2 | pub fn main() void { | |
| 3 | assert(hello[1] == 'e'); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/assert_function.17.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u64 = 0xFFEEDDCCBBAA9988; | |
| 3 | assert(i == 0xFFEEDDCCBBAA9988); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/assert_function.18.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | extern "c" fn write(c_int, usize, usize) usize; | |
| 4 | ||
| 5 | pub fn main() void { | |
| 6 | for ("hello") |_| print(); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // hello | |
| 16 | // hello | |
| 17 | // hello | |
| 18 | // hello | |
| 19 | // hello | |
| 20 | // |
test/cases/assert_function.2.zig created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | assert(i == 100); | |
| 14 | } | |
| 15 | ||
| 16 | pub fn assert(ok: bool) void { | |
| 17 | if (!ok) unreachable; // assertion failure | |
| 18 | } | |
| 19 | ||
| 20 | // run | |
| 21 | // |
test/cases/assert_function.3.zig created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | const j = i + d; // 110 | |
| 14 | assert(j == 110); | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/assert_function.4.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | return a + b; | |
| 8 | } | |
| 9 | ||
| 10 | pub fn assert(ok: bool) void { | |
| 11 | if (!ok) unreachable; // assertion failure | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/assert_function.5.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | var x: u32 = undefined; | |
| 8 | x = 0; | |
| 9 | x += a; | |
| 10 | x += b; | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/assert_function.6.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | pub fn main() void { | |
| 2 | const a: u32 = 2; | |
| 3 | const b: ?u32 = a; | |
| 4 | const c = b.?; | |
| 5 | if (c != 2) unreachable; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // |
test/cases/assert_function.7.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var i: u32 = 0; | |
| 5 | while (i < 4) : (i += 1) print(); | |
| 6 | assert(i == 4); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 11 | } | |
| 12 | ||
| 13 | pub fn assert(ok: bool) void { | |
| 14 | if (!ok) unreachable; // assertion failure | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // | |
| 19 | // hello | |
| 20 | // hello | |
| 21 | // hello | |
| 22 | // hello | |
| 23 | // |
test/cases/assert_function.8.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var i: u32 = 0; | |
| 5 | inline while (i < 4) : (i += 1) print(); | |
| 6 | assert(i == 4); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 11 | } | |
| 12 | ||
| 13 | pub fn assert(ok: bool) void { | |
| 14 | if (!ok) unreachable; // assertion failure | |
| 15 | } | |
| 16 | ||
| 17 | // error | |
| 18 | // | |
| 19 | // :5:21: error: unable to resolve comptime value | |
| 20 | // :5:21: note: condition in comptime branch must be comptime-known |
test/cases/assert_function.9.zig created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 20); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | break :blk e; | |
| 11 | }; | |
| 12 | const y = x + a; // 17 | |
| 13 | const z = y + a; // 20 | |
| 14 | return z; | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/break_continue.0.zig+1-1| ... | ... | @@ -5,5 +5,5 @@ pub fn main() void { |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | // run |
| 8 | // target=x86_64-linux,x86_64-macos,aarch64-linux,aarch64-macos | |
| 8 | // target=x86_64-linux,x86_64-macos | |
| 9 | 9 | // |
test/cases/comptime_var.0.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | if (a == 0) b = 3; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // output_mode=Exe | |
| 9 | // target=x86_64-macos,x86_64-linux | |
| 10 | // link_libc=true | |
| 11 | // | |
| 12 | // :4:19: error: store to comptime variable depends on runtime condition | |
| 13 | // :4:11: note: runtime condition here |
test/cases/comptime_var.1.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | switch (a) { | |
| 5 | 0 => {}, | |
| 6 | else => b = 3, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // | |
| 12 | // :6:19: error: store to comptime variable depends on runtime condition | |
| 13 | // :4:13: note: runtime condition here |
test/cases/comptime_var.2.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | comptime var len: u32 = 5; | |
| 5 | print(len); | |
| 6 | len += 9; | |
| 7 | print(len); | |
| 8 | } | |
| 9 | ||
| 10 | fn print(len: usize) void { | |
| 11 | _ = write(1, @ptrToInt("Hello, World!\n"), len); | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // HelloHello, World! | |
| 17 | // |
test/cases/comptime_var.3.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | comptime { | |
| 2 | var x: i32 = 1; | |
| 3 | x += 1; | |
| 4 | if (x != 1) unreachable; | |
| 5 | } | |
| 6 | pub fn main() void {} | |
| 7 | ||
| 8 | // error | |
| 9 | // | |
| 10 | // :4:17: error: reached unreachable code |
test/cases/comptime_var.4.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | pub fn main() void { | |
| 2 | comptime var i: u64 = 0; | |
| 3 | while (i < 5) : (i += 1) {} | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // | |
| 8 | // :3:24: error: cannot store to comptime variable in non-inline loop | |
| 9 | // :3:5: note: non-inline loop here |
test/cases/comptime_var.5.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | if (a == 0) { | |
| 4 | comptime var b: u32 = 0; | |
| 5 | b = 1; | |
| 6 | } | |
| 7 | } | |
| 8 | comptime { | |
| 9 | var x: i32 = 1; | |
| 10 | x += 1; | |
| 11 | if (x != 2) unreachable; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/comptime_var.6.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | comptime var i: u64 = 2; | |
| 5 | inline while (i < 6) : (i += 1) { | |
| 6 | print(i); | |
| 7 | } | |
| 8 | } | |
| 9 | fn print(len: usize) void { | |
| 10 | _ = write(1, @ptrToInt("Hello"), len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // HeHelHellHello |
test/cases/conditional_branches.0.zig created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | foo(123); | |
| 5 | } | |
| 6 | ||
| 7 | fn foo(x: u64) void { | |
| 8 | if (x > 42) { | |
| 9 | print(); | |
| 10 | } | |
| 11 | } | |
| 12 | ||
| 13 | fn print() void { | |
| 14 | const str = "Hello, World!\n"; | |
| 15 | _ = write(1, @ptrToInt(str.ptr), ptr.len); | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // target=x86_64-linux,x86_64-macos | |
| 20 | // link_libc=true | |
| 21 | // | |
| 22 | // Hello, World! | |
| 23 | // |
test/cases/conditional_branches.1.zig created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | foo(true); | |
| 5 | } | |
| 6 | ||
| 7 | fn foo(x: bool) void { | |
| 8 | if (x) { | |
| 9 | print(); | |
| 10 | print(); | |
| 11 | } else { | |
| 12 | print(); | |
| 13 | } | |
| 14 | } | |
| 15 | ||
| 16 | fn print() void { | |
| 17 | const str = "Hello, World!\n"; | |
| 18 | _ = write(1, @ptrToInt(str.ptr), ptr.len); | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // | |
| 23 | // Hello, World! | |
| 24 | // Hello, World! | |
| 25 | // |
test/cases/conditions.0.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i > @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } | |
| 6 | return i - 15; | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // target=wasm32-wasi | |
| 11 | // |
test/cases/conditions.1.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else { | |
| 6 | i = 2; | |
| 7 | } | |
| 8 | return i - 2; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/conditions.2.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else if (i == @as(u8, 5)) { | |
| 6 | i = 20; | |
| 7 | } | |
| 8 | return i - 20; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/conditions.3.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 11; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else { | |
| 6 | if (i > @as(u8, 10)) { | |
| 7 | i += 20; | |
| 8 | } else { | |
| 9 | i = 20; | |
| 10 | } | |
| 11 | } | |
| 12 | return i - 31; | |
| 13 | } | |
| 14 | ||
| 15 | // run | |
| 16 | // |
test/cases/conditions.4.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(foo(true) != @as(i32, 30)); | |
| 3 | } | |
| 4 | ||
| 5 | fn assert(ok: bool) void { | |
| 6 | if (!ok) unreachable; | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(ok: bool) i32 { | |
| 10 | const x = if (ok) @as(i32, 20) else @as(i32, 10); | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/conditions.5.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(foo(false) == @as(i32, 20)); | |
| 3 | assert(foo(true) == @as(i32, 30)); | |
| 4 | } | |
| 5 | ||
| 6 | fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; | |
| 8 | } | |
| 9 | ||
| 10 | fn foo(ok: bool) i32 { | |
| 11 | const val: i32 = blk: { | |
| 12 | var x: i32 = 1; | |
| 13 | if (!ok) break :blk x + @as(i32, 9); | |
| 14 | break :blk x + @as(i32, 19); | |
| 15 | }; | |
| 16 | return val + 10; | |
| 17 | } | |
| 18 | ||
| 19 | // run | |
| 20 | // |
test/cases/error_unions.0.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() void { | |
| 2 | var e1 = error.Foo; | |
| 3 | var e2 = error.Bar; | |
| 4 | assert(e1 != e2); | |
| 5 | assert(e1 == error.Foo); | |
| 6 | assert(e2 == error.Bar); | |
| 7 | } | |
| 8 | ||
| 9 | fn assert(b: bool) void { | |
| 10 | if (!b) unreachable; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=wasm32-wasi | |
| 15 | // |
test/cases/error_unions.1.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e: anyerror!u8 = 5; | |
| 3 | const i = e catch 10; | |
| 4 | return i - 5; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/error_unions.2.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e: anyerror!u8 = error.Foo; | |
| 3 | const i = e catch 10; | |
| 4 | return i - 10; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/error_unions.3.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 69; | |
| 4 | return i - 5; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return 5; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/error_unions.4.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 69; | |
| 4 | return i - 69; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return error.Bruh; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/error_unions.5.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 42; | |
| 4 | return i - 42; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return error.Dab; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/errors.0.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | foo() catch print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!void {} | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = std.os.write(1, "Hello, World!\n") catch {}; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=x86_64-macos | |
| 15 | // |
test/cases/errors.1.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | foo() catch print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!void { | |
| 8 | return error.Test; | |
| 9 | } | |
| 10 | ||
| 11 | fn print() void { | |
| 12 | _ = std.os.write(1, "Hello, World!\n") catch {}; | |
| 13 | } | |
| 14 | ||
| 15 | // run | |
| 16 | // | |
| 17 | // Hello, World! | |
| 18 | // |
test/cases/errors.2.zig created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch |err| { | |
| 3 | assert(err == error.Foo); | |
| 4 | assert(err != error.Bar); | |
| 5 | assert(err != error.Baz); | |
| 6 | }; | |
| 7 | bar() catch |err| { | |
| 8 | assert(err != error.Foo); | |
| 9 | assert(err == error.Bar); | |
| 10 | assert(err != error.Baz); | |
| 11 | }; | |
| 12 | } | |
| 13 | ||
| 14 | fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; | |
| 16 | } | |
| 17 | ||
| 18 | fn foo() anyerror!void { | |
| 19 | return error.Foo; | |
| 20 | } | |
| 21 | ||
| 22 | fn bar() anyerror!void { | |
| 23 | return error.Bar; | |
| 24 | } | |
| 25 | ||
| 26 | // run | |
| 27 | // |
test/cases/errors.3.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() void { | |
| 2 | foo() catch unreachable; | |
| 3 | } | |
| 4 | ||
| 5 | fn foo() anyerror!void { | |
| 6 | try bar(); | |
| 7 | } | |
| 8 | ||
| 9 | fn bar() anyerror!void {} | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/exit.zig created+5| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | pub fn main() void {} | |
| 2 | ||
| 3 | // run | |
| 4 | // target=x86_64-linux,x86_64-macos,x86_64-windows,x86_64-plan9 | |
| 5 | // |
test/cases/function_pointers.zig created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | const PrintFn = *const fn () void; | |
| 4 | ||
| 5 | pub fn main() void { | |
| 6 | var printFn: PrintFn = stopSayingThat; | |
| 7 | var i: u32 = 0; | |
| 8 | while (i < 4) : (i += 1) printFn(); | |
| 9 | ||
| 10 | printFn = moveEveryZig; | |
| 11 | printFn(); | |
| 12 | } | |
| 13 | ||
| 14 | fn stopSayingThat() void { | |
| 15 | _ = std.os.write(1, "Hello, my name is Inigo Montoya; you killed my father, prepare to die.\n") catch {}; | |
| 16 | } | |
| 17 | ||
| 18 | fn moveEveryZig() void { | |
| 19 | _ = std.os.write(1, "All your codebase are belong to us\n") catch {}; | |
| 20 | } | |
| 21 | ||
| 22 | // run | |
| 23 | // target=x86_64-macos | |
| 24 | // | |
| 25 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 26 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 27 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 28 | // Hello, my name is Inigo Montoya; you killed my father, prepare to die. | |
| 29 | // All your codebase are belong to us | |
| 30 | // |
test/cases/hello_world_with_updates.0.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | // error | |
| 2 | // output_mode=Exe | |
| 3 | // target=x86_64-linux,x86_64-macos | |
| 4 | // link_libc=true | |
| 5 | // | |
| 6 | // :?:?: error: root struct of file 'tmp' has no member named 'main' |
test/cases/hello_world_with_updates.1.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | pub export fn main() noreturn {} | |
| 2 | ||
| 3 | // error | |
| 4 | // | |
| 5 | // :1:22: error: function declared 'noreturn' implicitly returns | |
| 6 | // :1:32: note: control flow reaches end of body here |
test/cases/hello_world_with_updates.2.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | extern "c" fn exit(c_int) noreturn; | |
| 3 | ||
| 4 | pub export fn main() noreturn { | |
| 5 | print(); | |
| 6 | ||
| 7 | exit(0); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // |
test/cases/hello_world_with_updates.3.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("Hello, World!\n"); | |
| 9 | const len = 14; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // Hello, World! | |
| 16 | // |
test/cases/hello_world_with_updates.4.zig created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | print(); | |
| 7 | print(); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // Hello, World! | |
| 20 | // Hello, World! | |
| 21 | // Hello, World! | |
| 22 | // |
test/cases/hello_world_with_updates.5.zig created+16| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | extern "c" fn write(c_int, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 9 | const len = 104; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 16 | // |
test/cases/hello_world_with_updates.6.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | extern "c" fn write(c_int, usize, usize) usize; | |
| 4 | ||
| 5 | pub fn main() void { | |
| 6 | print(); | |
| 7 | print(); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 12 | const len = 104; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 19 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 20 | // |
test/cases/large_add_function.zig+3-1| ... | ... | @@ -33,6 +33,8 @@ fn assert(ok: bool) void { |
| 33 | 33 | if (!ok) unreachable; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | // TODO: enable this for native backend | |
| 37 | ||
| 36 | 38 | // run |
| 39 | // backend=llvm | |
| 37 | 40 | // target=aarch64-linux,aarch64-macos |
| 38 | // |
test/cases/locals.0.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u8 = 5; | |
| 3 | var y: f32 = 42.0; | |
| 4 | var x: u8 = 10; | |
| 5 | if (false) { | |
| 6 | y; | |
| 7 | x; | |
| 8 | } | |
| 9 | if (i != 5) unreachable; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // target=wasm32-wasi | |
| 14 | // |
test/cases/locals.1.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u8 = 5; | |
| 3 | var y: f32 = 42.0; | |
| 4 | _ = y; | |
| 5 | var x: u8 = 10; | |
| 6 | foo(i, x); | |
| 7 | i = x; | |
| 8 | if (i != 10) unreachable; | |
| 9 | } | |
| 10 | fn foo(x: u8, y: u8) void { | |
| 11 | _ = y; | |
| 12 | var i: u8 = 10; | |
| 13 | i = x; | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/only_1_function_and_it_gets_updated.0.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | while (true) {} | |
| 3 | } | |
| 4 | ||
| 5 | // run | |
| 6 | // target=x86_64-linux,x86_64-macos | |
| 7 | // |
test/cases/only_1_function_and_it_gets_updated.1.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | var dummy: u32 = 10; | |
| 3 | _ = dummy; | |
| 4 | while (true) {} | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/optionals.0.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = 5; | |
| 3 | var y: u8 = 0; | |
| 4 | if (x) |val| { | |
| 5 | y = val; | |
| 6 | } | |
| 7 | return y - 5; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // target=wasm32-wasi | |
| 12 | // |
test/cases/optionals.1.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = null; | |
| 3 | var y: u8 = 0; | |
| 4 | if (x) |val| { | |
| 5 | y = val; | |
| 6 | } | |
| 7 | return y; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/optionals.2.zig created+7| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = 5; | |
| 3 | return x.? - 5; | |
| 4 | } | |
| 5 | ||
| 6 | // run | |
| 7 | // |
test/cases/optionals.3.zig created+8| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 5; | |
| 3 | var y: ?u8 = x; | |
| 4 | return y.? - 5; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/optionals.4.zig created+13| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: ?u8 = 5; | |
| 3 | while (val) |*v| { | |
| 4 | v.* -= 1; | |
| 5 | if (v.* == 2) { | |
| 6 | val = null; | |
| 7 | } | |
| 8 | } | |
| 9 | return 0; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // |
test/cases/parameters_and_return_values.0.zig created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(id(14)); | |
| 5 | } | |
| 6 | ||
| 7 | fn id(x: u32) u32 { | |
| 8 | return x; | |
| 9 | } | |
| 10 | ||
| 11 | fn print(len: u32) void { | |
| 12 | const str = "Hello, World!\n"; | |
| 13 | _ = std.os.write(1, str[0..len]) catch {}; | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // target=x86_64-macos | |
| 18 | // | |
| 19 | // Hello, World! | |
| 20 | // |
test/cases/parameters_and_return_values.1.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(1, 2, 3, 4, 5, 6) == 21); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 { | |
| 6 | return a + b + c + d + e + f; | |
| 7 | } | |
| 8 | ||
| 9 | pub fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; // assertion failure | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/plan9/exit.zig deleted-5| ... | ... | @@ -1,5 +0,0 @@ |
| 1 | pub fn main() void {} | |
| 2 | ||
| 3 | // run | |
| 4 | // target=x86_64-plan9 | |
| 5 | // |
test/cases/plan9/hello_world_with_updates.0.zig deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | const str = "Hello World!\n"; | |
| 3 | asm volatile ( | |
| 4 | \\push $0 | |
| 5 | \\push %%r10 | |
| 6 | \\push %%r11 | |
| 7 | \\push $1 | |
| 8 | \\push $0 | |
| 9 | \\syscall | |
| 10 | \\pop %%r11 | |
| 11 | \\pop %%r11 | |
| 12 | \\pop %%r11 | |
| 13 | \\pop %%r11 | |
| 14 | \\pop %%r11 | |
| 15 | : | |
| 16 | // pwrite | |
| 17 | : [syscall_number] "{rbp}" (51), | |
| 18 | [hey] "{r11}" (@ptrToInt(str)), | |
| 19 | [strlen] "{r10}" (str.len), | |
| 20 | : "rcx", "rbp", "r11", "memory" | |
| 21 | ); | |
| 22 | } | |
| 23 | ||
| 24 | // run | |
| 25 | // target=x86_64-plan9 | |
| 26 | // | |
| 27 | // Hello World | |
| 28 | // |
test/cases/plan9/hello_world_with_updates.1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | pub fn main() void { | |
| 3 | const str = "Hello World!\n"; | |
| 4 | _ = std.os.plan9.pwrite(1, str, str.len, 0); | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // target=x86_64-plan9 | |
| 9 | // | |
| 10 | // Hello World | |
| 11 | // |
test/cases/pointers.0.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 0; | |
| 3 | ||
| 4 | foo(&x); | |
| 5 | return x - 2; | |
| 6 | } | |
| 7 | ||
| 8 | fn foo(x: *u8) void { | |
| 9 | x.* = 2; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // target=wasm32-wasi | |
| 14 | // |
test/cases/pointers.1.zig created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 0; | |
| 3 | ||
| 4 | foo(&x); | |
| 5 | bar(&x); | |
| 6 | return x - 4; | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(x: *u8) void { | |
| 10 | x.* = 2; | |
| 11 | } | |
| 12 | ||
| 13 | fn bar(x: *u8) void { | |
| 14 | x.* += 2; | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // |
test/cases/print_u32s.zig created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | printNumberHex(0x00000000); | |
| 5 | printNumberHex(0xaaaaaaaa); | |
| 6 | printNumberHex(0xdeadbeef); | |
| 7 | printNumberHex(0x31415926); | |
| 8 | } | |
| 9 | ||
| 10 | fn printNumberHex(x: u32) void { | |
| 11 | const digit_chars = "0123456789abcdef"; | |
| 12 | var i: u5 = 28; | |
| 13 | while (true) : (i -= 4) { | |
| 14 | const digit = (x >> i) & 0xf; | |
| 15 | _ = std.os.write(1, &.{digit_chars[digit]}) catch {}; | |
| 16 | if (i == 0) break; | |
| 17 | } | |
| 18 | _ = std.os.write(1, "\n") catch {}; | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // target=x86_64-macos | |
| 23 | // | |
| 24 | // 00000000 | |
| 25 | // aaaaaaaa | |
| 26 | // deadbeef | |
| 27 | // 31415926 | |
| 28 | // |
test/cases/recursive_fibonacci.zig+1-1| ... | ... | @@ -20,5 +20,5 @@ fn assert(ok: bool) void { |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // run |
| 23 | // target=x86_64-linux,x86_64-macos,arm-linux,wasm32-wasi | |
| 23 | // target=x86_64-linux,x86_64-macos,wasm32-wasi | |
| 24 | 24 | // |
test/cases/spilling_registers.0.zig created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 791); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | const k = i + j; // 210 | |
| 16 | const l = k + c; // 217 | |
| 17 | const m = l + d; // 227 | |
| 18 | const n = m + e; // 241 | |
| 19 | const o = n + f; // 265 | |
| 20 | const p = o + g; // 303 | |
| 21 | const q = p + h; // 365 | |
| 22 | const r = q + i; // 465 | |
| 23 | const s = r + j; // 575 | |
| 24 | const t = s + k; // 785 | |
| 25 | break :blk t; | |
| 26 | }; | |
| 27 | const y = x + a; // 788 | |
| 28 | const z = y + a; // 791 | |
| 29 | return z; | |
| 30 | } | |
| 31 | ||
| 32 | fn assert(ok: bool) void { | |
| 33 | if (!ok) unreachable; | |
| 34 | } | |
| 35 | ||
| 36 | // run | |
| 37 | // target=x86_64-linux,x86_64-macos | |
| 38 | // |
test/cases/spilling_registers.1.zig created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(addMul(3, 4) == 357747496); | |
| 3 | } | |
| 4 | ||
| 5 | fn addMul(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | const k = i + j; // 210 | |
| 16 | const l = k + c; // 217 | |
| 17 | const m = l * d; // 2170 | |
| 18 | const n = m + e; // 2184 | |
| 19 | const o = n * f; // 52416 | |
| 20 | const p = o + g; // 52454 | |
| 21 | const q = p * h; // 3252148 | |
| 22 | const r = q + i; // 3252248 | |
| 23 | const s = r * j; // 357747280 | |
| 24 | const t = s + k; // 357747490 | |
| 25 | break :blk t; | |
| 26 | }; | |
| 27 | const y = x + a; // 357747493 | |
| 28 | const z = y + a; // 357747496 | |
| 29 | return z; | |
| 30 | } | |
| 31 | ||
| 32 | fn assert(ok: bool) void { | |
| 33 | if (!ok) unreachable; | |
| 34 | } | |
| 35 | ||
| 36 | // run | |
| 37 | // |
test/cases/structs.0.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const Example = struct { x: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5 }; | |
| 5 | return example.x - 5; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // target=wasm32-wasi | |
| 10 | // |
test/cases/structs.1.zig created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | const Example = struct { x: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5 }; | |
| 5 | example.x = 10; | |
| 6 | return example.x - 10; | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // |
test/cases/structs.2.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | return example.y + example.x - 15; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // |
test/cases/structs.3.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | var example2: Example = .{ .x = 10, .y = 20 }; | |
| 6 | ||
| 7 | example = example2; | |
| 8 | return example.y + example.x - 30; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/structs.4.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | ||
| 6 | example = .{ .x = 10, .y = 20 }; | |
| 7 | return example.y + example.x - 30; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/switch.0.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 1; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 2; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=wasm32-wasi | |
| 15 | // |
test/cases/switch.1.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 2; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 3; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/switch.2.zig created+14| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 10; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 5; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/switch.3.zig created+15| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | const MyEnum = enum { One, Two, Three }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var val: MyEnum = .Two; | |
| 5 | var a: u8 = switch (val) { | |
| 6 | .One => 1, | |
| 7 | .Two => 2, | |
| 8 | .Three => 3, | |
| 9 | }; | |
| 10 | ||
| 11 | return a - 2; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/wasm-wasi/conditions.0.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i > @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } | |
| 6 | return i - 15; | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // target=wasm32-wasi | |
| 11 | // |
test/cases/wasm-wasi/conditions.1.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else { | |
| 6 | i = 2; | |
| 7 | } | |
| 8 | return i - 2; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/conditions.2.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 5; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else if (i == @as(u8, 5)) { | |
| 6 | i = 20; | |
| 7 | } | |
| 8 | return i - 20; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/conditions.3.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 11; | |
| 3 | if (i < @as(u8, 4)) { | |
| 4 | i += 10; | |
| 5 | } else { | |
| 6 | if (i > @as(u8, 10)) { | |
| 7 | i += 20; | |
| 8 | } else { | |
| 9 | i = 20; | |
| 10 | } | |
| 11 | } | |
| 12 | return i - 31; | |
| 13 | } | |
| 14 | ||
| 15 | // run | |
| 16 | // |
test/cases/wasm-wasi/conditions.4.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(foo(true) != @as(i32, 30)); | |
| 3 | } | |
| 4 | ||
| 5 | fn assert(ok: bool) void { | |
| 6 | if (!ok) unreachable; | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(ok: bool) i32 { | |
| 10 | const x = if (ok) @as(i32, 20) else @as(i32, 10); | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/wasm-wasi/conditions.5.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(foo(false) == @as(i32, 20)); | |
| 3 | assert(foo(true) == @as(i32, 30)); | |
| 4 | } | |
| 5 | ||
| 6 | fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; | |
| 8 | } | |
| 9 | ||
| 10 | fn foo(ok: bool) i32 { | |
| 11 | const val: i32 = blk: { | |
| 12 | var x: i32 = 1; | |
| 13 | if (!ok) break :blk x + @as(i32, 9); | |
| 14 | break :blk x + @as(i32, 19); | |
| 15 | }; | |
| 16 | return val + 10; | |
| 17 | } | |
| 18 | ||
| 19 | // run | |
| 20 | // |
test/cases/wasm-wasi/error_unions.0.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var e1 = error.Foo; | |
| 3 | var e2 = error.Bar; | |
| 4 | assert(e1 != e2); | |
| 5 | assert(e1 == error.Foo); | |
| 6 | assert(e2 == error.Bar); | |
| 7 | } | |
| 8 | ||
| 9 | fn assert(b: bool) void { | |
| 10 | if (!b) unreachable; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=wasm32-wasi | |
| 15 | // |
test/cases/wasm-wasi/error_unions.1.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e: anyerror!u8 = 5; | |
| 3 | const i = e catch 10; | |
| 4 | return i - 5; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/wasm-wasi/error_unions.2.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e: anyerror!u8 = error.Foo; | |
| 3 | const i = e catch 10; | |
| 4 | return i - 10; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/wasm-wasi/error_unions.3.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 69; | |
| 4 | return i - 5; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return 5; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/error_unions.4.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 69; | |
| 4 | return i - 69; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return error.Bruh; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/error_unions.5.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var e = foo(); | |
| 3 | const i = e catch 42; | |
| 4 | return i - 42; | |
| 5 | } | |
| 6 | ||
| 7 | fn foo() anyerror!u8 { | |
| 8 | return error.Dab; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/locals.0.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u8 = 5; | |
| 3 | var y: f32 = 42.0; | |
| 4 | var x: u8 = 10; | |
| 5 | if (false) { | |
| 6 | y; | |
| 7 | x; | |
| 8 | } | |
| 9 | if (i != 5) unreachable; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // target=wasm32-wasi | |
| 14 | // |
test/cases/wasm-wasi/locals.1.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u8 = 5; | |
| 3 | var y: f32 = 42.0; | |
| 4 | _ = y; | |
| 5 | var x: u8 = 10; | |
| 6 | foo(i, x); | |
| 7 | i = x; | |
| 8 | if (i != 10) unreachable; | |
| 9 | } | |
| 10 | fn foo(x: u8, y: u8) void { | |
| 11 | _ = y; | |
| 12 | var i: u8 = 10; | |
| 13 | i = x; | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/wasm-wasi/optionals.0.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = 5; | |
| 3 | var y: u8 = 0; | |
| 4 | if (x) |val| { | |
| 5 | y = val; | |
| 6 | } | |
| 7 | return y - 5; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // target=wasm32-wasi | |
| 12 | // |
test/cases/wasm-wasi/optionals.1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = null; | |
| 3 | var y: u8 = 0; | |
| 4 | if (x) |val| { | |
| 5 | y = val; | |
| 6 | } | |
| 7 | return y; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/wasm-wasi/optionals.2.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: ?u8 = 5; | |
| 3 | return x.? - 5; | |
| 4 | } | |
| 5 | ||
| 6 | // run | |
| 7 | // |
test/cases/wasm-wasi/optionals.3.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 5; | |
| 3 | var y: ?u8 = x; | |
| 4 | return y.? - 5; | |
| 5 | } | |
| 6 | ||
| 7 | // run | |
| 8 | // |
test/cases/wasm-wasi/optionals.4.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: ?u8 = 5; | |
| 3 | while (val) |*v| { | |
| 4 | v.* -= 1; | |
| 5 | if (v.* == 2) { | |
| 6 | val = null; | |
| 7 | } | |
| 8 | } | |
| 9 | return 0; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // |
test/cases/wasm-wasi/pointers.0.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 0; | |
| 3 | ||
| 4 | foo(&x); | |
| 5 | return x - 2; | |
| 6 | } | |
| 7 | ||
| 8 | fn foo(x: *u8) void { | |
| 9 | x.* = 2; | |
| 10 | } | |
| 11 | ||
| 12 | // run | |
| 13 | // target=wasm32-wasi | |
| 14 | // |
test/cases/wasm-wasi/pointers.1.zig deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var x: u8 = 0; | |
| 3 | ||
| 4 | foo(&x); | |
| 5 | bar(&x); | |
| 6 | return x - 4; | |
| 7 | } | |
| 8 | ||
| 9 | fn foo(x: *u8) void { | |
| 10 | x.* = 2; | |
| 11 | } | |
| 12 | ||
| 13 | fn bar(x: *u8) void { | |
| 14 | x.* += 2; | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // |
test/cases/wasm-wasi/structs.0.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const Example = struct { x: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5 }; | |
| 5 | return example.x - 5; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // target=wasm32-wasi | |
| 10 | // |
test/cases/wasm-wasi/structs.1.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | const Example = struct { x: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5 }; | |
| 5 | example.x = 10; | |
| 6 | return example.x - 10; | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // |
test/cases/wasm-wasi/structs.2.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | return example.y + example.x - 15; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // |
test/cases/wasm-wasi/structs.3.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | var example2: Example = .{ .x = 10, .y = 20 }; | |
| 6 | ||
| 7 | example = example2; | |
| 8 | return example.y + example.x - 30; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/wasm-wasi/structs.4.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const Example = struct { x: u8, y: u8 }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var example: Example = .{ .x = 5, .y = 10 }; | |
| 5 | ||
| 6 | example = .{ .x = 10, .y = 20 }; | |
| 7 | return example.y + example.x - 30; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/wasm-wasi/switch.0.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 1; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 2; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=wasm32-wasi | |
| 15 | // |
test/cases/wasm-wasi/switch.1.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 2; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 3; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/wasm-wasi/switch.2.zig deleted-14| ... | ... | @@ -1,14 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var val: u8 = 10; | |
| 3 | var a: u8 = switch (val) { | |
| 4 | 0, 1 => 2, | |
| 5 | 2 => 3, | |
| 6 | 3 => 4, | |
| 7 | else => 5, | |
| 8 | }; | |
| 9 | ||
| 10 | return a - 5; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // |
test/cases/wasm-wasi/switch.3.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | const MyEnum = enum { One, Two, Three }; | |
| 2 | ||
| 3 | pub fn main() u8 { | |
| 4 | var val: MyEnum = .Two; | |
| 5 | var a: u8 = switch (val) { | |
| 6 | .One => 1, | |
| 7 | .Two => 2, | |
| 8 | .Three => 3, | |
| 9 | }; | |
| 10 | ||
| 11 | return a - 2; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/wasm-wasi/while_loops.0.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 5)) { | |
| 4 | i += 1; | |
| 5 | } | |
| 6 | ||
| 7 | return i - 5; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // target=wasm32-wasi | |
| 12 | // |
test/cases/wasm-wasi/while_loops.1.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 10)) { | |
| 4 | var x: u8 = 1; | |
| 5 | i += x; | |
| 6 | } | |
| 7 | return i - 10; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/wasm-wasi/while_loops.2.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 10)) { | |
| 4 | var x: u8 = 1; | |
| 5 | i += x; | |
| 6 | if (i == @as(u8, 5)) break; | |
| 7 | } | |
| 8 | return i - 5; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/while_loops.0.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 5)) { | |
| 4 | i += 1; | |
| 5 | } | |
| 6 | ||
| 7 | return i - 5; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // target=wasm32-wasi | |
| 12 | // |
test/cases/while_loops.1.zig created+11| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 10)) { | |
| 4 | var x: u8 = 1; | |
| 5 | i += x; | |
| 6 | } | |
| 7 | return i - 10; | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/while_loops.2.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | pub fn main() u8 { | |
| 2 | var i: u8 = 0; | |
| 3 | while (i < @as(u8, 10)) { | |
| 4 | var x: u8 = 1; | |
| 5 | i += x; | |
| 6 | if (i == @as(u8, 5)) break; | |
| 7 | } | |
| 8 | return i - 5; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/x86_64-linux/assert_function.0.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | assert(a + b == 7); | |
| 7 | } | |
| 8 | ||
| 9 | pub fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; // assertion failure | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=x86_64-linux | |
| 15 | // |
test/cases/x86_64-linux/assert_function.1.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | assert(e == 14); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/x86_64-linux/assert_function.10.zig deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 116); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | break :blk j; | |
| 16 | }; | |
| 17 | const y = x + a; // 113 | |
| 18 | const z = y + a; // 116 | |
| 19 | return z; | |
| 20 | } | |
| 21 | ||
| 22 | pub fn assert(ok: bool) void { | |
| 23 | if (!ok) unreachable; // assertion failure | |
| 24 | } | |
| 25 | ||
| 26 | // run | |
| 27 | // |
test/cases/x86_64-linux/assert_function.11.zig deleted-66| ... | ... | @@ -1,66 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 1221); | |
| 3 | assert(mul(3, 4) == 21609); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = j + k; // 320 | |
| 18 | const m = l + c; // 327 | |
| 19 | const n = m + d; // 337 | |
| 20 | const o = n + e; // 351 | |
| 21 | const p = o + f; // 375 | |
| 22 | const q = p + g; // 413 | |
| 23 | const r = q + h; // 475 | |
| 24 | const s = r + i; // 575 | |
| 25 | const t = s + j; // 685 | |
| 26 | const u = t + k; // 895 | |
| 27 | const v = u + l; // 1215 | |
| 28 | break :blk v; | |
| 29 | }; | |
| 30 | const y = x + a; // 1218 | |
| 31 | const z = y + a; // 1221 | |
| 32 | return z; | |
| 33 | } | |
| 34 | ||
| 35 | fn mul(a: u32, b: u32) u32 { | |
| 36 | const x: u32 = blk: { | |
| 37 | const c = a * a * a * a; // 81 | |
| 38 | const d = a * a * a * b; // 108 | |
| 39 | const e = a * a * b * a; // 108 | |
| 40 | const f = a * a * b * b; // 144 | |
| 41 | const g = a * b * a * a; // 108 | |
| 42 | const h = a * b * a * b; // 144 | |
| 43 | const i = a * b * b * a; // 144 | |
| 44 | const j = a * b * b * b; // 192 | |
| 45 | const k = b * a * a * a; // 108 | |
| 46 | const l = b * a * a * b; // 144 | |
| 47 | const m = b * a * b * a; // 144 | |
| 48 | const n = b * a * b * b; // 192 | |
| 49 | const o = b * b * a * a; // 144 | |
| 50 | const p = b * b * a * b; // 192 | |
| 51 | const q = b * b * b * a; // 192 | |
| 52 | const r = b * b * b * b; // 256 | |
| 53 | const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 | |
| 54 | break :blk s; | |
| 55 | }; | |
| 56 | const y = x * a; // 7203 | |
| 57 | const z = y * a; // 21609 | |
| 58 | return z; | |
| 59 | } | |
| 60 | ||
| 61 | pub fn assert(ok: bool) void { | |
| 62 | if (!ok) unreachable; // assertion failure | |
| 63 | } | |
| 64 | ||
| 65 | // run | |
| 66 | // |
test/cases/x86_64-linux/assert_function.12.zig deleted-47| ... | ... | @@ -1,47 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 791); | |
| 3 | assert(add(4, 3) == 79); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = if (a < b) blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = k + c; // 217 | |
| 18 | const m = l + d; // 227 | |
| 19 | const n = m + e; // 241 | |
| 20 | const o = n + f; // 265 | |
| 21 | const p = o + g; // 303 | |
| 22 | const q = p + h; // 365 | |
| 23 | const r = q + i; // 465 | |
| 24 | const s = r + j; // 575 | |
| 25 | const t = s + k; // 785 | |
| 26 | break :blk t; | |
| 27 | } else blk: { | |
| 28 | const t = b + b + a; // 10 | |
| 29 | const c = a + t; // 14 | |
| 30 | const d = c + t; // 24 | |
| 31 | const e = d + t; // 34 | |
| 32 | const f = e + t; // 44 | |
| 33 | const g = f + t; // 54 | |
| 34 | const h = c + g; // 68 | |
| 35 | break :blk h + b; // 71 | |
| 36 | }; | |
| 37 | const y = x + a; // 788, 75 | |
| 38 | const z = y + a; // 791, 79 | |
| 39 | return z; | |
| 40 | } | |
| 41 | ||
| 42 | pub fn assert(ok: bool) void { | |
| 43 | if (!ok) unreachable; // assertion failure | |
| 44 | } | |
| 45 | ||
| 46 | // run | |
| 47 | // |
test/cases/x86_64-linux/assert_function.13.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | const ignore = | |
| 3 | \\ cool thx | |
| 4 | \\ | |
| 5 | ; | |
| 6 | _ = ignore; | |
| 7 | add('ぁ', '\x03'); | |
| 8 | } | |
| 9 | ||
| 10 | fn add(a: u32, b: u32) void { | |
| 11 | assert(a + b == 12356); | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/x86_64-linux/assert_function.14.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(aa, bb); | |
| 3 | } | |
| 4 | ||
| 5 | const aa = 'ぁ'; | |
| 6 | const bb = '\x03'; | |
| 7 | ||
| 8 | fn add(a: u32, b: u32) void { | |
| 9 | assert(a + b == 12356); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/x86_64-linux/assert_function.15.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert("hello"[0] == 'h'); | |
| 3 | } | |
| 4 | ||
| 5 | pub fn assert(ok: bool) void { | |
| 6 | if (!ok) unreachable; // assertion failure | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // |
test/cases/x86_64-linux/assert_function.16.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const hello = "hello".*; | |
| 2 | pub fn main() void { | |
| 3 | assert(hello[1] == 'e'); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/x86_64-linux/assert_function.17.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u64 = 0xFFEEDDCCBBAA9988; | |
| 3 | assert(i == 0xFFEEDDCCBBAA9988); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/x86_64-linux/assert_function.18.zig deleted-35| ... | ... | @@ -1,35 +0,0 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | extern "c" fn write(usize, usize, usize) usize; | |
| 4 | ||
| 5 | pub fn main() void { | |
| 6 | for ("hello") |_| print(); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | switch (builtin.os.tag) { | |
| 11 | .linux => { | |
| 12 | asm volatile ("syscall" | |
| 13 | : | |
| 14 | : [number] "{rax}" (1), | |
| 15 | [arg1] "{rdi}" (1), | |
| 16 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | |
| 17 | [arg3] "{rdx}" (6), | |
| 18 | : "rcx", "r11", "memory" | |
| 19 | ); | |
| 20 | }, | |
| 21 | .macos => { | |
| 22 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 23 | }, | |
| 24 | else => unreachable, | |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | // run | |
| 29 | // | |
| 30 | // hello | |
| 31 | // hello | |
| 32 | // hello | |
| 33 | // hello | |
| 34 | // hello | |
| 35 | // |
test/cases/x86_64-linux/assert_function.2.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | assert(i == 100); | |
| 14 | } | |
| 15 | ||
| 16 | pub fn assert(ok: bool) void { | |
| 17 | if (!ok) unreachable; // assertion failure | |
| 18 | } | |
| 19 | ||
| 20 | // run | |
| 21 | // |
test/cases/x86_64-linux/assert_function.3.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | const j = i + d; // 110 | |
| 14 | assert(j == 110); | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/x86_64-linux/assert_function.4.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | return a + b; | |
| 8 | } | |
| 9 | ||
| 10 | pub fn assert(ok: bool) void { | |
| 11 | if (!ok) unreachable; // assertion failure | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/x86_64-linux/assert_function.5.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | var x: u32 = undefined; | |
| 8 | x = 0; | |
| 9 | x += a; | |
| 10 | x += b; | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/x86_64-linux/assert_function.6.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | const a: u32 = 2; | |
| 3 | const b: ?u32 = a; | |
| 4 | const c = b.?; | |
| 5 | if (c != 2) unreachable; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // |
test/cases/x86_64-linux/assert_function.7.zig deleted-28| ... | ... | @@ -1,28 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u32 = 0; | |
| 3 | while (i < 4) : (i += 1) print(); | |
| 4 | assert(i == 4); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | asm volatile ("syscall" | |
| 9 | : | |
| 10 | : [number] "{rax}" (1), | |
| 11 | [arg1] "{rdi}" (1), | |
| 12 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | |
| 13 | [arg3] "{rdx}" (6), | |
| 14 | : "rcx", "r11", "memory" | |
| 15 | ); | |
| 16 | } | |
| 17 | ||
| 18 | pub fn assert(ok: bool) void { | |
| 19 | if (!ok) unreachable; // assertion failure | |
| 20 | } | |
| 21 | ||
| 22 | // run | |
| 23 | // | |
| 24 | // hello | |
| 25 | // hello | |
| 26 | // hello | |
| 27 | // hello | |
| 28 | // |
test/cases/x86_64-linux/assert_function.8.zig deleted-25| ... | ... | @@ -1,25 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u32 = 0; | |
| 3 | inline while (i < 4) : (i += 1) print(); | |
| 4 | assert(i == 4); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | asm volatile ("syscall" | |
| 9 | : | |
| 10 | : [number] "{rax}" (1), | |
| 11 | [arg1] "{rdi}" (1), | |
| 12 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | |
| 13 | [arg3] "{rdx}" (6), | |
| 14 | : "rcx", "r11", "memory" | |
| 15 | ); | |
| 16 | } | |
| 17 | ||
| 18 | pub fn assert(ok: bool) void { | |
| 19 | if (!ok) unreachable; // assertion failure | |
| 20 | } | |
| 21 | ||
| 22 | // error | |
| 23 | // | |
| 24 | // :3:21: error: unable to resolve comptime value | |
| 25 | // :3:21: note: condition in comptime branch must be comptime-known |
test/cases/x86_64-linux/assert_function.9.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 20); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | break :blk e; | |
| 11 | }; | |
| 12 | const y = x + a; // 17 | |
| 13 | const z = y + a; // 20 | |
| 14 | return z; | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/x86_64-linux/comptime_var.0.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | if (a == 0) b = 3; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // output_mode=Exe | |
| 9 | // target=x86_64-linux | |
| 10 | // | |
| 11 | // :4:19: error: store to comptime variable depends on runtime condition | |
| 12 | // :4:11: note: runtime condition here |
test/cases/x86_64-linux/comptime_var.1.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | switch (a) { | |
| 5 | 0 => {}, | |
| 6 | else => b = 3, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // | |
| 12 | // :6:19: error: store to comptime variable depends on runtime condition | |
| 13 | // :4:13: note: runtime condition here |
test/cases/x86_64-linux/comptime_var.2.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | comptime var len: u32 = 5; | |
| 3 | print(len); | |
| 4 | len += 9; | |
| 5 | print(len); | |
| 6 | } | |
| 7 | ||
| 8 | fn print(len: usize) void { | |
| 9 | asm volatile ("syscall" | |
| 10 | : | |
| 11 | : [number] "{rax}" (1), | |
| 12 | [arg1] "{rdi}" (1), | |
| 13 | [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), | |
| 14 | [arg3] "{rdx}" (len), | |
| 15 | : "rcx", "r11", "memory" | |
| 16 | ); | |
| 17 | } | |
| 18 | ||
| 19 | // run | |
| 20 | // | |
| 21 | // HelloHello, World! | |
| 22 | // |
test/cases/x86_64-linux/comptime_var.3.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var x: i32 = 1; | |
| 3 | x += 1; | |
| 4 | if (x != 1) unreachable; | |
| 5 | } | |
| 6 | pub fn main() void {} | |
| 7 | ||
| 8 | // error | |
| 9 | // | |
| 10 | // :4:17: error: reached unreachable code |
test/cases/x86_64-linux/comptime_var.4.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | comptime var i: u64 = 0; | |
| 3 | while (i < 5) : (i += 1) {} | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // | |
| 8 | // :3:24: error: cannot store to comptime variable in non-inline loop | |
| 9 | // :3:5: note: non-inline loop here |
test/cases/x86_64-linux/comptime_var.5.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | if (a == 0) { | |
| 4 | comptime var b: u32 = 0; | |
| 5 | b = 1; | |
| 6 | } | |
| 7 | } | |
| 8 | comptime { | |
| 9 | var x: i32 = 1; | |
| 10 | x += 1; | |
| 11 | if (x != 2) unreachable; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/x86_64-linux/comptime_var.6.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | comptime var i: u64 = 2; | |
| 3 | inline while (i < 6) : (i += 1) { | |
| 4 | print(i); | |
| 5 | } | |
| 6 | } | |
| 7 | fn print(len: usize) void { | |
| 8 | asm volatile ("syscall" | |
| 9 | : | |
| 10 | : [number] "{rax}" (1), | |
| 11 | [arg1] "{rdi}" (1), | |
| 12 | [arg2] "{rsi}" (@ptrToInt("Hello")), | |
| 13 | [arg3] "{rdx}" (len), | |
| 14 | : "rcx", "r11", "memory" | |
| 15 | ); | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // HeHelHellHello |
test/cases/x86_64-linux/hello_world_with_updates.0.zig deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | // error | |
| 2 | // output_mode=Exe | |
| 3 | // target=x86_64-linux | |
| 4 | // | |
| 5 | // :?:?: error: root struct of file 'tmp' has no member named 'main' | |
| 6 | // :?:?: note: called from here | |
| 7 | // :?:?: note: called from here | |
| 8 | // :?:?: note: called from here |
test/cases/x86_64-linux/hello_world_with_updates.1.zig deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | pub export fn main() noreturn {} | |
| 2 | ||
| 3 | // error | |
| 4 | // | |
| 5 | // :1:22: error: function declared 'noreturn' implicitly returns | |
| 6 | // :1:32: note: control flow reaches end of body here |
test/cases/x86_64-linux/hello_world_with_updates.2.zig deleted-32| ... | ... | @@ -1,32 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | print(); | |
| 3 | ||
| 4 | exit(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | asm volatile ("syscall" | |
| 9 | : | |
| 10 | : [number] "{rax}" (1), | |
| 11 | [arg1] "{rdi}" (1), | |
| 12 | [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), | |
| 13 | [arg3] "{rdx}" (14), | |
| 14 | : "rcx", "r11", "memory" | |
| 15 | ); | |
| 16 | return; | |
| 17 | } | |
| 18 | ||
| 19 | fn exit() noreturn { | |
| 20 | asm volatile ("syscall" | |
| 21 | : | |
| 22 | : [number] "{rax}" (231), | |
| 23 | [arg1] "{rdi}" (0), | |
| 24 | : "rcx", "r11", "memory" | |
| 25 | ); | |
| 26 | unreachable; | |
| 27 | } | |
| 28 | ||
| 29 | // run | |
| 30 | // | |
| 31 | // Hello, World! | |
| 32 | // |
test/cases/x86_64-linux/hello_world_with_updates.3.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(); | |
| 3 | } | |
| 4 | ||
| 5 | fn print() void { | |
| 6 | asm volatile ("syscall" | |
| 7 | : | |
| 8 | : [number] "{rax}" (1), | |
| 9 | [arg1] "{rdi}" (1), | |
| 10 | [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), | |
| 11 | [arg3] "{rdx}" (14), | |
| 12 | : "rcx", "r11", "memory" | |
| 13 | ); | |
| 14 | return; | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // | |
| 19 | // Hello, World! | |
| 20 | // |
test/cases/x86_64-linux/hello_world_with_updates.4.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(); | |
| 3 | } | |
| 4 | ||
| 5 | fn print() void { | |
| 6 | asm volatile ("syscall" | |
| 7 | : | |
| 8 | : [number] "{rax}" (1), | |
| 9 | [arg1] "{rdi}" (1), | |
| 10 | [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), | |
| 11 | [arg3] "{rdx}" (104), | |
| 12 | : "rcx", "r11", "memory" | |
| 13 | ); | |
| 14 | return; | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // | |
| 19 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 20 | // |
test/cases/x86_64-linux/hello_world_with_updates.5.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | print(); | |
| 3 | print(); | |
| 4 | } | |
| 5 | ||
| 6 | fn print() void { | |
| 7 | asm volatile ("syscall" | |
| 8 | : | |
| 9 | : [number] "{rax}" (1), | |
| 10 | [arg1] "{rdi}" (1), | |
| 11 | [arg2] "{rsi}" (@ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n")), | |
| 12 | [arg3] "{rdx}" (104), | |
| 13 | : "rcx", "r11", "memory" | |
| 14 | ); | |
| 15 | return; | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // | |
| 20 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 21 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 22 | // |
test/cases/x86_64-linux/only_1_function_and_it_gets_updated.0.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | asm volatile ("syscall" | |
| 3 | : | |
| 4 | : [number] "{rax}" (60), // exit | |
| 5 | [arg1] "{rdi}" (0), | |
| 6 | : "rcx", "r11", "memory" | |
| 7 | ); | |
| 8 | unreachable; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // target=x86_64-linux | |
| 13 | // |
test/cases/x86_64-linux/only_1_function_and_it_gets_updated.1.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub export fn _start() noreturn { | |
| 2 | asm volatile ("syscall" | |
| 3 | : | |
| 4 | : [number] "{rax}" (231), // exit_group | |
| 5 | [arg1] "{rdi}" (0), | |
| 6 | : "rcx", "r11", "memory" | |
| 7 | ); | |
| 8 | unreachable; | |
| 9 | } | |
| 10 | ||
| 11 | // run | |
| 12 | // |
test/cases/x86_64-macos/assert_function.0.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | assert(a + b == 7); | |
| 7 | } | |
| 8 | ||
| 9 | pub fn assert(ok: bool) void { | |
| 10 | if (!ok) unreachable; // assertion failure | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // target=x86_64-macos | |
| 15 | // |
test/cases/x86_64-macos/assert_function.1.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | assert(e == 14); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/x86_64-macos/assert_function.10.zig deleted-27| ... | ... | @@ -1,27 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 116); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | const f = d + e; // 24 | |
| 11 | const g = e + f; // 38 | |
| 12 | const h = f + g; // 62 | |
| 13 | const i = g + h; // 100 | |
| 14 | const j = i + d; // 110 | |
| 15 | break :blk j; | |
| 16 | }; | |
| 17 | const y = x + a; // 113 | |
| 18 | const z = y + a; // 116 | |
| 19 | return z; | |
| 20 | } | |
| 21 | ||
| 22 | pub fn assert(ok: bool) void { | |
| 23 | if (!ok) unreachable; // assertion failure | |
| 24 | } | |
| 25 | ||
| 26 | // run | |
| 27 | // |
test/cases/x86_64-macos/assert_function.11.zig deleted-66| ... | ... | @@ -1,66 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 1221); | |
| 3 | assert(mul(3, 4) == 21609); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = j + k; // 320 | |
| 18 | const m = l + c; // 327 | |
| 19 | const n = m + d; // 337 | |
| 20 | const o = n + e; // 351 | |
| 21 | const p = o + f; // 375 | |
| 22 | const q = p + g; // 413 | |
| 23 | const r = q + h; // 475 | |
| 24 | const s = r + i; // 575 | |
| 25 | const t = s + j; // 685 | |
| 26 | const u = t + k; // 895 | |
| 27 | const v = u + l; // 1215 | |
| 28 | break :blk v; | |
| 29 | }; | |
| 30 | const y = x + a; // 1218 | |
| 31 | const z = y + a; // 1221 | |
| 32 | return z; | |
| 33 | } | |
| 34 | ||
| 35 | fn mul(a: u32, b: u32) u32 { | |
| 36 | const x: u32 = blk: { | |
| 37 | const c = a * a * a * a; // 81 | |
| 38 | const d = a * a * a * b; // 108 | |
| 39 | const e = a * a * b * a; // 108 | |
| 40 | const f = a * a * b * b; // 144 | |
| 41 | const g = a * b * a * a; // 108 | |
| 42 | const h = a * b * a * b; // 144 | |
| 43 | const i = a * b * b * a; // 144 | |
| 44 | const j = a * b * b * b; // 192 | |
| 45 | const k = b * a * a * a; // 108 | |
| 46 | const l = b * a * a * b; // 144 | |
| 47 | const m = b * a * b * a; // 144 | |
| 48 | const n = b * a * b * b; // 192 | |
| 49 | const o = b * b * a * a; // 144 | |
| 50 | const p = b * b * a * b; // 192 | |
| 51 | const q = b * b * b * a; // 192 | |
| 52 | const r = b * b * b * b; // 256 | |
| 53 | const s = c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r; // 2401 | |
| 54 | break :blk s; | |
| 55 | }; | |
| 56 | const y = x * a; // 7203 | |
| 57 | const z = y * a; // 21609 | |
| 58 | return z; | |
| 59 | } | |
| 60 | ||
| 61 | pub fn assert(ok: bool) void { | |
| 62 | if (!ok) unreachable; // assertion failure | |
| 63 | } | |
| 64 | ||
| 65 | // run | |
| 66 | // |
test/cases/x86_64-macos/assert_function.12.zig deleted-47| ... | ... | @@ -1,47 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 791); | |
| 3 | assert(add(4, 3) == 79); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | const x: u32 = if (a < b) blk: { | |
| 8 | const c = a + b; // 7 | |
| 9 | const d = a + c; // 10 | |
| 10 | const e = d + b; // 14 | |
| 11 | const f = d + e; // 24 | |
| 12 | const g = e + f; // 38 | |
| 13 | const h = f + g; // 62 | |
| 14 | const i = g + h; // 100 | |
| 15 | const j = i + d; // 110 | |
| 16 | const k = i + j; // 210 | |
| 17 | const l = k + c; // 217 | |
| 18 | const m = l + d; // 227 | |
| 19 | const n = m + e; // 241 | |
| 20 | const o = n + f; // 265 | |
| 21 | const p = o + g; // 303 | |
| 22 | const q = p + h; // 365 | |
| 23 | const r = q + i; // 465 | |
| 24 | const s = r + j; // 575 | |
| 25 | const t = s + k; // 785 | |
| 26 | break :blk t; | |
| 27 | } else blk: { | |
| 28 | const t = b + b + a; // 10 | |
| 29 | const c = a + t; // 14 | |
| 30 | const d = c + t; // 24 | |
| 31 | const e = d + t; // 34 | |
| 32 | const f = e + t; // 44 | |
| 33 | const g = f + t; // 54 | |
| 34 | const h = c + g; // 68 | |
| 35 | break :blk h + b; // 71 | |
| 36 | }; | |
| 37 | const y = x + a; // 788, 75 | |
| 38 | const z = y + a; // 791, 79 | |
| 39 | return z; | |
| 40 | } | |
| 41 | ||
| 42 | pub fn assert(ok: bool) void { | |
| 43 | if (!ok) unreachable; // assertion failure | |
| 44 | } | |
| 45 | ||
| 46 | // run | |
| 47 | // |
test/cases/x86_64-macos/assert_function.13.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | const ignore = | |
| 3 | \\ cool thx | |
| 4 | \\ | |
| 5 | ; | |
| 6 | _ = ignore; | |
| 7 | add('ぁ', '\x03'); | |
| 8 | } | |
| 9 | ||
| 10 | fn add(a: u32, b: u32) void { | |
| 11 | assert(a + b == 12356); | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/x86_64-macos/assert_function.14.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(aa, bb); | |
| 3 | } | |
| 4 | ||
| 5 | const aa = 'ぁ'; | |
| 6 | const bb = '\x03'; | |
| 7 | ||
| 8 | fn add(a: u32, b: u32) void { | |
| 9 | assert(a + b == 12356); | |
| 10 | } | |
| 11 | ||
| 12 | pub fn assert(ok: bool) void { | |
| 13 | if (!ok) unreachable; // assertion failure | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // |
test/cases/x86_64-macos/assert_function.15.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert("hello"[0] == 'h'); | |
| 3 | } | |
| 4 | ||
| 5 | pub fn assert(ok: bool) void { | |
| 6 | if (!ok) unreachable; // assertion failure | |
| 7 | } | |
| 8 | ||
| 9 | // run | |
| 10 | // |
test/cases/x86_64-macos/assert_function.16.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | const hello = "hello".*; | |
| 2 | pub fn main() void { | |
| 3 | assert(hello[1] == 'e'); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/x86_64-macos/assert_function.17.zig deleted-11| ... | ... | @@ -1,11 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var i: u64 = 0xFFEEDDCCBBAA9988; | |
| 3 | assert(i == 0xFFEEDDCCBBAA9988); | |
| 4 | } | |
| 5 | ||
| 6 | pub fn assert(ok: bool) void { | |
| 7 | if (!ok) unreachable; // assertion failure | |
| 8 | } | |
| 9 | ||
| 10 | // run | |
| 11 | // |
test/cases/x86_64-macos/assert_function.18.zig deleted-35| ... | ... | @@ -1,35 +0,0 @@ |
| 1 | const builtin = @import("builtin"); | |
| 2 | ||
| 3 | extern "c" fn write(usize, usize, usize) usize; | |
| 4 | ||
| 5 | pub fn main() void { | |
| 6 | for ("hello") |_| print(); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | switch (builtin.os.tag) { | |
| 11 | .linux => { | |
| 12 | asm volatile ("syscall" | |
| 13 | : | |
| 14 | : [number] "{rax}" (1), | |
| 15 | [arg1] "{rdi}" (1), | |
| 16 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | |
| 17 | [arg3] "{rdx}" (6), | |
| 18 | : "rcx", "r11", "memory" | |
| 19 | ); | |
| 20 | }, | |
| 21 | .macos => { | |
| 22 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 23 | }, | |
| 24 | else => unreachable, | |
| 25 | } | |
| 26 | } | |
| 27 | ||
| 28 | // run | |
| 29 | // | |
| 30 | // hello | |
| 31 | // hello | |
| 32 | // hello | |
| 33 | // hello | |
| 34 | // hello | |
| 35 | // |
test/cases/x86_64-macos/assert_function.2.zig deleted-21| ... | ... | @@ -1,21 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | assert(i == 100); | |
| 14 | } | |
| 15 | ||
| 16 | pub fn assert(ok: bool) void { | |
| 17 | if (!ok) unreachable; // assertion failure | |
| 18 | } | |
| 19 | ||
| 20 | // run | |
| 21 | // |
test/cases/x86_64-macos/assert_function.3.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | add(3, 4); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) void { | |
| 6 | const c = a + b; // 7 | |
| 7 | const d = a + c; // 10 | |
| 8 | const e = d + b; // 14 | |
| 9 | const f = d + e; // 24 | |
| 10 | const g = e + f; // 38 | |
| 11 | const h = f + g; // 62 | |
| 12 | const i = g + h; // 100 | |
| 13 | const j = i + d; // 110 | |
| 14 | assert(j == 110); | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/x86_64-macos/assert_function.4.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | return a + b; | |
| 8 | } | |
| 9 | ||
| 10 | pub fn assert(ok: bool) void { | |
| 11 | if (!ok) unreachable; // assertion failure | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/x86_64-macos/assert_function.5.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 7); | |
| 3 | assert(add(20, 10) == 30); | |
| 4 | } | |
| 5 | ||
| 6 | fn add(a: u32, b: u32) u32 { | |
| 7 | var x: u32 = undefined; | |
| 8 | x = 0; | |
| 9 | x += a; | |
| 10 | x += b; | |
| 11 | return x; | |
| 12 | } | |
| 13 | ||
| 14 | pub fn assert(ok: bool) void { | |
| 15 | if (!ok) unreachable; // assertion failure | |
| 16 | } | |
| 17 | ||
| 18 | // run | |
| 19 | // |
test/cases/x86_64-macos/assert_function.6.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | const a: u32 = 2; | |
| 3 | const b: ?u32 = a; | |
| 4 | const c = b.?; | |
| 5 | if (c != 2) unreachable; | |
| 6 | } | |
| 7 | ||
| 8 | // run | |
| 9 | // |
test/cases/x86_64-macos/assert_function.7.zig deleted-23| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var i: u32 = 0; | |
| 5 | while (i < 4) : (i += 1) print(); | |
| 6 | assert(i == 4); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 11 | } | |
| 12 | ||
| 13 | pub fn assert(ok: bool) void { | |
| 14 | if (!ok) unreachable; // assertion failure | |
| 15 | } | |
| 16 | ||
| 17 | // run | |
| 18 | // | |
| 19 | // hello | |
| 20 | // hello | |
| 21 | // hello | |
| 22 | // hello | |
| 23 | // |
test/cases/x86_64-macos/assert_function.8.zig deleted-20| ... | ... | @@ -1,20 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | var i: u32 = 0; | |
| 5 | inline while (i < 4) : (i += 1) print(); | |
| 6 | assert(i == 4); | |
| 7 | } | |
| 8 | ||
| 9 | fn print() void { | |
| 10 | _ = write(1, @ptrToInt("hello\n"), 6); | |
| 11 | } | |
| 12 | ||
| 13 | pub fn assert(ok: bool) void { | |
| 14 | if (!ok) unreachable; // assertion failure | |
| 15 | } | |
| 16 | ||
| 17 | // error | |
| 18 | // | |
| 19 | // :5:21: error: unable to resolve comptime value | |
| 20 | // :5:21: note: condition in comptime branch must be comptime-known |
test/cases/x86_64-macos/assert_function.9.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | assert(add(3, 4) == 20); | |
| 3 | } | |
| 4 | ||
| 5 | fn add(a: u32, b: u32) u32 { | |
| 6 | const x: u32 = blk: { | |
| 7 | const c = a + b; // 7 | |
| 8 | const d = a + c; // 10 | |
| 9 | const e = d + b; // 14 | |
| 10 | break :blk e; | |
| 11 | }; | |
| 12 | const y = x + a; // 17 | |
| 13 | const z = y + a; // 20 | |
| 14 | return z; | |
| 15 | } | |
| 16 | ||
| 17 | pub fn assert(ok: bool) void { | |
| 18 | if (!ok) unreachable; // assertion failure | |
| 19 | } | |
| 20 | ||
| 21 | // run | |
| 22 | // |
test/cases/x86_64-macos/comptime_var.0.zig deleted-12| ... | ... | @@ -1,12 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | if (a == 0) b = 3; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // output_mode=Exe | |
| 9 | // target=x86_64-macos | |
| 10 | // | |
| 11 | // :4:19: error: store to comptime variable depends on runtime condition | |
| 12 | // :4:11: note: runtime condition here |
test/cases/x86_64-macos/comptime_var.1.zig deleted-13| ... | ... | @@ -1,13 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | comptime var b: u32 = 0; | |
| 4 | switch (a) { | |
| 5 | 0 => {}, | |
| 6 | else => b = 3, | |
| 7 | } | |
| 8 | } | |
| 9 | ||
| 10 | // error | |
| 11 | // | |
| 12 | // :6:19: error: store to comptime variable depends on runtime condition | |
| 13 | // :4:13: note: runtime condition here |
test/cases/x86_64-macos/comptime_var.2.zig deleted-17| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | comptime var len: u32 = 5; | |
| 5 | print(len); | |
| 6 | len += 9; | |
| 7 | print(len); | |
| 8 | } | |
| 9 | ||
| 10 | fn print(len: usize) void { | |
| 11 | _ = write(1, @ptrToInt("Hello, World!\n"), len); | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // HelloHello, World! | |
| 17 | // |
test/cases/x86_64-macos/comptime_var.3.zig deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | comptime { | |
| 2 | var x: i32 = 1; | |
| 3 | x += 1; | |
| 4 | if (x != 1) unreachable; | |
| 5 | } | |
| 6 | pub fn main() void {} | |
| 7 | ||
| 8 | // error | |
| 9 | // | |
| 10 | // :4:17: error: reached unreachable code |
test/cases/x86_64-macos/comptime_var.4.zig deleted-9| ... | ... | @@ -1,9 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | comptime var i: u64 = 0; | |
| 3 | while (i < 5) : (i += 1) {} | |
| 4 | } | |
| 5 | ||
| 6 | // error | |
| 7 | // | |
| 8 | // :3:24: error: cannot store to comptime variable in non-inline loop | |
| 9 | // :3:5: note: non-inline loop here |
test/cases/x86_64-macos/comptime_var.5.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | pub fn main() void { | |
| 2 | var a: u32 = 0; | |
| 3 | if (a == 0) { | |
| 4 | comptime var b: u32 = 0; | |
| 5 | b = 1; | |
| 6 | } | |
| 7 | } | |
| 8 | comptime { | |
| 9 | var x: i32 = 1; | |
| 10 | x += 1; | |
| 11 | if (x != 2) unreachable; | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // |
test/cases/x86_64-macos/comptime_var.6.zig deleted-15| ... | ... | @@ -1,15 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | comptime var i: u64 = 2; | |
| 5 | inline while (i < 6) : (i += 1) { | |
| 6 | print(i); | |
| 7 | } | |
| 8 | } | |
| 9 | fn print(len: usize) void { | |
| 10 | _ = write(1, @ptrToInt("Hello"), len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // HeHelHellHello |
test/cases/x86_64-macos/hello_world_with_updates.0.zig deleted-5| ... | ... | @@ -1,5 +0,0 @@ |
| 1 | // error | |
| 2 | // output_mode=Exe | |
| 3 | // target=x86_64-macos | |
| 4 | // | |
| 5 | // :?:?: error: root struct of file 'tmp' has no member named 'main' |
test/cases/x86_64-macos/hello_world_with_updates.1.zig deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | pub export fn main() noreturn {} | |
| 2 | ||
| 3 | // error | |
| 4 | // | |
| 5 | // :1:22: error: function declared 'noreturn' implicitly returns | |
| 6 | // :1:32: note: control flow reaches end of body here |
test/cases/x86_64-macos/hello_world_with_updates.2.zig deleted-19| ... | ... | @@ -1,19 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | extern "c" fn exit(usize) noreturn; | |
| 3 | ||
| 4 | pub export fn main() noreturn { | |
| 5 | print(); | |
| 6 | ||
| 7 | exit(0); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // |
test/cases/x86_64-macos/hello_world_with_updates.3.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("Hello, World!\n"); | |
| 9 | const len = 14; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // Hello, World! | |
| 16 | // |
test/cases/x86_64-macos/hello_world_with_updates.4.zig deleted-22| ... | ... | @@ -1,22 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | print(); | |
| 7 | print(); | |
| 8 | } | |
| 9 | ||
| 10 | fn print() void { | |
| 11 | const msg = @ptrToInt("Hello, World!\n"); | |
| 12 | const len = 14; | |
| 13 | _ = write(1, msg, len); | |
| 14 | } | |
| 15 | ||
| 16 | // run | |
| 17 | // | |
| 18 | // Hello, World! | |
| 19 | // Hello, World! | |
| 20 | // Hello, World! | |
| 21 | // Hello, World! | |
| 22 | // |
test/cases/x86_64-macos/hello_world_with_updates.5.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 9 | const len = 104; | |
| 10 | _ = write(1, msg, len); | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 16 | // |
test/cases/x86_64-macos/hello_world_with_updates.6.zig deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | extern "c" fn write(usize, usize, usize) usize; | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | print(); | |
| 6 | } | |
| 7 | ||
| 8 | fn print() void { | |
| 9 | const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n"); | |
| 10 | const len = 104; | |
| 11 | _ = write(1, msg, len); | |
| 12 | } | |
| 13 | ||
| 14 | // run | |
| 15 | // | |
| 16 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 17 | // What is up? This is a longer message that will force the data to be relocated in virtual address space. | |
| 18 | // |
test/cases/x86_64-windows/hello_world_with_updates.0.zig deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | // error | |
| 2 | // output_mode=Exe | |
| 3 | // target=x86_64-windows | |
| 4 | // | |
| 5 | // :?:?: error: root struct of file 'tmp' has no member named 'main' | |
| 6 | // :?:?: note: called from here | |
| 7 | // :?:?: note: called from here |
test/cases/x86_64-windows/hello_world_with_updates.1.zig deleted-6| ... | ... | @@ -1,6 +0,0 @@ |
| 1 | pub export fn main() noreturn {} | |
| 2 | ||
| 3 | // error | |
| 4 | // | |
| 5 | // :1:22: error: function declared 'noreturn' implicitly returns | |
| 6 | // :1:32: note: control flow reaches end of body here |
test/cases/x86_64-windows/hello_world_with_updates.2.zig deleted-16| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | print(); | |
| 5 | } | |
| 6 | ||
| 7 | fn print() void { | |
| 8 | const msg = "Hello, World!\n"; | |
| 9 | const stdout = std.io.getStdOut(); | |
| 10 | stdout.writeAll(msg) catch unreachable; | |
| 11 | } | |
| 12 | ||
| 13 | // run | |
| 14 | // | |
| 15 | // Hello, World! | |
| 16 | // |