blob: 4657b2cfda92692ed2909a261acce9851ff78074 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
const std = @import("std");
const builtin = @import("builtin");
var result: []const u8 = "wrong";
test "pass string literal byvalue to a generic var param" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
start();
blowUpStack(10);
try std.testing.expect(std.mem.eql(u8, result, "string literal"));
}
fn start() void {
foo("string literal");
}
fn foo(x: anytype) void {
bar(x);
}
fn bar(x: anytype) void {
result = x;
}
fn blowUpStack(x: u32) void {
if (x == 0) return;
blowUpStack(x - 1);
}
|