mirror of
https://github.com/ziglang/zig.git
synced 2024-11-28 08:02:32 +00:00
f26dda2117
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
23 lines
489 B
Zig
23 lines
489 B
Zig
const Number = enum { One, Two, Three };
|
|
|
|
pub fn main() void {
|
|
var number1 = Number.One;
|
|
var number2: Number = .Two;
|
|
const number3: Number = @enumFromInt(2);
|
|
assert(number1 != number2);
|
|
assert(number2 != number3);
|
|
assert(@intFromEnum(number1) == 0);
|
|
assert(@intFromEnum(number2) == 1);
|
|
assert(@intFromEnum(number3) == 2);
|
|
var x: Number = .Two;
|
|
assert(number2 == x);
|
|
|
|
return;
|
|
}
|
|
fn assert(val: bool) void {
|
|
if (!val) unreachable;
|
|
}
|
|
|
|
// run
|
|
//
|