| ... | @@ -3714,6 +3714,14 @@ fn typeNameLength(comptime T: type) usize { | ... | @@ -3714,6 +3714,14 @@ fn typeNameLength(comptime T: type) usize { |
| 3714 | | 3714 | |
| 3715 | const assert = @import("std").debug.assert; | 3715 | const assert = @import("std").debug.assert; |
| 3716 | | 3716 | |
| | 3717 | test "if expression" { |
| | 3718 | // If expressions are used instead of a ternary expression. |
| | 3719 | const a: u32 = 5; |
| | 3720 | const b: u32 = 4; |
| | 3721 | const result = if (a != b) 47 else 3089; |
| | 3722 | assert(result == 47); |
| | 3723 | } |
| | 3724 | |
| 3717 | test "if boolean" { | 3725 | test "if boolean" { |
| 3718 | // If expressions test boolean conditions. | 3726 | // If expressions test boolean conditions. |
| 3719 | const a: u32 = 5; | 3727 | const a: u32 = 5; |
| ... | @@ -3725,10 +3733,6 @@ test "if boolean" { | ... | @@ -3725,10 +3733,6 @@ test "if boolean" { |
| 3725 | } else { | 3733 | } else { |
| 3726 | unreachable; | 3734 | unreachable; |
| 3727 | } | 3735 | } |
| 3728 | | | |
| 3729 | // If expressions are used instead of a ternary expression. | | |
| 3730 | const result = if (a != b) 47 else 3089; | | |
| 3731 | assert(result == 47); | | |
| 3732 | } | 3736 | } |
| 3733 | | 3737 | |
| 3734 | test "if optional" { | 3738 | test "if optional" { |