diff options
Diffstat (limited to 'v_windows/v/old/vlib/v/tests/conversions_test.v')
-rw-r--r-- | v_windows/v/old/vlib/v/tests/conversions_test.v | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/v_windows/v/old/vlib/v/tests/conversions_test.v b/v_windows/v/old/vlib/v/tests/conversions_test.v new file mode 100644 index 0000000..9d281e2 --- /dev/null +++ b/v_windows/v/old/vlib/v/tests/conversions_test.v @@ -0,0 +1,16 @@ +fn test_conv_to_bool() { + v := 0 + mut b := v != 0 + assert !b + b = u64(&v) != 0 + assert b + // check true -> 1 + assert int(b) == 1 + + // branchless tests (can be important for manual optimization) + arr := [7, 8]! + e := arr[int(b)] + assert e == 8 + b = e < 0 + assert arr[int(b)] == 7 +} |