| author | |
| committer | |
| log | 2875216f8e01c4e71a76fe840a0b298f0d42758e |
| tree | 1d0d50ee200424ba1af988267179f624864a025c |
| parent | 5a5648c0f03058e1d3878cc8c072af968fc90aa8 |
This is just a temporary fix - I would like to unify all of x86_64
tests across linux and macos OSes.101 files changed, 1075 insertions(+), 607 deletions(-)
test/incremental/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,x86_64-macos | ||
| 15 | // | ||
test/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/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/incremental/assert_function.7.zig deleted-40| ... | @@ -1,40 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 3 | extern "c" fn write(usize, usize, usize) usize; | ||
| 4 | |||
| 5 | pub fn main() void { | ||
| 6 | var i: u32 = 0; | ||
| 7 | while (i < 4) : (i += 1) print(); | ||
| 8 | assert(i == 4); | ||
| 9 | } | ||
| 10 | |||
| 11 | fn print() void { | ||
| 12 | switch (builtin.os.tag) { | ||
| 13 | .linux => { | ||
| 14 | asm volatile ("syscall" | ||
| 15 | : | ||
| 16 | : [number] "{rax}" (1), | ||
| 17 | [arg1] "{rdi}" (1), | ||
| 18 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | ||
| 19 | [arg3] "{rdx}" (6), | ||
| 20 | : "rcx", "r11", "memory" | ||
| 21 | ); | ||
| 22 | }, | ||
| 23 | .macos => { | ||
| 24 | _ = write(1, @ptrToInt("hello\n"), 6); | ||
| 25 | }, | ||
| 26 | else => unreachable, | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | pub fn assert(ok: bool) void { | ||
| 31 | if (!ok) unreachable; // assertion failure | ||
| 32 | } | ||
| 33 | |||
| 34 | // run | ||
| 35 | // | ||
| 36 | // hello | ||
| 37 | // hello | ||
| 38 | // hello | ||
| 39 | // hello | ||
| 40 | // | ||
test/incremental/assert_function.8.zig deleted-36| ... | @@ -1,36 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 3 | extern "c" fn write(usize, usize, usize) usize; | ||
| 4 | |||
| 5 | pub fn main() void { | ||
| 6 | var i: u32 = 0; | ||
| 7 | inline while (i < 4) : (i += 1) print(); | ||
| 8 | assert(i == 4); | ||
| 9 | } | ||
| 10 | |||
| 11 | fn print() void { | ||
| 12 | switch (builtin.os.tag) { | ||
| 13 | .linux => { | ||
| 14 | asm volatile ("syscall" | ||
| 15 | : | ||
| 16 | : [number] "{rax}" (1), | ||
| 17 | [arg1] "{rdi}" (1), | ||
| 18 | [arg2] "{rsi}" (@ptrToInt("hello\n")), | ||
| 19 | [arg3] "{rdx}" (6), | ||
| 20 | : "rcx", "r11", "memory" | ||
| 21 | ); | ||
| 22 | }, | ||
| 23 | .macos => { | ||
| 24 | _ = write(1, @ptrToInt("hello\n"), 6); | ||
| 25 | }, | ||
| 26 | else => unreachable, | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | pub fn assert(ok: bool) void { | ||
| 31 | if (!ok) unreachable; // assertion failure | ||
| 32 | } | ||
| 33 | |||
| 34 | // error | ||
| 35 | // | ||
| 36 | // :7:21: error: unable to resolve comptime value | ||
test/incremental/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/incremental/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,x86_64-macos | ||
| 10 | // | ||
| 11 | // :4:21: error: store to comptime variable depends on runtime condition | ||
| 12 | // :4:11: note: runtime condition here | ||
test/incremental/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:21: error: store to comptime variable depends on runtime condition | ||
| 13 | // :4:13: note: runtime condition here | ||
test/incremental/comptime_var.2.zig deleted-34| ... | @@ -1,34 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 3 | extern "c" fn write(usize, usize, usize) usize; | ||
| 4 | |||
| 5 | pub fn main() void { | ||
| 6 | comptime var len: u32 = 5; | ||
| 7 | print(len); | ||
| 8 | len += 9; | ||
| 9 | print(len); | ||
| 10 | } | ||
| 11 | |||
| 12 | fn print(len: usize) void { | ||
| 13 | switch (builtin.os.tag) { | ||
| 14 | .linux => { | ||
| 15 | asm volatile ("syscall" | ||
| 16 | : | ||
| 17 | : [number] "{rax}" (1), | ||
| 18 | [arg1] "{rdi}" (1), | ||
| 19 | [arg2] "{rsi}" (@ptrToInt("Hello, World!\n")), | ||
| 20 | [arg3] "{rdx}" (len), | ||
| 21 | : "rcx", "r11", "memory" | ||
| 22 | ); | ||
| 23 | }, | ||
| 24 | .macos => { | ||
| 25 | _ = write(1, @ptrToInt("Hello, World!\n"), len); | ||
| 26 | }, | ||
| 27 | else => unreachable, | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | // run | ||
| 32 | // | ||
| 33 | // HelloHello, World! | ||
| 34 | // | ||
test/incremental/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: unable to resolve comptime value | ||
test/incremental/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/incremental/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/incremental/comptime_var.6.zig deleted-32| ... | @@ -1,32 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 3 | extern "c" fn write(usize, usize, usize) usize; | ||
| 4 | |||
| 5 | pub fn main() void { | ||
| 6 | comptime var i: u64 = 2; | ||
| 7 | inline while (i < 6) : (i += 1) { | ||
| 8 | print(i); | ||
| 9 | } | ||
| 10 | } | ||
| 11 | fn print(len: usize) void { | ||
| 12 | switch (builtin.os.tag) { | ||
| 13 | .linux => { | ||
| 14 | asm volatile ("syscall" | ||
| 15 | : | ||
| 16 | : [number] "{rax}" (1), | ||
| 17 | [arg1] "{rdi}" (1), | ||
| 18 | [arg2] "{rsi}" (@ptrToInt("Hello")), | ||
| 19 | [arg3] "{rdx}" (len), | ||
| 20 | : "rcx", "r11", "memory" | ||
| 21 | ); | ||
| 22 | }, | ||
| 23 | .macos => { | ||
| 24 | _ = write(1, @ptrToInt("Hello"), len); | ||
| 25 | }, | ||
| 26 | else => unreachable, | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | // run | ||
| 31 | // | ||
| 32 | // HeHelHellHello | ||
test/incremental/llvm/address_space_pointer_access_chaining_pointer_to_optional_array.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=llvm | 10 | // backend=llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/address_spaces_pointer_access_chaining_array_pointer.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/address_spaces_pointer_access_chaining_complex.zig+1-1| ... | @@ -9,5 +9,5 @@ pub fn main() void { | ... | @@ -9,5 +9,5 @@ pub fn main() void { |
| 9 | // error | 9 | // error |
| 10 | // output_mode=Exe | 10 | // output_mode=Exe |
| 11 | // backend=llvm | 11 | // backend=llvm |
| 12 | // target=x86_64-linux | 12 | // target=x86_64-linux,x86_64-macos |
| 13 | // | 13 | // |
test/incremental/llvm/address_spaces_pointer_access_chaining_struct_pointer.zig+1-1| ... | @@ -9,5 +9,5 @@ pub fn main() void { | ... | @@ -9,5 +9,5 @@ pub fn main() void { |
| 9 | // error | 9 | // error |
| 10 | // output_mode=Exe | 10 | // output_mode=Exe |
| 11 | // backend=stage2,llvm | 11 | // backend=stage2,llvm |
| 12 | // target=x86_64-linux | 12 | // target=x86_64-linux,x86_64-macos |
| 13 | // | 13 | // |
test/incremental/llvm/any_typed_null_to_any_typed_optional.zig+1-1| ... | @@ -6,6 +6,6 @@ pub fn main() void { | ... | @@ -6,6 +6,6 @@ pub fn main() void { |
| 6 | // error | 6 | // error |
| 7 | // output_mode=Exe | 7 | // output_mode=Exe |
| 8 | // backend=stage2,llvm | 8 | // backend=stage2,llvm |
| 9 | // target=x86_64-linux | 9 | // target=x86_64-linux,x86_64-macos |
| 10 | // | 10 | // |
| 11 | // :3:21: error: expected *anyopaque, found ?usize | 11 | // :3:21: error: expected *anyopaque, found ?usize |
test/incremental/llvm/blocks.zig+1-1| ... | @@ -18,5 +18,5 @@ pub fn main() void { | ... | @@ -18,5 +18,5 @@ pub fn main() void { |
| 18 | 18 | ||
| 19 | // run | 19 | // run |
| 20 | // backend=stage2,llvm | 20 | // backend=stage2,llvm |
| 21 | // target=x86_64-linux | 21 | // target=x86_64-linux,x86_64-macos |
| 22 | // | 22 | // |
test/incremental/llvm/dereferencing_though_multiple_pointers_with_address_spaces.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/for_loop.zig+1-1| ... | @@ -12,5 +12,5 @@ pub fn main() void { | ... | @@ -12,5 +12,5 @@ pub fn main() void { |
| 12 | 12 | ||
| 13 | // run | 13 | // run |
| 14 | // backend=stage2,llvm | 14 | // backend=stage2,llvm |
| 15 | // target=x86_64-linux | 15 | // target=x86_64-linux,x86_64-macos |
| 16 | // | 16 | // |
test/incremental/llvm/hello_world.zig+1-1| ... | @@ -6,7 +6,7 @@ pub fn main() void { | ... | @@ -6,7 +6,7 @@ pub fn main() void { |
| 6 | 6 | ||
| 7 | // run | 7 | // run |
| 8 | // backend=llvm | 8 | // backend=llvm |
| 9 | // target=x86_64-linux | 9 | // target=x86_64-linux,x86_64-macos |
| 10 | // | 10 | // |
| 11 | // hello world! | 11 | // hello world! |
| 12 | // | 12 | // |
test/incremental/llvm/invalid_address_space_coercion.zig+1-1| ... | @@ -8,6 +8,6 @@ pub fn main() void { | ... | @@ -8,6 +8,6 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
| 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 | 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 |
test/incremental/llvm/invalid_pointer_keeps_address_space_when_taking_address_of_dereference.zig+1-1| ... | @@ -8,6 +8,6 @@ pub fn main() void { | ... | @@ -8,6 +8,6 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
| 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 | 13 | // :2:12: error: expected *i32, found *addrspace(.gs) i32 |
test/incremental/llvm/nested_blocks.zig+1-1| ... | @@ -20,5 +20,5 @@ pub fn main() void { | ... | @@ -20,5 +20,5 @@ pub fn main() void { |
| 20 | 20 | ||
| 21 | // run | 21 | // run |
| 22 | // backend=stage2, llvm | 22 | // backend=stage2, llvm |
| 23 | // target=x86_64-linux | 23 | // target=x86_64-linux,x86_64-macos |
| 24 | // | 24 | // |
test/incremental/llvm/optionals.zig+1-1| ... | @@ -41,5 +41,5 @@ pub fn main() void { | ... | @@ -41,5 +41,5 @@ pub fn main() void { |
| 41 | 41 | ||
| 42 | // run | 42 | // run |
| 43 | // backend=llvm | 43 | // backend=llvm |
| 44 | // target=x86_64-linux | 44 | // target=x86_64-linux,x86_64-macos |
| 45 | // | 45 | // |
test/incremental/llvm/pointer_keeps_address_space.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/pointer_keeps_address_space_when_taking_address_of_dereference.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig+1-1| ... | @@ -8,5 +8,5 @@ pub fn main() void { | ... | @@ -8,5 +8,5 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/pointer_with_different_address_spaces.zig+1-1| ... | @@ -8,6 +8,6 @@ pub fn main() void { | ... | @@ -8,6 +8,6 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
| 13 | // :2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32 | 13 | // :2:12: error: expected *addrspace(.fs) i32, found *addrspace(.gs) i32 |
test/incremental/llvm/pointers_with_different_address_spaces.zig+1-1| ... | @@ -8,6 +8,6 @@ pub fn main() void { | ... | @@ -8,6 +8,6 @@ pub fn main() void { |
| 8 | // error | 8 | // error |
| 9 | // output_mode=Exe | 9 | // output_mode=Exe |
| 10 | // backend=stage2,llvm | 10 | // backend=stage2,llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
| 13 | // :2:13: error: expected *i32, found *addrspace(.gs) i32 | 13 | // :2:13: error: expected *i32, found *addrspace(.gs) i32 |
test/incremental/llvm/rem.zig+1-1| ... | @@ -11,5 +11,5 @@ pub fn main() void { | ... | @@ -11,5 +11,5 @@ pub fn main() void { |
| 11 | 11 | ||
| 12 | // run | 12 | // run |
| 13 | // backend=stage2,llvm | 13 | // backend=stage2,llvm |
| 14 | // target=x86_64-linux | 14 | // target=x86_64-linux,x86_64-macos |
| 15 | // | 15 | // |
test/incremental/llvm/shift_right_plus_left.0.zig+1-1| ... | @@ -8,5 +8,5 @@ fn assert(a: u32, b: u32) void { | ... | @@ -8,5 +8,5 @@ fn assert(a: u32, b: u32) void { |
| 8 | 8 | ||
| 9 | // run | 9 | // run |
| 10 | // backend=llvm | 10 | // backend=llvm |
| 11 | // target=x86_64-linux | 11 | // target=x86_64-linux,x86_64-macos |
| 12 | // | 12 | // |
test/incremental/llvm/simple_addition_and_subtraction.zig+1-1| ... | @@ -16,5 +16,5 @@ fn assert(ok: bool) void { | ... | @@ -16,5 +16,5 @@ fn assert(ok: bool) void { |
| 16 | 16 | ||
| 17 | // run | 17 | // run |
| 18 | // backend=stage2,llvm | 18 | // backend=stage2,llvm |
| 19 | // target=x86_64-linux | 19 | // target=x86_64-linux,x86_64-macos |
| 20 | // | 20 | // |
test/incremental/llvm/simple_if_statement.zig+1-1| ... | @@ -12,5 +12,5 @@ pub fn main() void { | ... | @@ -12,5 +12,5 @@ pub fn main() void { |
| 12 | 12 | ||
| 13 | // run | 13 | // run |
| 14 | // backend=stage2,llvm | 14 | // backend=stage2,llvm |
| 15 | // target=x86_64-linux | 15 | // target=x86_64-linux,x86_64-macos |
| 16 | // | 16 | // |
test/incremental/llvm/while_loops.zig+1-1| ... | @@ -14,5 +14,5 @@ pub fn main() void { | ... | @@ -14,5 +14,5 @@ pub fn main() void { |
| 14 | 14 | ||
| 15 | // run | 15 | // run |
| 16 | // backend=stage2,llvm | 16 | // backend=stage2,llvm |
| 17 | // target=x86_64-linux | 17 | // target=x86_64-linux,x86_64-macos |
| 18 | // | 18 | // |
test/incremental/x86_64-linux/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-linux | ||
| 15 | // | ||
test/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/assert_function.18.zig created+35| ... | @@ -0,0 +1,35 @@ | ||
| 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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/assert_function.7.zig created+28| ... | @@ -0,0 +1,28 @@ | ||
| 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/incremental/x86_64-linux/assert_function.8.zig created+24| ... | @@ -0,0 +1,24 @@ | ||
| 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 | // :5:21: error: unable to resolve comptime value | ||
test/incremental/x86_64-linux/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/incremental/x86_64-linux/comptime_var.0.zig created+12| ... | @@ -0,0 +1,12 @@ | ||
| 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:21: error: store to comptime variable depends on runtime condition | ||
| 12 | // :4:11: note: runtime condition here | ||
test/incremental/x86_64-linux/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:21: error: store to comptime variable depends on runtime condition | ||
| 13 | // :4:13: note: runtime condition here | ||
test/incremental/x86_64-linux/comptime_var.2.zig created+22| ... | @@ -0,0 +1,22 @@ | ||
| 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/incremental/x86_64-linux/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: unable to resolve comptime value | ||
test/incremental/x86_64-linux/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/incremental/x86_64-linux/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/incremental/x86_64-linux/comptime_var.6.zig created+20| ... | @@ -0,0 +1,20 @@ | ||
| 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/incremental/x86_64-macos/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 | ||
| 15 | // | ||
test/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/assert_function.18.zig created+35| ... | @@ -0,0 +1,35 @@ | ||
| 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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/assert_function.7.zig created+23| ... | @@ -0,0 +1,23 @@ | ||
| 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/incremental/x86_64-macos/assert_function.8.zig created+19| ... | @@ -0,0 +1,19 @@ | ||
| 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 | ||
test/incremental/x86_64-macos/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/incremental/x86_64-macos/comptime_var.0.zig created+12| ... | @@ -0,0 +1,12 @@ | ||
| 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:21: error: store to comptime variable depends on runtime condition | ||
| 12 | // :4:11: note: runtime condition here | ||
test/incremental/x86_64-macos/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:21: error: store to comptime variable depends on runtime condition | ||
| 13 | // :4:13: note: runtime condition here | ||
test/incremental/x86_64-macos/comptime_var.2.zig created+17| ... | @@ -0,0 +1,17 @@ | ||
| 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/incremental/x86_64-macos/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: unable to resolve comptime value | ||
test/incremental/x86_64-macos/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/incremental/x86_64-macos/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/incremental/x86_64-macos/comptime_var.6.zig created+15| ... | @@ -0,0 +1,15 @@ | ||
| 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 | ||