v/vlib/compiler/tests/enum_test.v

31 lines
515 B
V

enum Color {
red
blue
green
}
fn test_enum() {
assert Color.red == Color.red
assert Color.blue == Color.blue
assert Color.green == Color.green
assert Color.red == .red
assert Color.blue == .blue
assert Color.green == .green
assert Color.red != Color.blue
assert Color.red != Color.green
assert Color.blue != Color.green
mut color := Color.red
assert color == Color.red
color = .green
assert color == Color.green
}
fn test_in() {
color := Color.red
num := 3
assert color in [.red, .green]
}