-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests for checking fixed array .sort() errors
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:3:6: error: expected 0 or 1 argument, but got 2 | ||
1 | fn main() { | ||
2 | mut arr := [3, 2, 1]! | ||
3 | arr.sort(a < b, a) | ||
| ~~~~~~~~~~~~~~ | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:4:6: error: `.sort()` can only use `<` or `>` comparison | ||
2 | mut arr := [3, 2, 1]! | ||
3 | arr.sort(a < b, a) | ||
4 | arr.sort(a == b) | ||
| ~~~~~~~~~~~~ | ||
5 | arr.sort(a > a) | ||
6 | arr.sort(c > d) | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:5:6: error: `.sort()` cannot use same argument | ||
3 | arr.sort(a < b, a) | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
| ~~~~~~~~~~~ | ||
6 | arr.sort(c > d) | ||
7 | } | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:6:11: error: can not access external variable `c` | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
6 | arr.sort(c > d) | ||
| ^ | ||
7 | } | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:6:6: error: `.sort()` can only use `a` or `b` as argument, e.g. `arr.sort(a < b)` | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
6 | arr.sort(c > d) | ||
| ~~~~~~~~~~~ | ||
7 | } | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:6:11: error: undefined ident: `c` | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
6 | arr.sort(c > d) | ||
| ^ | ||
7 | } | ||
vlib/v/checker/tests/fixed_array_sort_err.vv:6:15: error: undefined ident: `d` | ||
4 | arr.sort(a == b) | ||
5 | arr.sort(a > a) | ||
6 | arr.sort(c > d) | ||
| ^ | ||
7 | } |
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,7 @@ | ||
fn main() { | ||
mut arr := [3, 2, 1]! | ||
arr.sort(a < b, a) | ||
arr.sort(a == b) | ||
arr.sort(a > a) | ||
arr.sort(c > d) | ||
} |
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,12 @@ | ||
vlib/v/checker/tests/fn_return_fixed_array_sort_err.vv:6:14: error: the `sort()` method can be called only on mutable receivers, but `ret_array()` is a call expression | ||
4 | | ||
5 | fn main() { | ||
6 | ret_array().sort() | ||
| ~~~~~~ | ||
7 | } | ||
vlib/v/checker/tests/fn_return_fixed_array_sort_err.vv:6:2: error: cannot pass expression as `mut` | ||
4 | | ||
5 | fn main() { | ||
6 | ret_array().sort() | ||
| ~~~~~~~~~~~ | ||
7 | } |
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,7 @@ | ||
fn ret_array() [3]int { | ||
return [1, 3, 2]! | ||
} | ||
|
||
fn main() { | ||
ret_array().sort() | ||
} |