From 02fb393747bf3ed64a2137c021a27f0ca45216e9 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 17 May 2020 08:13:08 +0800 Subject: [PATCH] test: fix vrepl and cast test errors --- cmd/tools/vrepl.v | 4 +- vlib/v/checker/tests/in_mismatch_type.out | 88 +++++++++++------------ vlib/v/checker/tests/in_mismatch_type.vv | 7 +- vlib/v/checker/tests/match_expr_else.out | 7 ++ 4 files changed, 55 insertions(+), 51 deletions(-) diff --git a/cmd/tools/vrepl.v b/cmd/tools/vrepl.v index a18d380e5d..81906bd941 100644 --- a/cmd/tools/vrepl.v +++ b/cmd/tools/vrepl.v @@ -72,7 +72,7 @@ fn (r &Repl) current_source_code(should_add_temp_lines bool) string { } fn repl_help() { - println(util.full_v_version()) + println(util.full_v_version(true)) println(' help Displays this information. list Show the program so far. @@ -83,7 +83,7 @@ fn repl_help() { } 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') file := os.join_path(workdir, '.${vrepl_prefix}vrepl.v') diff --git a/vlib/v/checker/tests/in_mismatch_type.out b/vlib/v/checker/tests/in_mismatch_type.out index b8a269d8ed..c1b5dac613 100644 --- a/vlib/v/checker/tests/in_mismatch_type.out +++ b/vlib/v/checker/tests/in_mismatch_type.out @@ -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 - 11 | } - 12 | s := 'abcd' - 13 | if 1 in a_s { +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 + 8 | } + 9 | s := 'abcd' + 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 | } -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 - 14 | println('ok') +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('yeah') 15 | } - 16 | if 2 in m { + 16 | if 3 in s { | ~~ - 17 | println('yeah') + 17 | println('dope') 18 | } -vlib/v/checker/tests/in_mismatch_type.v:19:7: error: the data type on the left of `in` must be a string - 17 | println('yeah') +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('dope') 18 | } - 19 | if 3 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 { + 19 | if `a` in s { | ~~ - 23 | println("oh no :'(") - 24 | } -vlib/v/checker/tests/in_mismatch_type.v:25:7: error: `in` can only be used with an array/map/string - 23 | println("oh no :'(") - 24 | } - 25 | if 1 in 12 { + 20 | println("oh no :'(") + 21 | } +vlib/v/checker/tests/in_mismatch_type.v:22:7: error: `in` can only be used with an array/map/string + 20 | println("oh no :'(") + 21 | } + 22 | if 1 in 12 { | ~~ - 26 | println('right') - 27 | } -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 - 26 | println('right') - 27 | } - 28 | if Int(2) in m { + 23 | println('right') + 24 | } +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 + 23 | println('right') + 24 | } + 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 | } -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 - 29 | println('yeah') +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('sure') 30 | } - 31 | if Str2('3') in a_i { - | ~~ - 32 | println('sure') + 31 | if '2' in a_i { + | ~~ + 32 | println('all right') 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 | } diff --git a/vlib/v/checker/tests/in_mismatch_type.vv b/vlib/v/checker/tests/in_mismatch_type.vv index 0754815d00..dd882d771d 100644 --- a/vlib/v/checker/tests/in_mismatch_type.vv +++ b/vlib/v/checker/tests/in_mismatch_type.vv @@ -1,8 +1,5 @@ type Int = int -type Str2 = string -type Str3 = Str2 - fn main() { a_i := [1, 2, 3] a_s := ['1', '2', '3'] @@ -28,10 +25,10 @@ fn main() { if Int(2) in m { println('yeah') } - if Str2('3') in a_i { + if '3' in a_i { println('sure') } - if Str3('2') in a_i { + if '2' in a_i { println('all right') } } diff --git a/vlib/v/checker/tests/match_expr_else.out b/vlib/v/checker/tests/match_expr_else.out index 350584292a..f62e043fd8 100644 --- a/vlib/v/checker/tests/match_expr_else.out +++ b/vlib/v/checker/tests/match_expr_else.out @@ -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) 3 | fn main() { 4 | x := A('test')