From a27f2ddcc3569f0ee71174da4e332ea703954f84 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+tobealive@users.noreply.github.com> Date: Sun, 2 Jul 2023 08:38:33 +0200 Subject: [PATCH] term.ui, vweb, v: update deprecated functions (#18726) --- examples/term.ui/cursor_chaser.v | 2 +- examples/term.ui/event_viewer.v | 2 +- examples/term.ui/pong.v | 2 +- examples/term.ui/rectangles.v | 2 +- examples/term.ui/term_drawing.v | 2 +- examples/term.ui/text_editor.v | 2 +- examples/term.ui/vyper.v | 2 +- vlib/term/ui/README.md | 2 +- vlib/term/ui/input_nix.c.v | 2 +- vlib/term/ui/input_windows.c.v | 2 +- vlib/v/eval/interpret_test.v | 6 +++--- vlib/v/gen/js/program_test.v | 2 +- .../generics_with_nested_external_generics_fn_test.v | 4 ++-- vlib/v/tests/match_aliases_test.v | 2 +- vlib/v/tests/match_expr_with_assign_sumtype_test.v | 12 ++++++------ vlib/v/tests/shared_array_sort_test.v | 10 +++++----- vlib/v/vmod/parser_test.v | 4 ++-- vlib/vweb/csrf/csrf_test.v | 4 ++-- 18 files changed, 32 insertions(+), 32 deletions(-) diff --git a/examples/term.ui/cursor_chaser.v b/examples/term.ui/cursor_chaser.v index 80eb16abaf..6cf4b9ecba 100644 --- a/examples/term.ui/cursor_chaser.v +++ b/examples/term.ui/cursor_chaser.v @@ -92,5 +92,5 @@ fn main() { event_fn: event hide_cursor: true ) - app.tui.run()? + app.tui.run()! } diff --git a/examples/term.ui/event_viewer.v b/examples/term.ui/event_viewer.v index 16e604e568..8b81967dcd 100644 --- a/examples/term.ui/event_viewer.v +++ b/examples/term.ui/event_viewer.v @@ -42,5 +42,5 @@ fn main() { use_alternate_buffer: false ) println('V term.ui event viewer (press `esc` to exit)\n\n') - app.tui.run()? + app.tui.run()! } diff --git a/examples/term.ui/pong.v b/examples/term.ui/pong.v index 86e84d4d70..62861e8270 100644 --- a/examples/term.ui/pong.v +++ b/examples/term.ui/pong.v @@ -493,5 +493,5 @@ fn main() { hide_cursor: true frame_rate: 60 ) - app.tui.run()? + app.tui.run()! } diff --git a/examples/term.ui/rectangles.v b/examples/term.ui/rectangles.v index 541ca91831..ed6213a8b0 100644 --- a/examples/term.ui/rectangles.v +++ b/examples/term.ui/rectangles.v @@ -91,5 +91,5 @@ fn main() { hide_cursor: true frame_rate: 60 ) - app.tui.run()? + app.tui.run()! } diff --git a/examples/term.ui/term_drawing.v b/examples/term.ui/term_drawing.v index afd6773b0e..f5d7d9f288 100644 --- a/examples/term.ui/term_drawing.v +++ b/examples/term.ui/term_drawing.v @@ -125,7 +125,7 @@ fn main() { app.mouse_pos.x = 40 app.mouse_pos.y = 15 app.ui.clear() - app.ui.run()? + app.ui.run()! } fn frame(mut app App) { diff --git a/examples/term.ui/text_editor.v b/examples/term.ui/text_editor.v index e19aafb9c1..89c1985817 100644 --- a/examples/term.ui/text_editor.v +++ b/examples/term.ui/text_editor.v @@ -646,5 +646,5 @@ fn main() { event_fn: event capture_events: true ) - a.tui.run()? + a.tui.run()! } diff --git a/examples/term.ui/vyper.v b/examples/term.ui/vyper.v index cba2e935a7..d4e3aa2e65 100644 --- a/examples/term.ui/vyper.v +++ b/examples/term.ui/vyper.v @@ -468,5 +468,5 @@ fn main() { hide_cursor: true frame_rate: 10 ) - app.termui.run()? + app.termui.run()! } diff --git a/vlib/term/ui/README.md b/vlib/term/ui/README.md index 945907048f..b72dfd6ab1 100644 --- a/vlib/term/ui/README.md +++ b/vlib/term/ui/README.md @@ -39,7 +39,7 @@ fn main() { frame_fn: frame hide_cursor: true ) - app.tui.run()? + app.tui.run()! } ``` diff --git a/vlib/term/ui/input_nix.c.v b/vlib/term/ui/input_nix.c.v index 8e8e84e6df..7e21631ba9 100644 --- a/vlib/term/ui/input_nix.c.v +++ b/vlib/term/ui/input_nix.c.v @@ -44,7 +44,7 @@ fn load_title() { } // run sets up and starts the terminal. -pub fn (mut ctx Context) run() ? { +pub fn (mut ctx Context) run() ! { if ctx.cfg.use_x11 { ctx.fail('error: x11 backend not implemented yet') exit(1) diff --git a/vlib/term/ui/input_windows.c.v b/vlib/term/ui/input_windows.c.v index d8ba7f408e..0e09801d82 100644 --- a/vlib/term/ui/input_windows.c.v +++ b/vlib/term/ui/input_windows.c.v @@ -101,7 +101,7 @@ pub fn init(cfg Config) &Context { } // run starts the windows console or restarts if it was paused. -pub fn (mut ctx Context) run() ? { +pub fn (mut ctx Context) run() ! { frame_time := 1_000_000 / ctx.cfg.frame_rate mut init_called := false mut sw := time.new_stopwatch(auto_start: false) diff --git a/vlib/v/eval/interpret_test.v b/vlib/v/eval/interpret_test.v index ad1e1ec7bd..df8b877ca0 100644 --- a/vlib/v/eval/interpret_test.v +++ b/vlib/v/eval/interpret_test.v @@ -8,9 +8,9 @@ fn test_interpret() { mut bench := benchmark.new_benchmark() vexe := os.getenv('VEXE') vroot := os.dir(vexe) - os.chdir(vroot)? + os.chdir(vroot)! dir := os.join_path(vroot, 'vlib/v/eval/testdata') - files := os.ls(dir)? + files := os.ls(dir)! // tests := files.filter(it.ends_with('.vv')) if tests.len == 0 { @@ -35,7 +35,7 @@ fn test_interpret() { eprintln(res.output) continue } - mut expected := os.read_file('${dir}/${test_name_without_postfix}.out')? + mut expected := os.read_file('${dir}/${test_name_without_postfix}.out')! expected = normalise_line_endings(expected) mut found := normalise_line_endings(res.output) found = found.trim_space() diff --git a/vlib/v/gen/js/program_test.v b/vlib/v/gen/js/program_test.v index 9660d7d614..7c8125b0f6 100644 --- a/vlib/v/gen/js/program_test.v +++ b/vlib/v/gen/js/program_test.v @@ -40,7 +40,7 @@ fn test_running_programs_compiled_with_the_js_backend() { os.chdir(vroot) or {} test_dir := 'vlib/v/gen/js/tests/testdata' main_files := get_main_files_in_dir(test_dir) - fails := check_path(test_dir, main_files)? + fails := check_path(test_dir, main_files)! assert fails == 0 } diff --git a/vlib/v/tests/generics_with_nested_external_generics_fn_test.v b/vlib/v/tests/generics_with_nested_external_generics_fn_test.v index 0db726c4d6..557d343dbc 100644 --- a/vlib/v/tests/generics_with_nested_external_generics_fn_test.v +++ b/vlib/v/tests/generics_with_nested_external_generics_fn_test.v @@ -1,10 +1,10 @@ import rand -pub fn sample[T](arr []T, k int) ?[]T { +pub fn sample[T](arr []T, k int) ![]T { mut result := arr.clone() rand.seed([u32(1), 2]) // set seed to produce same results in order - rand.shuffle[T](mut result)? + rand.shuffle[T](mut result)! return result[0..k] } diff --git a/vlib/v/tests/match_aliases_test.v b/vlib/v/tests/match_aliases_test.v index 88b4a39590..933692fb03 100644 --- a/vlib/v/tests/match_aliases_test.v +++ b/vlib/v/tests/match_aliases_test.v @@ -1,5 +1,5 @@ fn test_match_aliases() { - a := byte(97) + a := u8(97) ret := match a { `0`...`9`, `a`...`f` { 'OK' } else { 'NOT OK' } diff --git a/vlib/v/tests/match_expr_with_assign_sumtype_test.v b/vlib/v/tests/match_expr_with_assign_sumtype_test.v index 09549213fe..05d49547f2 100644 --- a/vlib/v/tests/match_expr_with_assign_sumtype_test.v +++ b/vlib/v/tests/match_expr_with_assign_sumtype_test.v @@ -23,7 +23,7 @@ enum State { parse_operator } -fn tokenise(args string) ?[]Value { +fn tokenise(args string) ![]Value { mut rv := []Value{} mut state := State.expecting @@ -34,7 +34,7 @@ fn tokenise(args string) ?[]Value { match i { `0`...`9` { state = .parse_num - cur_value = int(i.str().parse_uint(10, 8)?) + cur_value = int(i.str().parse_uint(10, 8)!) } `+`, `-`, `*`, `/` { state = .parse_operator @@ -67,7 +67,7 @@ fn tokenise(args string) ?[]Value { .parse_num { match i { `0`...`9` { - cur_value = 10 + int(i.str().parse_uint(10, 8)?) + cur_value = 10 + int(i.str().parse_uint(10, 8)!) } `+`, `-`, `*`, `/` { state = .parse_operator @@ -94,7 +94,7 @@ fn tokenise(args string) ?[]Value { `0`...`9` { state = .parse_num rv << cur_value - cur_value = int(i.str().parse_uint(10, 8)?) + cur_value = int(i.str().parse_uint(10, 8)!) } ` ` { state = .expecting @@ -111,11 +111,11 @@ fn tokenise(args string) ?[]Value { return rv } -fn parse_args(argv []string) ?Expression { +fn parse_args(argv []string) !Expression { rv := Expression{ val: 1 } - tokens := tokenise(argv.join(' '))? + tokens := tokenise(argv.join(' '))! println(tokens) assert '${tokens}' == '[Value(1), Value(add), Value(subtract), Value(multiply), Value(divide)]' diff --git a/vlib/v/tests/shared_array_sort_test.v b/vlib/v/tests/shared_array_sort_test.v index 1c4dac3e3c..8bf452aaa0 100644 --- a/vlib/v/tests/shared_array_sort_test.v +++ b/vlib/v/tests/shared_array_sort_test.v @@ -16,11 +16,11 @@ fn test_sorting_shared_arrays() { alarms := Alarms{} utc := time.utc() alarms.add(utc) - alarms.add(time.parse_iso8601('2022-03-01')?) - alarms.add(time.parse_iso8601('3001-03-01')?) - alarms.add(time.parse_iso8601('2002-03-01')?) - alarms.add(time.parse_iso8601('3002-03-01')?) - alarms.add(time.parse_iso8601('2021-03-01')?) + alarms.add(time.parse_iso8601('2022-03-01')!) + alarms.add(time.parse_iso8601('3001-03-01')!) + alarms.add(time.parse_iso8601('2002-03-01')!) + alarms.add(time.parse_iso8601('3002-03-01')!) + alarms.add(time.parse_iso8601('2021-03-01')!) println(alarms) lock alarms.times { assert alarms.times.len == 6 diff --git a/vlib/v/vmod/parser_test.v b/vlib/v/vmod/parser_test.v index 09582f8825..cae77387ce 100644 --- a/vlib/v/vmod/parser_test.v +++ b/vlib/v/vmod/parser_test.v @@ -15,7 +15,7 @@ fn test_ok() { }" for s in [ok_source, ok_source.replace(apos, quote), ok_source.replace('\n', '\r\n'), ok_source.replace('\n', '\r\n '), ok_source.replace('\n', '\n ')] { - content := vmod.decode(s)? + content := vmod.decode(s)! assert content.name == 'V' assert content.description == 'The V programming language.' assert content.version == '0.7.7' @@ -24,7 +24,7 @@ fn test_ok() { assert content.dependencies == [] assert content.unknown == {} } - e := vmod.decode('Module{}')? + e := vmod.decode('Module{}')! assert e.name == '' assert e.description == '' assert e.version == '' diff --git a/vlib/vweb/csrf/csrf_test.v b/vlib/vweb/csrf/csrf_test.v index c9471bfc4b..b1de7cb241 100644 --- a/vlib/vweb/csrf/csrf_test.v +++ b/vlib/vweb/csrf/csrf_test.v @@ -268,7 +268,7 @@ fn test_token_with_app() { res := http.get('http://${localserver}/') or { panic(err) } mut doc := html.parse(res.body) - inputs := doc.get_tag_by_attribute_value('type', 'hidden') + inputs := doc.get_tags_by_attribute_value('type', 'hidden') assert inputs.len == 1 assert csrf_config.token_name == inputs[0].attributes['name'] } @@ -277,7 +277,7 @@ fn test_token_with_middleware() { res := http.get('http://${localserver}/middleware_index') or { panic(err) } mut doc := html.parse(res.body) - inputs := doc.get_tag_by_attribute_value('type', 'hidden') + inputs := doc.get_tags_by_attribute_value('type', 'hidden') assert inputs.len == 1 assert csrf_config.token_name == inputs[0].attributes['name'] }