| 1 | enum EnumCommutative { |
| 2 | a |
| 3 | b |
| 4 | } |
| 5 | |
| 6 | fn short_eq_left(x EnumCommutative) bool { |
| 7 | return .a == x |
| 8 | } |
| 9 | |
| 10 | fn short_eq_right(x EnumCommutative) bool { |
| 11 | return x == .a |
| 12 | } |
| 13 | |
| 14 | fn short_ne_left(x EnumCommutative) bool { |
| 15 | return .a != x |
| 16 | } |
| 17 | |
| 18 | fn short_ne_right(x EnumCommutative) bool { |
| 19 | return x != .a |
| 20 | } |
| 21 | |
| 22 | fn test_short_enum_infix_equality_is_commutative() { |
| 23 | assert short_eq_left(.a) |
| 24 | assert short_eq_right(.a) |
| 25 | assert !short_eq_left(.b) |
| 26 | assert !short_eq_right(.b) |
| 27 | } |
| 28 | |
| 29 | fn test_short_enum_infix_inequality_is_commutative() { |
| 30 | assert !short_ne_left(.a) |
| 31 | assert !short_ne_right(.a) |
| 32 | assert short_ne_left(.b) |
| 33 | assert short_ne_right(.b) |
| 34 | } |
| 35 | |