-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: improve if expr with compound conditions (#22541)
- Loading branch information
Showing
5 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletions
9
...ns/ifs/if_expr_with_compound_conds_test.v → .../ifs/if_expr_with_compound_conds_1_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
type Foo = int | []int | ||
|
||
fn test_if_expr_with_compound_conds() { | ||
fn works() bool { | ||
a := Foo([3]) | ||
if a is []int && a[0] == 3 { | ||
println('works') | ||
return true | ||
} | ||
assert true | ||
return false | ||
} | ||
|
||
fn test_if_expr_with_compound_conds() { | ||
assert works() | ||
} |
15 changes: 15 additions & 0 deletions
15
vlib/v/tests/conditions/ifs/if_expr_with_compound_conds_2_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type Foo = int | []int | ||
|
||
fn works() bool { | ||
arr := [1, 2, 3] | ||
a := Foo(2) | ||
if a is int && arr[a] == 3 { | ||
println('works') | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
fn test_if_expr_with_compound_conds() { | ||
assert works() | ||
} |
14 changes: 14 additions & 0 deletions
14
vlib/v/tests/conditions/ifs/if_expr_with_compound_conds_3_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
type Foo = int | []int | ||
|
||
fn works() bool { | ||
a := Foo(2) | ||
if a is int && '${a}' == '2' { | ||
println('works') | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
fn test_if_expr_with_compound_conds() { | ||
assert works() | ||
} |
15 changes: 15 additions & 0 deletions
15
vlib/v/tests/conditions/ifs/if_expr_with_compound_conds_4_test.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type Foo = int | []int | ||
|
||
fn works() bool { | ||
arr := [1, 2, 3] | ||
a := Foo(2) | ||
if a is int && unsafe { arr[..a] == [1, 2] } { | ||
println('works') | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
fn test_if_expr_with_compound_conds() { | ||
assert works() | ||
} |