Flash 35 lines
// Flash-source eval suite — compile-time evaluation observed end to end:
// the emitted test blocks run under `zig build test-flash`, proving the
// values the evaluator folds are exactly the values downstream computes,
// that a generic instance denotes a usable type, and that a known condition
// selects the same arm downstream (the dead arm holds a division by zero
// that must never be analyzed).
use std
fn Box(comptime T type) type {
return T
}
const Byte = Box(u8)
const Size = 6 * 7
const Buf = [Size]u8
const Taken = if (true) 1 else 2 / 0
test "a folded constant is the value downstream computes" {
try std.testing.expectEqual(42, Size)
}
test "a folded constant sizes an array type" {
try std.testing.expectEqual(42, #sizeOf(Buf))
}
test "a generic instance denotes its argument type" {
const b Byte = 255
try std.testing.expectEqual(255, b)
}
test "a known condition selects its arm downstream too" {
try std.testing.expectEqual(1, Taken)
}