test:zig
This commit is contained in:
20
guide/language/if-expressions.zig
Normal file
20
guide/language/if-expressions.zig
Normal file
@@ -0,0 +1,20 @@
|
||||
// $ zig test if-expressions.zig
|
||||
const expect = @import("std").testing.expect;
|
||||
|
||||
test "if statement" {
|
||||
const a = true;
|
||||
var x: u16 = 0;
|
||||
if (a) {
|
||||
x += 1;
|
||||
} else {
|
||||
x += 2;
|
||||
}
|
||||
try expect(x == 1);
|
||||
}
|
||||
|
||||
test "if expression" {
|
||||
const a = true;
|
||||
var x: u16 = 0;
|
||||
x += if (a) 1 else 2;
|
||||
try expect(x == 1);
|
||||
}
|
||||
Reference in New Issue
Block a user