test: fix vrepl and cast test errors

pull/4924/head
yuyi 2020-05-17 08:13:08 +08:00 committed by GitHub
parent 81148fa2bd
commit 02fb393747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 51 deletions

View File

@ -72,7 +72,7 @@ fn (r &Repl) current_source_code(should_add_temp_lines bool) string {
} }
fn repl_help() { fn repl_help() {
println(util.full_v_version()) println(util.full_v_version(true))
println(' println('
help Displays this information. help Displays this information.
list Show the program so far. list Show the program so far.
@ -83,7 +83,7 @@ fn repl_help() {
} }
fn run_repl(workdir string, vrepl_prefix string) { fn run_repl(workdir string, vrepl_prefix string) {
println(util.full_v_version()) println(util.full_v_version(true))
println('Use Ctrl-C or `exit` to exit') println('Use Ctrl-C or `exit` to exit')
file := os.join_path(workdir, '.${vrepl_prefix}vrepl.v') file := os.join_path(workdir, '.${vrepl_prefix}vrepl.v')

View File

@ -1,56 +1,56 @@
vlib/v/checker/tests/in_mismatch_type.v:13:7: error: the data type on the left of `in` does not match the array item type vlib/v/checker/tests/in_mismatch_type.v:10:7: error: the data type on the left of `in` does not match the array item type
11 | } 8 | }
12 | s := 'abcd' 9 | s := 'abcd'
13 | if 1 in a_s { 10 | if 1 in a_s {
| ~~ | ~~
14 | println('ok') 11 | println('ok')
12 | }
vlib/v/checker/tests/in_mismatch_type.v:13:7: error: the data type on the left of `in` does not match the map key type
11 | println('ok')
12 | }
13 | if 2 in m {
| ~~
14 | println('yeah')
15 | } 15 | }
vlib/v/checker/tests/in_mismatch_type.v:16:7: error: the data type on the left of `in` does not match the map key type vlib/v/checker/tests/in_mismatch_type.v:16:7: error: the data type on the left of `in` must be a string
14 | println('ok') 14 | println('yeah')
15 | } 15 | }
16 | if 2 in m { 16 | if 3 in s {
| ~~ | ~~
17 | println('yeah') 17 | println('dope')
18 | } 18 | }
vlib/v/checker/tests/in_mismatch_type.v:19:7: error: the data type on the left of `in` must be a string vlib/v/checker/tests/in_mismatch_type.v:19:9: error: the data type on the left of `in` must be a string
17 | println('yeah') 17 | println('dope')
18 | } 18 | }
19 | if 3 in s { 19 | if `a` in s {
| ~~
20 | println('dope')
21 | }
vlib/v/checker/tests/in_mismatch_type.v:22:9: error: the data type on the left of `in` must be a string
20 | println('dope')
21 | }
22 | if `a` in s {
| ~~ | ~~
23 | println("oh no :'(") 20 | println("oh no :'(")
24 | } 21 | }
vlib/v/checker/tests/in_mismatch_type.v:25:7: error: `in` can only be used with an array/map/string vlib/v/checker/tests/in_mismatch_type.v:22:7: error: `in` can only be used with an array/map/string
23 | println("oh no :'(") 20 | println("oh no :'(")
24 | } 21 | }
25 | if 1 in 12 { 22 | if 1 in 12 {
| ~~ | ~~
26 | println('right') 23 | println('right')
27 | } 24 | }
vlib/v/checker/tests/in_mismatch_type.v:28:12: error: the data type on the left of `in` does not match the map key type vlib/v/checker/tests/in_mismatch_type.v:25:12: error: the data type on the left of `in` does not match the map key type
26 | println('right') 23 | println('right')
27 | } 24 | }
28 | if Int(2) in m { 25 | if Int(2) in m {
| ~~ | ~~
29 | println('yeah') 26 | println('yeah')
27 | }
vlib/v/checker/tests/in_mismatch_type.v:28:9: error: the data type on the left of `in` does not match the array item type
26 | println('yeah')
27 | }
28 | if '3' in a_i {
| ~~
29 | println('sure')
30 | } 30 | }
vlib/v/checker/tests/in_mismatch_type.v:31:15: error: the data type on the left of `in` does not match the array item type vlib/v/checker/tests/in_mismatch_type.v:31:9: error: the data type on the left of `in` does not match the array item type
29 | println('yeah') 29 | println('sure')
30 | } 30 | }
31 | if Str2('3') in a_i { 31 | if '2' in a_i {
| ~~ | ~~
32 | println('sure') 32 | println('all right')
33 | } 33 | }
vlib/v/checker/tests/in_mismatch_type.v:34:15: error: the data type on the left of `in` does not match the array item type
32 | println('sure')
33 | }
34 | if Str3('2') in a_i {
| ~~
35 | println('all right')
36 | }

View File

@ -1,8 +1,5 @@
type Int = int type Int = int
type Str2 = string
type Str3 = Str2
fn main() { fn main() {
a_i := [1, 2, 3] a_i := [1, 2, 3]
a_s := ['1', '2', '3'] a_s := ['1', '2', '3']
@ -28,10 +25,10 @@ fn main() {
if Int(2) in m { if Int(2) in m {
println('yeah') println('yeah')
} }
if Str2('3') in a_i { if '3' in a_i {
println('sure') println('sure')
} }
if Str3('2') in a_i { if '2' in a_i {
println('all right') println('all right')
} }
} }

View File

@ -1,3 +1,10 @@
vlib/v/checker/tests/match_expr_else.v:4:9: error: cannot cast a string
2 |
3 | fn main() {
4 | x := A('test')
| ~~~~~~
5 | _ = match x {
6 | int {
vlib/v/checker/tests/match_expr_else.v:5:6: error: match must be exhaustive (add match branches for: `f64` or `else {}` at the end) vlib/v/checker/tests/match_expr_else.v:5:6: error: match must be exhaustive (add match branches for: `f64` or `else {}` at the end)
3 | fn main() { 3 | fn main() {
4 | x := A('test') 4 | x := A('test')