zig/doc/langref/test_fibonacci_comptime_unreachable.zig

13 lines
272 B
Zig

const assert = @import("std").debug.assert;
fn fibonacci(index: i32) i32 {
if (index < 2) return index;
return fibonacci(index - 1) + fibonacci(index - 2);
}
test "fibonacci" {
try comptime assert(fibonacci(7) == 99999);
}
// test_error=reached unreachable