authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-11-11 20:00:00+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-11-11 20:00:00+00:00
log28bdab385a80aaff736707a9227af2d1a17e7fa4
tree66e6d8479ad4152b9fee6f958f1061f86c180584
parent560d6b99d5be8e906b7d8d70a2b2e1f1d4da4f89
parent6e56bc1096eb99a065bc7222bf3264142251da6d
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21961 from mlugg/incr-cases

incremental: remove legacy cases, add some new ones

182 files changed, 192 insertions(+), 2456 deletions(-)

test/cases/adding_numbers_at_runtime_and_comptime.0.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 add(3, 4);
3}
4
5fn add(a: u32, b: u32) void {
6 if (a + b != 7) unreachable;
7}
8
9// run
10//
test/cases/adding_numbers_at_runtime_and_comptime.1.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 if (x - 7 != 0) unreachable;
3}
4
5fn add(a: u32, b: u32) u32 {
6 return a + b;
7}
8
9const x = add(3, 4);
10
11// run
12//
test/cases/adding_numbers_at_runtime_and_comptime.2.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() void {
2 var x: usize = 3;
3 _ = &x;
4 const y = add(1, 2, x);
5 if (y - 6 != 0) unreachable;
6}
7
8inline fn add(a: usize, b: usize, c: usize) usize {
9 return a + b + c;
10}
11
12// run
13//
test/cases/arithmetic_operations.0.zig deleted-17
...@@ -1,17 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(2, 4);
5 print(1, 7);
6}
7
8fn print(a: u32, b: u32) void {
9 const str = "123456789";
10 const len = a + b;
11 _ = std.posix.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 deleted-16
...@@ -1,16 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(10, 5);
5 print(4, 3);
6}
7
8fn print(a: u32, b: u32) void {
9 const str = "123456789";
10 const len = a - b;
11 _ = std.posix.write(1, str[0..len]) catch {};
12}
13
14// run
15//
16// 123451
test/cases/arithmetic_operations.2.zig deleted-16
...@@ -1,16 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(8, 9);
5 print(3, 7);
6}
7
8fn print(a: u32, b: u32) void {
9 const str = "123456789";
10 const len = a & b;
11 _ = std.posix.write(1, str[0..len]) catch {};
12}
13
14// run
15//
16// 12345678123
test/cases/arithmetic_operations.3.zig deleted-16
...@@ -1,16 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(4, 2);
5 print(3, 7);
6}
7
8fn print(a: u32, b: u32) void {
9 const str = "123456789";
10 const len = a | b;
11 _ = std.posix.write(1, str[0..len]) catch {};
12}
13
14// run
15//
16// 1234561234567
test/cases/arithmetic_operations.4.zig deleted-16
...@@ -1,16 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(42, 42);
5 print(3, 5);
6}
7
8fn print(a: u32, b: u32) void {
9 const str = "123456789";
10 const len = a ^ b;
11 _ = std.posix.write(1, str[0..len]) catch {};
12}
13
14// run
15//
16// 123456
test/cases/arithmetic_operations.5.zig deleted-15
...@@ -1,15 +0,0 @@
1pub 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
10pub fn assert(ok: bool) void {
11 if (!ok) unreachable; // assertion failure
12}
13
14// run
15//
test/cases/arithmetic_operations.6.zig deleted-21
...@@ -1,21 +0,0 @@
1pub 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
16pub fn assert(ok: bool) void {
17 if (!ok) unreachable; // assertion failure
18}
19
20// run
21//
test/cases/assert_function.0.zig deleted-15
...@@ -1,15 +0,0 @@
1pub fn main() void {
2 add(3, 4);
3}
4
5fn add(a: u32, b: u32) void {
6 assert(a + b == 7);
7}
8
9pub 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 deleted-17
...@@ -1,17 +0,0 @@
1pub fn main() void {
2 add(3, 4);
3}
4
5fn 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
12pub fn assert(ok: bool) void {
13 if (!ok) unreachable; // assertion failure
14}
15
16// run
17//
test/cases/assert_function.10.zig deleted-27
...@@ -1,27 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 116);
3}
4
5fn 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
22pub fn assert(ok: bool) void {
23 if (!ok) unreachable; // assertion failure
24}
25
26// run
27//
test/cases/assert_function.11.zig deleted-66
...@@ -1,66 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 1221);
3 assert(mul(3, 4) == 21609);
4}
5
6fn 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
35fn 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
61pub fn assert(ok: bool) void {
62 if (!ok) unreachable; // assertion failure
63}
64
65// run
66//
test/cases/assert_function.12.zig deleted-47
...@@ -1,47 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 791);
3 assert(add(4, 3) == 79);
4}
5
6fn 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
42pub fn assert(ok: bool) void {
43 if (!ok) unreachable; // assertion failure
44}
45
46// run
47//
test/cases/assert_function.13.zig deleted-19
...@@ -1,19 +0,0 @@
1pub fn main() void {
2 const ignore =
3 \\ cool thx
4 \\
5 ;
6 _ = ignore;
7 add('ぁ', '\x03');
8}
9
10fn add(a: u32, b: u32) void {
11 assert(a + b == 12356);
12}
13
14pub fn assert(ok: bool) void {
15 if (!ok) unreachable; // assertion failure
16}
17
18// run
19//
test/cases/assert_function.14.zig deleted-17
...@@ -1,17 +0,0 @@
1pub fn main() void {
2 add(aa, bb);
3}
4
5const aa = 'ぁ';
6const bb = '\x03';
7
8fn add(a: u32, b: u32) void {
9 assert(a + b == 12356);
10}
11
12pub fn assert(ok: bool) void {
13 if (!ok) unreachable; // assertion failure
14}
15
16// run
17//
test/cases/assert_function.15.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 assert("hello"[0] == 'h');
3}
4
5pub fn assert(ok: bool) void {
6 if (!ok) unreachable; // assertion failure
7}
8
9// run
10//
test/cases/assert_function.16.zig deleted-11
...@@ -1,11 +0,0 @@
1const hello = "hello".*;
2pub fn main() void {
3 assert(hello[1] == 'e');
4}
5
6pub fn assert(ok: bool) void {
7 if (!ok) unreachable; // assertion failure
8}
9
10// run
11//
test/cases/assert_function.17.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 var i: u64 = 0xFFEEDDCCBBAA9988;
3 _ = &i;
4 assert(i == 0xFFEEDDCCBBAA9988);
5}
6
7pub fn assert(ok: bool) void {
8 if (!ok) unreachable; // assertion failure
9}
10
11// run
12//
test/cases/assert_function.18.zig deleted-20
...@@ -1,20 +0,0 @@
1const builtin = @import("builtin");
2
3extern "c" fn write(c_int, usize, usize) usize;
4
5pub fn main() void {
6 for ("hello") |_| print();
7}
8
9fn print() void {
10 _ = write(1, @intFromPtr("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 deleted-21
...@@ -1,21 +0,0 @@
1pub fn main() void {
2 add(3, 4);
3}
4
5fn 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
16pub fn assert(ok: bool) void {
17 if (!ok) unreachable; // assertion failure
18}
19
20// run
21//
test/cases/assert_function.3.zig deleted-22
...@@ -1,22 +0,0 @@
1pub fn main() void {
2 add(3, 4);
3}
4
5fn 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
17pub fn assert(ok: bool) void {
18 if (!ok) unreachable; // assertion failure
19}
20
21// run
22//
test/cases/assert_function.4.zig deleted-15
...@@ -1,15 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 7);
3 assert(add(20, 10) == 30);
4}
5
6fn add(a: u32, b: u32) u32 {
7 return a + b;
8}
9
10pub fn assert(ok: bool) void {
11 if (!ok) unreachable; // assertion failure
12}
13
14// run
15//
test/cases/assert_function.5.zig deleted-19
...@@ -1,19 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 7);
3 assert(add(20, 10) == 30);
4}
5
6fn 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
14pub fn assert(ok: bool) void {
15 if (!ok) unreachable; // assertion failure
16}
17
18// run
19//
test/cases/assert_function.6.zig deleted-9
...@@ -1,9 +0,0 @@
1pub 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 deleted-23
...@@ -1,23 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 var i: u32 = 0;
5 while (i < 4) : (i += 1) print();
6 assert(i == 4);
7}
8
9fn print() void {
10 _ = write(1, @intFromPtr("hello\n"), 6);
11}
12
13pub 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 deleted-20
...@@ -1,20 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 var i: u32 = 0;
5 inline while (i < 4) : (i += 1) print();
6 assert(i == 4);
7}
8
9fn print() void {
10 _ = write(1, @intFromPtr("hello\n"), 6);
11}
12
13pub 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 deleted-22
...@@ -1,22 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 20);
3}
4
5fn 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
17pub fn assert(ok: bool) void {
18 if (!ok) unreachable; // assertion failure
19}
20
21// run
22//
test/cases/binary_operands.0.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: u8 = 5;
3 i += 20;
4 if (i != 25) unreachable;
5}
6
7// run
8// target=wasm32-wasi
9//
test/cases/binary_operands.1.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: i32 = 2147483647;
3 _ = &i;
4 if (i +% 1 != -2147483648) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.10.zig deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() void {
2 var i: u32 = 5;
3 i *= 7;
4 var result: u32 = foo(i, 10);
5 _ = &result;
6 if (result != 350) unreachable;
7 return;
8}
9fn foo(x: u32, y: u32) u32 {
10 return x * y;
11}
12
13// run
14//
test/cases/binary_operands.11.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 var i: i32 = 2147483647;
3 _ = &i;
4 const result = i *% 2;
5 if (result != -2) unreachable;
6 return;
7}
8
9// run
10//
test/cases/binary_operands.12.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: u3 = 3;
3 _ = &i;
4 if (i *% 3 != 1) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.13.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: i4 = 3;
3 _ = &i;
4 if (i *% 3 != -7) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.14.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() void {
2 var i: u32 = 352;
3 i /= 7; // i = 50
4 const result: u32 = foo(i, 7);
5 if (result != 7) unreachable;
6 return;
7}
8fn foo(x: u32, y: u32) u32 {
9 return x / y;
10}
11
12// run
13//
test/cases/binary_operands.15.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 5;
3 i &= 6;
4 return i - 4;
5}
6
7// run
8//
test/cases/binary_operands.16.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 5;
3 i |= 6;
4 return i - 7;
5}
6
7// run
8//
test/cases/binary_operands.17.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 5;
3 i ^= 6;
4 return i - 3;
5}
6
7// run
8//
test/cases/binary_operands.18.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = false;
3 b = b or false;
4 if (b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.19.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = true;
3 b = b or false;
4 if (!b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.2.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: i4 = 7;
3 _ = &i;
4 if (i +% 1 != -8) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.20.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = false;
3 b = b or true;
4 if (!b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.21.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = true;
3 b = b or true;
4 if (!b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.22.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = false;
3 b = b and false;
4 if (b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.23.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = true;
3 b = b and false;
4 if (b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.24.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = false;
3 b = b and true;
4 if (b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.25.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var b: bool = true;
3 b = b and true;
4 if (!b) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.3.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 255;
3 _ = &i;
4 return i +% 1;
5}
6
7// run
8//
test/cases/binary_operands.4.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 5;
3 i += 20;
4 const result: u8 = foo(i, 10);
5 return result - 35;
6}
7fn foo(x: u8, y: u8) u8 {
8 return x + y;
9}
10
11// run
12//
test/cases/binary_operands.5.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 20;
3 i -= 5;
4 return i - 15;
5}
6
7// run
8//
test/cases/binary_operands.6.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: i32 = -2147483648;
3 _ = &i;
4 if (i -% 1 != 2147483647) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.7.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i: i7 = -64;
3 _ = &i;
4 if (i -% 1 != 63) unreachable;
5 return;
6}
7
8// run
9//
test/cases/binary_operands.8.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() void {
2 var i: u4 = 0;
3 _ = &i;
4 if (i -% 1 != 15) unreachable;
5}
6
7// run
8//
test/cases/binary_operands.9.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 5;
3 i -= 3;
4 var result: u8 = foo(i, 10);
5 _ = &result;
6 return result - 8;
7}
8fn foo(x: u8, y: u8) u8 {
9 return y - x;
10}
11
12// run
13//
test/cases/break_continue.0.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 while (true) {
3 break;
4 }
5}
6
7// run
8// target=x86_64-linux,x86_64-macos
9//
test/cases/break_continue.1.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() void {
2 foo: while (true) {
3 break :foo;
4 }
5}
6
7// run
8//
test/cases/break_continue.2.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 var i: u64 = 0;
3 while (true) : (i += 1) {
4 if (i == 4) return;
5 continue;
6 }
7}
8
9// run
10//
test/cases/break_continue.3.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 var i: u64 = 0;
3 foo: while (true) : (i += 1) {
4 if (i == 4) return;
5 continue :foo;
6 }
7}
8
9// run
10//
test/cases/catch_at_comptime.0.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const i: anyerror!u64 = 0;
3 const caught = i catch 5;
4 assert(caught == 0);
5}
6fn assert(b: bool) void {
7 if (!b) unreachable;
8}
9
10// run
11//
test/cases/catch_at_comptime.1.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const i: anyerror!u64 = error.B;
3 const caught = i catch 5;
4 assert(caught == 5);
5}
6fn assert(b: bool) void {
7 if (!b) unreachable;
8}
9
10// run
11//
test/cases/catch_at_comptime.2.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const a: anyerror!comptime_int = 42;
3 const b: *const comptime_int = &(a catch unreachable);
4 assert(b.* == 42);
5}
6fn assert(b: bool) void {
7 if (!b) unreachable; // assertion failure
8}
9
10// run
11//
test/cases/catch_at_comptime.3.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 const a: anyerror!u32 = error.B;
3 _ = &(a catch |err| assert(err == error.B));
4}
5fn assert(b: bool) void {
6 if (!b) unreachable;
7}
8
9// run
10//
test/cases/catch_at_comptime.4.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 const a: anyerror!u32 = error.Bar;
3 a catch |err| assert(err == error.Bar);
4}
5fn assert(b: bool) void {
6 if (!b) unreachable;
7}
8
9// run
10//
test/cases/compile_log.0.zig deleted-22
...@@ -1,22 +0,0 @@
1export fn _start() noreturn {
2 const b = true;
3 var f: u32 = 1;
4 @compileLog(b, 20, f, x);
5 @compileLog(1000);
6 var bruh: usize = true;
7 _ = .{ &f, &bruh };
8 unreachable;
9}
10export fn other() void {
11 @compileLog(1234);
12}
13fn x() void {}
14
15// error
16//
17// :6:23: error: expected type 'usize', found 'bool'
18//
19// Compile Log Output:
20// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
21// @as(comptime_int, 1000)
22// @as(comptime_int, 1234)
test/cases/compile_log.1.zig deleted-21
...@@ -1,21 +0,0 @@
1export fn _start() noreturn {
2 const b = true;
3 var f: u32 = 1;
4 _ = &f;
5 @compileLog(b, 20, f, x);
6 @compileLog(1000);
7 unreachable;
8}
9export fn other() void {
10 @compileLog(1234);
11}
12fn x() void {}
13
14// error
15//
16// :9:5: error: found compile log statement
17// :4:5: note: also here
18//
19// Compile Log Output:
20// @as(bool, true), @as(comptime_int, 20), @as(u32, [runtime value]), @as(fn () void, (function 'x'))
21// @as(comptime_int, 1000)
test/cases/comptime_var.0.zig deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() void {
2 var a: u32 = 0;
3 _ = &a;
4 comptime var b: u32 = 0;
5 if (a == 0) b = 3;
6}
7
8// error
9// output_mode=Exe
10// target=x86_64-macos,x86_64-linux
11// link_libc=true
12//
13// :5:19: error: store to comptime variable depends on runtime condition
14// :5:11: note: runtime condition here
test/cases/comptime_var.1.zig deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() void {
2 var a: u32 = 0;
3 _ = &a;
4 comptime var b: u32 = 0;
5 switch (a) {
6 0 => {},
7 else => b = 3,
8 }
9}
10
11// error
12//
13// :6:19: error: store to comptime variable depends on runtime condition
14// :4:13: note: runtime condition here
test/cases/comptime_var.2.zig deleted-17
...@@ -1,17 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 comptime var len: u32 = 5;
5 print(len);
6 len += 9;
7 print(len);
8}
9
10fn print(len: usize) void {
11 _ = write(1, @intFromPtr("Hello, World!\n"), len);
12}
13
14// run
15//
16// HelloHello, World!
17//
test/cases/comptime_var.3.zig deleted-10
...@@ -1,10 +0,0 @@
1comptime {
2 var x: i32 = 1;
3 x += 1;
4 if (x != 1) unreachable;
5}
6pub fn main() void {}
7
8// error
9//
10// :4:17: error: reached unreachable code
test/cases/comptime_var.4.zig deleted-9
...@@ -1,9 +0,0 @@
1pub 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 deleted-16
...@@ -1,16 +0,0 @@
1pub fn main() void {
2 var a: u32 = 0;
3 _ = &a;
4 if (a == 0) {
5 comptime var b: u32 = 0;
6 b = 1;
7 }
8}
9comptime {
10 var x: i32 = 1;
11 x += 1;
12 if (x != 2) unreachable;
13}
14
15// run
16//
test/cases/comptime_var.6.zig deleted-15
...@@ -1,15 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 comptime var i: u64 = 2;
5 inline while (i < 6) : (i += 1) {
6 print(i);
7 }
8}
9fn print(len: usize) void {
10 _ = write(1, @intFromPtr("Hello"), len);
11}
12
13// run
14//
15// HeHelHellHello
test/cases/conditional_branches.0.zig deleted-23
...@@ -1,23 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 foo(123);
5}
6
7fn foo(x: u64) void {
8 if (x > 42) {
9 print();
10 }
11}
12
13fn print() void {
14 const str = "Hello, World!\n";
15 _ = write(1, @intFromPtr(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 deleted-25
...@@ -1,25 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 foo(true);
5}
6
7fn foo(x: bool) void {
8 if (x) {
9 print();
10 print();
11 } else {
12 print();
13 }
14}
15
16fn print() void {
17 const str = "Hello, World!\n";
18 _ = write(1, @intFromPtr(str.ptr), ptr.len);
19}
20
21// run
22//
23// Hello, World!
24// Hello, World!
25//
test/cases/conditions.0.zig deleted-11
...@@ -1,11 +0,0 @@
1pub 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 deleted-12
...@@ -1,12 +0,0 @@
1pub 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 deleted-12
...@@ -1,12 +0,0 @@
1pub 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 deleted-16
...@@ -1,16 +0,0 @@
1pub 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 deleted-15
...@@ -1,15 +0,0 @@
1pub fn main() void {
2 assert(foo(true) != @as(i32, 30));
3}
4
5fn assert(ok: bool) void {
6 if (!ok) unreachable;
7}
8
9fn 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 deleted-21
...@@ -1,21 +0,0 @@
1pub fn main() void {
2 assert(foo(false) == @as(i32, 20));
3 assert(foo(true) == @as(i32, 30));
4}
5
6fn assert(ok: bool) void {
7 if (!ok) unreachable;
8}
9
10fn foo(ok: bool) i32 {
11 const val: i32 = blk: {
12 var x: i32 = 1;
13 _ = &x;
14 if (!ok) break :blk x + @as(i32, 9);
15 break :blk x + @as(i32, 19);
16 };
17 return val + 10;
18}
19
20// run
21//
test/cases/double_ampersand.0.zig deleted-6
...@@ -1,6 +0,0 @@
1pub const a = if (true && false) 1 else 2;
2
3// error
4// output_mode=Exe
5//
6// :1:24: error: ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND
test/cases/double_ampersand.1.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const a = true;
3 const b = false;
4 _ = a & &b;
5}
6
7// error
8//
9// :4:11: error: incompatible types: 'bool' and '*const bool'
10// :4:9: note: type 'bool' here
11// :4:13: note: type '*const bool' here
test/cases/double_ampersand.2.zig deleted-7
...@@ -1,7 +0,0 @@
1pub fn main() void {
2 const b: u8 = 1;
3 _ = &&b;
4}
5
6// run
7//
test/cases/enum_values.0.zig deleted-18
...@@ -1,18 +0,0 @@
1const Number = enum { One, Two, Three };
2
3pub fn main() void {
4 var number1 = Number.One;
5 var number2: Number = .Two;
6 if (false) {
7 &number1;
8 &number2;
9 }
10 const number3: Number = @enumFromInt(2);
11 if (@intFromEnum(number3) != 2) {
12 unreachable;
13 }
14 return;
15}
16
17// run
18//
test/cases/enum_values.1.zig deleted-25
...@@ -1,25 +0,0 @@
1const Number = enum { One, Two, Three };
2
3pub fn main() void {
4 var number1 = Number.One;
5 _ = &number1;
6 var number2: Number = .Two;
7 _ = &number2;
8 const number3: Number = @enumFromInt(2);
9 assert(number1 != number2);
10 assert(number2 != number3);
11 assert(@intFromEnum(number1) == 0);
12 assert(@intFromEnum(number2) == 1);
13 assert(@intFromEnum(number3) == 2);
14 var x: Number = .Two;
15 _ = &x;
16 assert(number2 == x);
17
18 return;
19}
20fn assert(val: bool) void {
21 if (!val) unreachable;
22}
23
24// run
25//
test/cases/error_unions.0.zig deleted-16
...@@ -1,16 +0,0 @@
1pub fn main() void {
2 var e1 = error.Foo;
3 var e2 = error.Bar;
4 _ = .{ &e1, &e2 };
5 assert(e1 != e2);
6 assert(e1 == error.Foo);
7 assert(e2 == error.Bar);
8}
9
10fn assert(b: bool) void {
11 if (!b) unreachable;
12}
13
14// run
15// target=wasm32-wasi
16//
test/cases/error_unions.1.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() u8 {
2 var e: anyerror!u8 = 5;
3 _ = &e;
4 const i = e catch 10;
5 return i - 5;
6}
7
8// run
9//
test/cases/error_unions.2.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() u8 {
2 var e: anyerror!u8 = error.Foo;
3 _ = &e;
4 const i = e catch 10;
5 return i - 10;
6}
7
8// run
9//
test/cases/error_unions.3.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var e = foo();
3 _ = &e;
4 const i = e catch 69;
5 return i - 5;
6}
7
8fn foo() anyerror!u8 {
9 return 5;
10}
11
12// run
13//
test/cases/error_unions.4.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var e = foo();
3 _ = &e;
4 const i = e catch 69;
5 return i - 69;
6}
7
8fn foo() anyerror!u8 {
9 return error.Bruh;
10}
11
12// run
13//
test/cases/error_unions.5.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var e = foo();
3 _ = &e;
4 const i = e catch 42;
5 return i - 42;
6}
7
8fn foo() anyerror!u8 {
9 return error.Dab;
10}
11
12// run
13//
test/cases/errors.0.zig deleted-15
...@@ -1,15 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 foo() catch print();
5}
6
7fn foo() anyerror!void {}
8
9fn print() void {
10 _ = std.posix.write(1, "Hello, World!\n") catch {};
11}
12
13// run
14// target=x86_64-macos
15//
test/cases/errors.1.zig deleted-18
...@@ -1,18 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 foo() catch print();
5}
6
7fn foo() anyerror!void {
8 return error.Test;
9}
10
11fn print() void {
12 _ = std.posix.write(1, "Hello, World!\n") catch {};
13}
14
15// run
16//
17// Hello, World!
18//
test/cases/errors.2.zig deleted-27
...@@ -1,27 +0,0 @@
1pub 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
14fn assert(ok: bool) void {
15 if (!ok) unreachable;
16}
17
18fn foo() anyerror!void {
19 return error.Foo;
20}
21
22fn bar() anyerror!void {
23 return error.Bar;
24}
25
26// run
27//
test/cases/errors.3.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 foo() catch unreachable;
3}
4
5fn foo() anyerror!void {
6 try bar();
7}
8
9fn bar() anyerror!void {}
10
11// run
12//
test/cases/extern_variable_has_no_type.0.zig deleted-10
...@@ -1,10 +0,0 @@
1comptime {
2 const x = foo + foo;
3 _ = x;
4}
5extern var foo: i32;
6
7// error
8//
9// :2:19: error: unable to evaluate comptime expression
10// :2:15: note: operation is runtime due to this operand
test/cases/extern_variable_has_no_type.1.zig deleted-8
...@@ -1,8 +0,0 @@
1export fn entry() void {
2 _ = foo;
3}
4extern var foo;
5
6// error
7//
8// :4:8: error: unable to infer variable type
test/cases/function_calls.0.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 foo();
3 bar();
4}
5fn foo() void {
6 bar();
7 bar();
8}
9fn bar() void {}
10
11// run
12//
test/cases/function_calls.1.zig deleted-15
...@@ -1,15 +0,0 @@
1pub fn main() void {
2 bar();
3 foo();
4 foo();
5 bar();
6 foo();
7 bar();
8}
9fn foo() void {
10 bar();
11}
12fn bar() void {}
13
14// run
15//
test/cases/function_calls.2.zig deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() void {
2 bar();
3 foo();
4 return;
5}
6fn foo() void {
7 bar();
8 bar();
9 bar();
10}
11fn bar() void {}
12
13// run
14//
test/cases/function_calls.3.zig deleted-10
...@@ -1,10 +0,0 @@
1pub fn main() void {
2 foo(10, 20);
3}
4fn foo(x: u8, y: u8) void {
5 _ = x;
6 _ = y;
7}
8
9// run
10//
test/cases/hello_world_with_updates.0.zig deleted-6
...@@ -1,6 +0,0 @@
1// error
2// output_mode=Exe
3// target=x86_64-linux,x86_64-macos
4// link_libc=true
5//
6// :?:?: error: root source file struct 'tmp' has no member named 'main'
test/cases/hello_world_with_updates.1.zig deleted-6
...@@ -1,6 +0,0 @@
1pub 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 deleted-19
...@@ -1,19 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2extern "c" fn exit(c_int) noreturn;
3
4pub export fn main() noreturn {
5 print();
6
7 exit(0);
8}
9
10fn print() void {
11 const msg = @intFromPtr("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 deleted-16
...@@ -1,16 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 print();
5}
6
7fn print() void {
8 const msg = @intFromPtr("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 deleted-22
...@@ -1,22 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 print();
5 print();
6 print();
7 print();
8}
9
10fn print() void {
11 const msg = @intFromPtr("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 deleted-16
...@@ -1,16 +0,0 @@
1extern "c" fn write(c_int, usize, usize) usize;
2
3pub fn main() void {
4 print();
5}
6
7fn print() void {
8 const msg = @intFromPtr("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 deleted-20
...@@ -1,20 +0,0 @@
1const builtin = @import("builtin");
2
3extern "c" fn write(c_int, usize, usize) usize;
4
5pub fn main() void {
6 print();
7 print();
8}
9
10fn print() void {
11 const msg = @intFromPtr("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/int_to_ptr.0.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() void {
2 _ = @as(*u8, @ptrFromInt(0));
3}
4
5// error
6// output_mode=Exe
7//
8// :2:18: error: pointer type '*u8' does not allow address zero
test/cases/int_to_ptr.1.zig deleted-7
...@@ -1,7 +0,0 @@
1pub fn main() void {
2 _ = @as(*u32, @ptrFromInt(2));
3}
4
5// error
6//
7// :2:19: error: pointer type '*u32' requires aligned address
test/cases/locals.0.zig deleted-14
...@@ -1,14 +0,0 @@
1pub 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 / &i;
8 }
9 if (i != 5) unreachable;
10}
11
12// run
13// target=wasm32-wasi
14//
test/cases/locals.1.zig deleted-18
...@@ -1,18 +0,0 @@
1pub fn main() void {
2 var i: u8 = 5;
3 var y: f32 = 42.0;
4 _ = &y;
5 var x: u8 = 10;
6 _ = &x;
7 foo(i, x);
8 i = x;
9 if (i != 10) unreachable;
10}
11fn foo(x: u8, y: u8) void {
12 _ = y;
13 var i: u8 = 10;
14 i = x;
15}
16
17// run
18//
test/cases/lower_unnamed_consts_structs.0.zig deleted-25
...@@ -1,25 +0,0 @@
1const Foo = struct {
2 a: u8,
3 b: u32,
4
5 fn first(self: *Foo) u8 {
6 return self.a;
7 }
8
9 fn second(self: *Foo) u32 {
10 return self.b;
11 }
12};
13
14pub fn main() void {
15 var foo = Foo{ .a = 1, .b = 5 };
16 assert(foo.first() == 1);
17 assert(foo.second() == 5);
18}
19
20fn assert(ok: bool) void {
21 if (!ok) unreachable;
22}
23
24// run
25//
test/cases/lower_unnamed_consts_structs.1.zig deleted-35
...@@ -1,35 +0,0 @@
1const Foo = struct {
2 a: u8,
3 b: u32,
4
5 fn first(self: *Foo) u8 {
6 return self.a;
7 }
8
9 fn second(self: *Foo) u32 {
10 return self.b;
11 }
12};
13
14pub fn main() void {
15 var foo = Foo{ .a = 1, .b = 5 };
16 assert(foo.first() == 1);
17 assert(foo.second() == 5);
18
19 foo.a = 10;
20 foo.b = 255;
21
22 assert(foo.first() == 10);
23 assert(foo.second() == 255);
24
25 var foo2 = Foo{ .a = 15, .b = 255 };
26 assert(foo2.first() == 15);
27 assert(foo2.second() == 255);
28}
29
30fn assert(ok: bool) void {
31 if (!ok) unreachable;
32}
33
34// run
35//
test/cases/lower_unnamed_consts_structs.2.zig deleted-25
...@@ -1,25 +0,0 @@
1const Foo = struct {
2 a: u8,
3 b: u32,
4
5 fn first(self: *Foo) u8 {
6 return self.a;
7 }
8
9 fn second(self: *Foo) u32 {
10 return self.b;
11 }
12};
13
14pub fn main() void {
15 var foo2 = Foo{ .a = 15, .b = 255 };
16 assert(foo2.first() == 15);
17 assert(foo2.second() == 255);
18}
19
20fn assert(ok: bool) void {
21 if (!ok) unreachable;
22}
23
24// run
25//
test/cases/merge_error_sets.0.zig deleted-18
...@@ -1,18 +0,0 @@
1pub fn main() void {
2 const E = error{ A, B, D } || error{ A, B, C };
3 E.A catch {};
4 E.B catch {};
5 E.C catch {};
6 E.D catch {};
7 const E2 = error{ X, Y } || @TypeOf(error.Z);
8 E2.X catch {};
9 E2.Y catch {};
10 E2.Z catch {};
11 assert(anyerror || error{Z} == anyerror);
12}
13fn assert(b: bool) void {
14 if (!b) unreachable;
15}
16
17// run
18//
test/cases/merge_error_sets.1.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 const z = true || false;
3 _ = z;
4}
5
6// error
7//
8// :2:15: error: expected error set type, found 'bool'
9// :2:20: note: '||' merges error sets; 'or' performs boolean OR
test/cases/multiplying_numbers_at_runtime_and_comptime.0.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 mul(3, 4);
3}
4
5fn mul(a: u32, b: u32) void {
6 if (a * b != 12) unreachable;
7}
8
9// run
10// target=x86_64-linux,x86_64-macos
11//
test/cases/multiplying_numbers_at_runtime_and_comptime.1.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 if (x - 12 != 0) unreachable;
3}
4
5fn mul(a: u32, b: u32) u32 {
6 return a * b;
7}
8
9const x = mul(3, 4);
10
11// run
12//
test/cases/multiplying_numbers_at_runtime_and_comptime.2.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() void {
2 var x: usize = 5;
3 _ = &x;
4 const y = mul(2, 3, x);
5 if (y - 30 != 0) unreachable;
6}
7
8inline fn mul(a: usize, b: usize, c: usize) usize {
9 return a * b * c;
10}
11
12// run
13//
test/cases/only_1_function_and_it_gets_updated.0.zig deleted-7
...@@ -1,7 +0,0 @@
1pub 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 deleted-8
...@@ -1,8 +0,0 @@
1pub export fn _start() noreturn {
2 var dummy: u32 = 10;
3 _ = &dummy;
4 while (true) {}
5}
6
7// run
8//
test/cases/optional_payload.0.zig deleted-19
...@@ -1,19 +0,0 @@
1pub fn main() void {
2 var x: u32 = undefined;
3 const maybe_x = byPtr(&x);
4 assert(maybe_x != null);
5 maybe_x.?.* = 123;
6 assert(x == 123);
7}
8
9fn byPtr(x: *u32) ?*u32 {
10 return x;
11}
12
13fn assert(ok: bool) void {
14 if (!ok) unreachable;
15}
16
17// run
18// target=x86_64-linux,x86_64-macos
19//
test/cases/optional_payload.1.zig deleted-17
...@@ -1,17 +0,0 @@
1pub fn main() void {
2 var x: u32 = undefined;
3 const maybe_x = byPtr(&x);
4 assert(maybe_x == null);
5}
6
7fn byPtr(x: *u32) ?*u32 {
8 _ = x;
9 return null;
10}
11
12fn assert(ok: bool) void {
13 if (!ok) unreachable;
14}
15
16// run
17//
test/cases/optional_payload.2.zig deleted-18
...@@ -1,18 +0,0 @@
1pub fn main() void {
2 var x: u8 = undefined;
3 const maybe_x = byPtr(&x);
4 assert(maybe_x != null);
5 maybe_x.?.* = 255;
6 assert(x == 255);
7}
8
9fn byPtr(x: *u8) ?*u8 {
10 return x;
11}
12
13fn assert(ok: bool) void {
14 if (!ok) unreachable;
15}
16
17// run
18//
test/cases/optional_payload.3.zig deleted-18
...@@ -1,18 +0,0 @@
1pub fn main() void {
2 var x: i8 = undefined;
3 const maybe_x = byPtr(&x);
4 assert(maybe_x != null);
5 maybe_x.?.* = -1;
6 assert(x == -1);
7}
8
9fn byPtr(x: *i8) ?*i8 {
10 return x;
11}
12
13fn assert(ok: bool) void {
14 if (!ok) unreachable;
15}
16
17// run
18//
test/cases/optionals.0.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var x: ?u8 = 5;
3 _ = &x;
4 var y: u8 = 0;
5 if (x) |val| {
6 y = val;
7 }
8 return y - 5;
9}
10
11// run
12// target=wasm32-wasi
13//
test/cases/optionals.1.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() u8 {
2 var x: ?u8 = null;
3 _ = &x;
4 var y: u8 = 0;
5 if (x) |val| {
6 y = val;
7 }
8 return y;
9}
10
11// run
12//
test/cases/optionals.2.zig deleted-8
...@@ -1,8 +0,0 @@
1pub fn main() u8 {
2 var x: ?u8 = 5;
3 _ = &x;
4 return x.? - 5;
5}
6
7// run
8//
test/cases/optionals.3.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() u8 {
2 var x: u8 = 5;
3 var y: ?u8 = x;
4 _ = .{ &x, &y };
5 return y.? - 5;
6}
7
8// run
9//
test/cases/optionals.4.zig deleted-13
...@@ -1,13 +0,0 @@
1pub 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/orelse_at_comptime.0.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const i: ?u64 = 0;
3 const result = i orelse 5;
4 assert(result == 0);
5}
6fn assert(b: bool) void {
7 if (!b) unreachable;
8}
9
10// run
11//
test/cases/orelse_at_comptime.1.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const i: ?u64 = null;
3 const result = i orelse 5;
4 assert(result == 5);
5}
6fn assert(b: bool) void {
7 if (!b) unreachable;
8}
9
10// run
11//
test/cases/parameters_and_return_values.0.zig deleted-20
...@@ -1,20 +0,0 @@
1const std = @import("std");
2
3pub fn main() void {
4 print(id(14));
5}
6
7fn id(x: u32) u32 {
8 return x;
9}
10
11fn print(len: u32) void {
12 const str = "Hello, World!\n";
13 _ = std.posix.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 deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() void {
2 assert(add(1, 2, 3, 4, 5, 6) == 21);
3}
4
5fn add(a: u32, b: u32, c: u32, d: u32, e: u32, f: u32) u32 {
6 return a + b + c + d + e + f;
7}
8
9pub fn assert(ok: bool) void {
10 if (!ok) unreachable; // assertion failure
11}
12
13// run
14//
test/cases/pointers.0.zig deleted-14
...@@ -1,14 +0,0 @@
1pub fn main() u8 {
2 var x: u8 = 0;
3
4 foo(&x);
5 return x - 2;
6}
7
8fn foo(x: *u8) void {
9 x.* = 2;
10}
11
12// run
13// target=wasm32-wasi
14//
test/cases/pointers.1.zig deleted-18
...@@ -1,18 +0,0 @@
1pub fn main() u8 {
2 var x: u8 = 0;
3
4 foo(&x);
5 bar(&x);
6 return x - 4;
7}
8
9fn foo(x: *u8) void {
10 x.* = 2;
11}
12
13fn bar(x: *u8) void {
14 x.* += 2;
15}
16
17// run
18//
test/cases/redundant_comptime.0.zig deleted-7
...@@ -1,7 +0,0 @@
1pub fn main() void {
2 var a: comptime u32 = 0;
3}
4
5// error
6//
7// :2:12: error: redundant comptime keyword in already comptime scope
test/cases/redundant_comptime.1.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 comptime {
3 var a: u32 = comptime 0;
4 }
5}
6
7// error
8//
9// :3:22: error: redundant comptime keyword in already comptime scope
test/cases/spilling_registers.0.zig deleted-38
...@@ -1,38 +0,0 @@
1pub fn main() void {
2 assert(add(3, 4) == 791);
3}
4
5fn 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
32fn 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 deleted-37
...@@ -1,37 +0,0 @@
1pub fn main() void {
2 assert(addMul(3, 4) == 357747496);
3}
4
5fn 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
32fn assert(ok: bool) void {
33 if (!ok) unreachable;
34}
35
36// run
37//
test/cases/structs.0.zig deleted-11
...@@ -1,11 +0,0 @@
1const Example = struct { x: u8 };
2
3pub fn main() u8 {
4 var example: Example = .{ .x = 5 };
5 _ = &example;
6 return example.x - 5;
7}
8
9// run
10// target=wasm32-wasi
11//
test/cases/structs.1.zig deleted-10
...@@ -1,10 +0,0 @@
1const Example = struct { x: u8 };
2
3pub 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 deleted-10
...@@ -1,10 +0,0 @@
1const Example = struct { x: u8, y: u8 };
2
3pub fn main() u8 {
4 var example: Example = .{ .x = 5, .y = 10 };
5 _ = &example;
6 return example.y + example.x - 15;
7}
8
9// run
10//
test/cases/structs.3.zig deleted-13
...@@ -1,13 +0,0 @@
1const Example = struct { x: u8, y: u8 };
2
3pub fn main() u8 {
4 var example: Example = .{ .x = 5, .y = 10 };
5 var example2: Example = .{ .x = 10, .y = 20 };
6 _ = &example2;
7
8 example = example2;
9 return example.y + example.x - 30;
10}
11
12// run
13//
test/cases/structs.4.zig deleted-11
...@@ -1,11 +0,0 @@
1const Example = struct { x: u8, y: u8 };
2
3pub 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 deleted-16
...@@ -1,16 +0,0 @@
1pub fn main() u8 {
2 var val: u8 = 1;
3 _ = &val;
4 const a: u8 = switch (val) {
5 0, 1 => 2,
6 2 => 3,
7 3 => 4,
8 else => 5,
9 };
10
11 return a - 2;
12}
13
14// run
15// target=wasm32-wasi
16//
test/cases/switch.1.zig deleted-16
...@@ -1,16 +0,0 @@
1pub fn main() u8 {
2 var val: u8 = 2;
3 _ = &val;
4 var a: u8 = switch (val) {
5 0, 1 => 2,
6 2 => 3,
7 3 => 4,
8 else => 5,
9 };
10 _ = &a;
11
12 return a - 3;
13}
14
15// run
16//
test/cases/switch.2.zig deleted-15
...@@ -1,15 +0,0 @@
1pub fn main() u8 {
2 var val: u8 = 10;
3 _ = &val;
4 const a: u8 = switch (val) {
5 0, 1 => 2,
6 2 => 3,
7 3 => 4,
8 else => 5,
9 };
10
11 return a - 5;
12}
13
14// run
15//
test/cases/switch.3.zig deleted-16
...@@ -1,16 +0,0 @@
1const MyEnum = enum { One, Two, Three };
2
3pub fn main() u8 {
4 var val: MyEnum = .Two;
5 _ = &val;
6 const a: u8 = switch (val) {
7 .One => 1,
8 .Two => 2,
9 .Three => 3,
10 };
11
12 return a - 2;
13}
14
15// run
16//
test/cases/type_of.0.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() void {
2 var x: usize = 0;
3 _ = &x;
4 const z = @TypeOf(x, @as(u128, 5));
5 assert(z == u128);
6}
7
8pub fn assert(ok: bool) void {
9 if (!ok) unreachable; // assertion failure
10}
11
12// run
13//
test/cases/type_of.1.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 const z = @TypeOf(true);
3 assert(z == bool);
4}
5
6pub fn assert(ok: bool) void {
7 if (!ok) unreachable; // assertion failure
8}
9
10// run
11//
test/cases/type_of.2.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 _ = @TypeOf(true, 1);
3}
4
5// error
6//
7// :2:9: error: incompatible types: 'bool' and 'comptime_int'
8// :2:17: note: type 'bool' here
9// :2:23: note: type 'comptime_int' here
test/cases/unused_labels.0.zig deleted-8
...@@ -1,8 +0,0 @@
1comptime {
2 foo: {}
3}
4
5// error
6// output_mode=Exe
7//
8// :2:5: error: unused block label
test/cases/unused_labels.1.zig deleted-7
...@@ -1,7 +0,0 @@
1comptime {
2 foo: while (true) {}
3}
4
5// error
6//
7// :2:5: error: unused while loop label
test/cases/unused_labels.2.zig deleted-7
...@@ -1,7 +0,0 @@
1comptime {
2 foo: for ("foo") |_| {}
3}
4
5// error
6//
7// :2:5: error: unused for loop label
test/cases/unused_labels.3.zig deleted-10
...@@ -1,10 +0,0 @@
1comptime {
2 blk: {
3 blk: {}
4 }
5}
6
7// error
8//
9// :2:11: error: redefinition of label 'blk'
10// :2:5: note: previous definition here
test/cases/variable_shadowing.0.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 var i: u32 = 10;
3 var i: u32 = 10;
4}
5
6// error
7// backend=stage2
8// target=x86_64-linux,x86_64-macos
9//
10// :3:9: error: redeclaration of local variable 'i'
11// :2:9: note: previous declaration here
test/cases/variable_shadowing.1.zig deleted-9
...@@ -1,9 +0,0 @@
1var testing: i64 = 10;
2pub fn main() void {
3 var testing: i64 = 20;
4}
5
6// error
7//
8// :3:9: error: local variable shadows declaration of 'testing'
9// :1:1: note: declared here
test/cases/variable_shadowing.10.zig deleted-9
...@@ -1,9 +0,0 @@
1fn foo() !void {
2 var i: anyerror!usize = 1;
3 _ = i catch |i| return i;
4}
5
6// error
7//
8// :3:18: error: redeclaration of local variable 'i'
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.2.zig deleted-13
...@@ -1,13 +0,0 @@
1fn a() type {
2 return struct {
3 pub fn b() void {
4 const c = 6;
5 const c = 69;
6 }
7 };
8}
9
10// error
11//
12// :5:19: error: redeclaration of local constant 'c'
13// :4:19: note: previous declaration here
test/cases/variable_shadowing.3.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 for ("n", 0..) |_, i| {}
4}
5
6// error
7//
8// :3:24: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.4.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 for ("n") |i| {}
4}
5
6// error
7//
8// :3:16: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.5.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 while ("n") |i| {}
4}
5
6// error
7//
8// :3:18: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.6.zig deleted-11
...@@ -1,11 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 while ("n") |bruh| {
4 _ = bruh;
5 } else |i| {}
6}
7
8// error
9//
10// :5:13: error: capture 'i' shadows local variable from outer scope
11// :2:9: note: previous declaration here
test/cases/variable_shadowing.7.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 if (true) |i| {}
4}
5
6// error
7//
8// :3:16: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.8.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 if (true) |i| {} else |e| {}
4}
5
6// error
7//
8// :3:16: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/variable_shadowing.9.zig deleted-9
...@@ -1,9 +0,0 @@
1pub fn main() void {
2 var i = 0;
3 if (true) |_| {} else |i| {}
4}
5
6// error
7//
8// :3:28: error: capture 'i' shadows local variable from outer scope
9// :2:9: note: previous declaration here
test/cases/while_loops.0.zig deleted-12
...@@ -1,12 +0,0 @@
1pub 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 deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 0;
3 while (i < @as(u8, 10)) {
4 var x: u8 = 1;
5 _ = &x;
6 i += x;
7 }
8 return i - 10;
9}
10
11// run
12//
test/cases/while_loops.2.zig deleted-13
...@@ -1,13 +0,0 @@
1pub fn main() u8 {
2 var i: u8 = 0;
3 while (i < @as(u8, 10)) {
4 var x: u8 = 1;
5 _ = &x;
6 i += x;
7 if (i == @as(u8, 5)) break;
8 }
9 return i - 5;
10}
11
12// run
13//
test/cases/x86_64-linux/inline_assembly.0.zig deleted-16
...@@ -1,16 +0,0 @@
1pub fn main() void {
2 const number = 1234;
3 const x = asm volatile ("syscall"
4 : [o] "{rax}" (-> number),
5 : [number] "{rax}" (231),
6 [arg1] "{rdi}" (60),
7 : "rcx", "r11", "memory"
8 );
9 _ = x;
10}
11
12// error
13// output_mode=Exe
14// target=x86_64-linux
15//
16// :4:27: error: expected type 'type', found 'comptime_int'
test/cases/x86_64-linux/inline_assembly.1.zig deleted-15
...@@ -1,15 +0,0 @@
1const S = struct {
2 comptime {
3 asm volatile (
4 \\zig_moment:
5 \\syscall
6 );
7 }
8};
9pub fn main() void {
10 _ = S;
11}
12
13// error
14//
15// :3:13: error: volatile is meaningless on global assembly
test/cases/x86_64-linux/inline_assembly.2.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {
2 var bruh: u32 = 1;
3 asm (""
4 :
5 : [bruh] "{rax}" (4),
6 : "memory"
7 );
8}
9
10// error
11//
12// :3:5: error: assembly expression with no output must be marked volatile
test/cases/x86_64-linux/inline_assembly.3.zig deleted-12
...@@ -1,12 +0,0 @@
1pub fn main() void {}
2comptime {
3 asm (""
4 :
5 : [bruh] "{rax}" (4),
6 : "memory"
7 );
8}
9
10// error
11//
12// :3:5: error: global assembly cannot have inputs, outputs, or clobbers
test/incremental/change_fn_type created+35
...@@ -0,0 +1,35 @@
1#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=initial version
5#file=main.zig
6pub fn main() !void {
7 try foo(123);
8}
9fn foo(x: u8) !void {
10 return std.io.getStdOut().writer().print("{d}\n", .{x});
11}
12const std = @import("std");
13#expect_stdout="123\n"
14
15#update=change function type
16#file=main.zig
17pub fn main() !void {
18 try foo(123);
19}
20fn foo(x: i64) !void {
21 return std.io.getStdOut().writer().print("{d}\n", .{x});
22}
23const std = @import("std");
24#expect_stdout="123\n"
25
26#update=change function argument
27#file=main.zig
28pub fn main() !void {
29 try foo(-42);
30}
31fn foo(x: i64) !void {
32 return std.io.getStdOut().writer().print("{d}\n", .{x});
33}
34const std = @import("std");
35#expect_stdout="-42\n"
test/incremental/change_shift_op created+23
...@@ -0,0 +1,23 @@
1#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=initial version
5#file=main.zig
6pub fn main() !void {
7 try foo(0x1300);
8}
9fn foo(x: u16) !void {
10 try std.io.getStdOut().writer().print("0x{x}\n", .{x << 4});
11}
12const std = @import("std");
13#expect_stdout="0x3000\n"
14#update=change to right shift
15#file=main.zig
16pub fn main() !void {
17 try foo(0x1300);
18}
19fn foo(x: u16) !void {
20 try std.io.getStdOut().writer().print("0x{x}\n", .{x >> 4});
21}
22const std = @import("std");
23#expect_stdout="0x130\n"
test/incremental/change_struct_same_fields created+50
...@@ -0,0 +1,50 @@
1#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=initial version
5#file=main.zig
6const S = extern struct { x: u8, y: u8 };
7pub fn main() !void {
8 const val: S = .{ .x = 100, .y = 200 };
9 try foo(&val);
10}
11fn foo(val: *const S) !void {
12 try std.io.getStdOut().writer().print(
13 "{d} {d}\n",
14 .{ val.x, val.y },
15 );
16}
17const std = @import("std");
18#expect_stdout="100 200\n"
19
20#update=change struct layout
21#file=main.zig
22const S = extern struct { x: u32, y: u32 };
23pub fn main() !void {
24 const val: S = .{ .x = 100, .y = 200 };
25 try foo(&val);
26}
27fn foo(val: *const S) !void {
28 try std.io.getStdOut().writer().print(
29 "{d} {d}\n",
30 .{ val.x, val.y },
31 );
32}
33const std = @import("std");
34#expect_stdout="100 200\n"
35
36#update=change values
37#file=main.zig
38const S = extern struct { x: u32, y: u32 };
39pub fn main() !void {
40 const val: S = .{ .x = 1234, .y = 5678 };
41 try foo(&val);
42}
43fn foo(val: *const S) !void {
44 try std.io.getStdOut().writer().print(
45 "{d} {d}\n",
46 .{ val.x, val.y },
47 );
48}
49const std = @import("std");
50#expect_stdout="1234 5678\n"
test/incremental/compile_error_then_log created+21
...@@ -0,0 +1,21 @@
1#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=initial version with compile error
5#file=main.zig
6comptime {
7 @compileError("this is an error");
8}
9comptime {
10 @compileLog("this is a log");
11}
12#expect_error=ignored
13#update=remove the compile error
14#file=main.zig
15comptime {
16 //@compileError("this is an error");
17}
18comptime {
19 @compileLog("this is a log");
20}
21#expect_error=ignored
test/incremental/function_becomes_inline created+35
...@@ -0,0 +1,35 @@
1//#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=non-inline version
5#file=main.zig
6pub fn main() !void {
7 try foo();
8}
9fn foo() !void {
10 try std.io.getStdOut().writer().writeAll("Hello, World!\n");
11}
12const std = @import("std");
13#expect_stdout="Hello, World!\n"
14
15#update=make function inline
16#file=main.zig
17pub fn main() !void {
18 try foo();
19}
20inline fn foo() !void {
21 try std.io.getStdOut().writer().writeAll("Hello, World!\n");
22}
23const std = @import("std");
24#expect_stdout="Hello, World!\n"
25
26#update=change string
27#file=main.zig
28pub fn main() !void {
29 try foo();
30}
31inline fn foo() !void {
32 try std.io.getStdOut().writer().writeAll("Hello, `inline` World!\n");
33}
34const std = @import("std");
35#expect_stdout="Hello, `inline` World!\n"
test/incremental/recursive_function_becomes_non_recursive created+28
...@@ -0,0 +1,28 @@
1//#target=x86_64-linux-selfhosted
2#target=x86_64-linux-cbe
3#target=x86_64-windows-cbe
4#update=initial version
5#file=main.zig
6pub fn main() !void {
7 try foo(false);
8}
9fn foo(recurse: bool) !void {
10 const stdout = std.io.getStdOut().writer();
11 if (recurse) return foo(true);
12 try stdout.writeAll("non-recursive path\n");
13}
14const std = @import("std");
15#expect_stdout="non-recursive path\n"
16
17#update=eliminate recursion and change argument
18#file=main.zig
19pub fn main() !void {
20 try foo(true);
21}
22fn foo(recurse: bool) !void {
23 const stdout = std.io.getStdOut().writer();
24 if (recurse) return stdout.writeAll("x==1\n");
25 try stdout.writeAll("non-recursive path\n");
26}
27const std = @import("std");
28#expect_stdout="x==1\n"