From e523bb1a19c08288101b13b309d3c7217b5bfb66 Mon Sep 17 00:00:00 2001 From: shove70 Date: Thu, 10 Aug 2023 19:06:04 +0800 Subject: [PATCH] tests: cleanup test cases --- vlib/builtin/int_test.v | 6 --- vlib/encoding/base58/base58_usage_test.v | 4 +- vlib/net/html/README.md | 6 ++- vlib/net/html/html_test.v | 6 +-- vlib/net/html/tag_test.v | 4 +- vlib/net/http/header_test.v | 4 +- vlib/net/websocket/events.v | 16 ++++---- vlib/strconv/format_test.v | 22 +++++----- vlib/v/tests/anon_sum_type_test.v | 41 ------------------- vlib/v/tests/array_init_test.v | 2 +- ...gn_option_of_multi_return_with_heap_test.v | 2 +- vlib/v/tests/attribute_test.v | 2 +- vlib/v/tests/autogen_free_test.v | 4 +- vlib/v/tests/cast_to_anon_sumtype_test.v | 5 --- vlib/v/tests/comptime_map_it_test.v | 6 +-- vlib/v/tests/const_test.v | 4 +- vlib/v/tests/defer/defer_return_test.v | 2 +- vlib/v/tests/empty_struct_compare_test.v | 2 +- vlib/v/tests/enum_test.v | 2 +- vlib/v/tests/fn_multiple_returns_test.v | 6 +-- vlib/v/tests/fn_ptr_call_test.v | 4 +- vlib/v/tests/fn_shared_return_test.v | 6 +-- vlib/v/tests/for_in_mut_iterator_val_test.v | 8 ++-- vlib/v/tests/for_in_mut_struct_val_test.v | 2 +- .../generic_empty_interface_to_struct_test.v | 2 +- vlib/v/tests/generic_struct_recursive_test.v | 2 +- ...ric_sumtype_init_in_generic_fn_call_test.v | 2 +- .../generics_call_with_reference_arg_test.v | 2 +- ...cs_with_nested_external_generics_fn_test.v | 2 +- vlib/v/tests/heap_reference_test.v | 4 +- vlib/v/tests/if_guard_test.v | 2 +- vlib/v/tests/map_get_assign_blank_test.v | 4 +- vlib/v/tests/match_error_to_none_test.v | 24 +++++------ .../match_expr_with_assign_sumtype_test.v | 4 +- .../tests/match_sumtype_var_with_none_test.v | 13 ------ vlib/v/tests/modules/sub/foo.v | 5 +++ vlib/v/tests/nested_option_call_test.v | 6 +-- vlib/v/tests/option_2_test.v | 2 +- vlib/v/tests/option_default_values_test.v | 8 ++-- .../tests/option_expr_with_array_value_test.v | 2 +- .../option_if_assign_and_fallthrough_test.v | 2 +- vlib/v/tests/option_in_loop_test.v | 2 +- .../option_struct_init_with_ref_opt_test.v | 8 ++-- vlib/v/tests/option_test.v | 26 ++++++------ vlib/v/tests/option_void_test.v | 6 +-- vlib/v/tests/or_expr_with_multi_stmts_test.v | 2 +- .../or_expr_with_nested_match_expr_test.v | 2 +- vlib/v/tests/shared_fn_return_test.v | 6 +-- vlib/v/tests/string_array_of_ref_type_test.v | 2 +- vlib/v/tests/string_option_none_test.v | 22 ---------- vlib/v/tests/struct_selector_or_block_test.v | 4 +- vlib/v/tests/struct_test.v | 6 +-- vlib/v/tests/sumtype_with_none_test.v | 16 -------- vlib/v/tests/typeof_test.v | 36 +++++++--------- vlib/v/tests/vsh_envbang_test.v | 6 +-- 55 files changed, 145 insertions(+), 251 deletions(-) delete mode 100644 vlib/v/tests/anon_sum_type_test.v delete mode 100644 vlib/v/tests/cast_to_anon_sumtype_test.v delete mode 100644 vlib/v/tests/match_sumtype_var_with_none_test.v delete mode 100644 vlib/v/tests/string_option_none_test.v delete mode 100644 vlib/v/tests/sumtype_with_none_test.v diff --git a/vlib/builtin/int_test.v b/vlib/builtin/int_test.v index dac0cc1cbe..30e44ac7d1 100644 --- a/vlib/builtin/int_test.v +++ b/vlib/builtin/int_test.v @@ -248,9 +248,3 @@ fn test_repeat() { assert b.repeat(1) == b.ascii_str() assert b.repeat(0) == '' } - -fn test_byte_vs_u8() { - bb := byte(1) - uu := u8(1) - assert bb == uu -} diff --git a/vlib/encoding/base58/base58_usage_test.v b/vlib/encoding/base58/base58_usage_test.v index 3df0a8c811..d7765967aa 100644 --- a/vlib/encoding/base58/base58_usage_test.v +++ b/vlib/encoding/base58/base58_usage_test.v @@ -32,8 +32,8 @@ fn test_decode() { 'USm3fpXnKG5EUBx2ndxBDMPVciP5hGey2Jh4NDv6gmeo1LkMeiKrLJUUBk6Z': 'The quick brown fox jumps over the lazy dog.' '11StV1DL6CwTryKyV': '\x00\x00hello world' '2NEpo7TZRRrLZSi2U': 'Hello World!' - '14cxpo3MBCYYWCgF74SWTdcmxipnGUsPw3': hex.decode('0027b5891b01da2db74cde1689a97a2acbe23d5fb1c0205bf6')?.bytestr() - '3vQB7B6MrGQZaxCuFg4oh': hex.decode('68656c6c6f20776f726c64bc62d4b8')?.bytestr() + '14cxpo3MBCYYWCgF74SWTdcmxipnGUsPw3': hex.decode('0027b5891b01da2db74cde1689a97a2acbe23d5fb1c0205bf6')!.bytestr() + '3vQB7B6MrGQZaxCuFg4oh': hex.decode('68656c6c6f20776f726c64bc62d4b8')!.bytestr() } { input := base58.decode(output)! println('> output: `${output}` | decoded input: `${input}` | bytes: ${input.bytes().hex()}') diff --git a/vlib/net/html/README.md b/vlib/net/html/README.md index b963cd25d9..a4f503f443 100644 --- a/vlib/net/html/README.md +++ b/vlib/net/html/README.md @@ -1,16 +1,18 @@ net/html is an **HTML Parser** written in pure V. ## Usage -```v oksyntax + +```v import net.html fn main() { doc := html.parse('

Hello world!

') - tag := doc.get_tag('h1')[0] //

Hello world!

+ tag := doc.get_tags(name: 'h1')[0] //

Hello world!

println(tag.name) // h1 println(tag.content) // Hello world! println(tag.attributes) // {'class':'title'} println(tag.str()) //

Hello world!

} ``` + More examples found on [`parser_test.v`](parser_test.v) and [`html_test.v`](html_test.v) diff --git a/vlib/net/html/html_test.v b/vlib/net/html/html_test.v index 2a518a2ddb..2f30fe31d5 100644 --- a/vlib/net/html/html_test.v +++ b/vlib/net/html/html_test.v @@ -2,7 +2,7 @@ module html fn test_parse() { doc := parse('

Hello world!

') - tags := doc.get_tag('h1') + tags := doc.get_tags(name: 'h1') assert tags.len == 1 h1_tag := tags[0] //

Hello world!

assert h1_tag.name == 'h1' @@ -16,13 +16,13 @@ fn test_parse() { fn test_parse_inline_tags() { doc := parse('

before in between after

') - tags := doc.get_tag('span') + tags := doc.get_tags(name: 'span') assert tags.len == 1 span_tag := tags[0] assert span_tag.str() == 'in between' - p_tags := doc.get_tag('p') + p_tags := doc.get_tags(name: 'p') assert p_tags.len == 1 p_tag := p_tags[0] diff --git a/vlib/net/html/tag_test.v b/vlib/net/html/tag_test.v index 082dee986c..fcf3c02227 100644 --- a/vlib/net/html/tag_test.v +++ b/vlib/net/html/tag_test.v @@ -32,7 +32,7 @@ const ( fn test_search_tag_by_type() { mut dom := parse(html.html) - tag := dom.get_tags(GetTagsOptions{'body'})[0] + tag := dom.get_tags(name: 'body')[0] assert tag.get_tag('div')?.attributes['id'] == '1st' assert tag.get_tag_by_attribute('href')?.content == 'V' // TODO: update after improved parsing to not add trailing white space to attribute values @@ -65,7 +65,7 @@ fn generate_temp_html_with_classes() string { fn test_search_by_class() { mut dom := parse(generate_temp_html_with_classes()) - tag := dom.get_tags(GetTagsOptions{'body'})[0] + tag := dom.get_tags(name: 'body')[0] single_class_tags := tag.get_tags_by_class_name('single') common_class_tags := tag.get_tags_by_class_name('common') complex_class_tags := tag.get_tags_by_class_name('complex-0', 'complex-1', 'complex-2') diff --git a/vlib/net/http/header_test.v b/vlib/net/http/header_test.v index f50a94ef89..5f508a266b 100644 --- a/vlib/net/http/header_test.v +++ b/vlib/net/http/header_test.v @@ -346,7 +346,7 @@ fn parse_headers_test(s string, expected map[string]string) ? { assert parse_headers(s)? == new_custom_header_from_map(expected)? } -fn test_parse_headers() ? { +fn test_parse_headers() ! { parse_headers_test('foo: bar', { 'foo': 'bar' })? @@ -371,7 +371,7 @@ fn test_parse_headers() ? { 'foo': 'bar' 'bar': 'baz' })? - assert parse_headers('foo: bar\r\nfoo:baz')?.custom_values('foo') == ['bar', 'baz'] + assert parse_headers('foo: bar\r\nfoo:baz')!.custom_values('foo') == ['bar', 'baz'] if x := parse_headers(' oops: oh no') { return error('should have errored, but got ${x}') diff --git a/vlib/net/websocket/events.v b/vlib/net/websocket/events.v index 688298dc67..53583baa72 100644 --- a/vlib/net/websocket/events.v +++ b/vlib/net/websocket/events.v @@ -2,32 +2,32 @@ module websocket // MessageEventHandler represents a callback on a new message struct MessageEventHandler { - handler SocketMessageFn // callback function - handler2 SocketMessageFn2 // callback function with reference + handler SocketMessageFn = unsafe { nil } // callback function + handler2 SocketMessageFn2 = unsafe { nil } // callback function with reference is_ref bool // true if has a reference object ref voidptr // referenced object } // ErrorEventHandler represents a callback on error struct ErrorEventHandler { - handler SocketErrorFn // callback function - handler2 SocketErrorFn2 // callback function with reference + handler SocketErrorFn = unsafe { nil } // callback function + handler2 SocketErrorFn2 = unsafe { nil } // callback function with reference is_ref bool // true if has a reference object ref voidptr // referenced object } // OpenEventHandler represents a callback when connection is opened struct OpenEventHandler { - handler SocketOpenFn // callback function - handler2 SocketOpenFn2 // callback function with reference + handler SocketOpenFn = unsafe { nil } // callback function + handler2 SocketOpenFn2 = unsafe { nil } // callback function with reference is_ref bool // true if has a reference object ref voidptr // referenced object } // CloseEventHandler represents a callback on a closing event struct CloseEventHandler { - handler SocketCloseFn // callback function - handler2 SocketCloseFn2 // callback function with reference + handler SocketCloseFn = unsafe { nil } // callback function + handler2 SocketCloseFn2 = unsafe { nil } // callback function with reference is_ref bool // true if has a reference object ref voidptr // referenced object } diff --git a/vlib/strconv/format_test.v b/vlib/strconv/format_test.v index 16af688b53..9a815981b7 100644 --- a/vlib/strconv/format_test.v +++ b/vlib/strconv/format_test.v @@ -14,7 +14,7 @@ fn test_format() { f3 := 1234.300e-6 sc0 := 'ciao: [%-08u] %d %hhd [%8s] [%08X] [%-20.4f] [%-20.4f] [%c]' - temp_s = strconv.v_sprintf(sc0, a0, b0, c0, s0, b0, f0, f1, ch0) + temp_s = unsafe { strconv.v_sprintf(sc0, a0, b0, c0, s0, b0, f0, f1, ch0) } tmp_str = 'ciao: [10 ] 200 12 [ ciAo] [000000C8] [0.3123 ] [200000.0000 ] [B]' // C.printf(sc0.str,a0 ,b0 ,c0 ,s0.str ,b0 ,f0, f1, ch0) // println("\n$temp_s") @@ -25,7 +25,7 @@ fn test_format() { c := 14 d := i64(15) sc1 := '==>%hhd %hd %d %ld' - temp_s = strconv.v_sprintf(sc1, a, b, c, d) + temp_s = unsafe { strconv.v_sprintf(sc1, a, b, c, d) } tmp_str = '==>12 13 14 15' // C.printf(sc1.str, a ,b ,c, d) // println("\n$temp_s") @@ -36,28 +36,28 @@ fn test_format() { c1 := u32(0xffff_ffff) d1 := u64(-1) sc2 := '%hhu %hu %u %lu' - temp_s = strconv.v_sprintf(sc2, a1, b1, c1, d1) + temp_s = unsafe { strconv.v_sprintf(sc2, a1, b1, c1, d1) } tmp_str = '255 65535 4294967295 18446744073709551615' // C.printf(sc2.str, a1 ,b1 ,c1, d1) // println("\n$temp_s") assert tmp_str == temp_s sc3 := '%hhx %hx %x %lx' - temp_s = strconv.v_sprintf(sc3, a1, b1, c1, d1) + temp_s = unsafe { strconv.v_sprintf(sc3, a1, b1, c1, d1) } tmp_str = 'ff ffff ffffffff ffffffffffffffff' // C.printf(sc3.str, a1 ,b1 ,c1, d1) // println("\n$temp_s") assert tmp_str == temp_s sc4 := '[%-20.3e] [%20.3e] [%-020.3e] [%-020.3E] [%-020.3e] [%-020.3e]' - temp_s = strconv.v_sprintf(sc4, f0, f1, f1, f1, f2, f3) + temp_s = unsafe { strconv.v_sprintf(sc4, f0, f1, f1, f1, f2, f3) } tmp_str = '[3.123e-01 ] [ 2.000e+05] [2.000e+05 ] [2.000E+05 ] [-1.234e+09 ] [1.234e-03 ]' // C.printf(sc4.str, f0, f1, f1, f1, f2, f3) // println("\n$temp_s") assert tmp_str == temp_s sc5 := '[%.3f] [%0.3f] [%0.3F] [%0.3f] [%0.3F]' - temp_s = strconv.v_sprintf(sc5, f0, f1, f1, f2, f3) + temp_s = unsafe { strconv.v_sprintf(sc5, f0, f1, f1, f2, f3) } tmp_str = '[0.312] [200000.000] [200000.000] [-1234300000.000] [0.001]' // C.printf(sc5.str, f0, f1, f1, f2, f3, f3) // println("\n$temp_s") @@ -65,7 +65,7 @@ fn test_format() { ml := 3 sc6 := '%.*s [%05hhX]' - temp_s = strconv.v_sprintf(sc6, ml, s0, a) + temp_s = unsafe { strconv.v_sprintf(sc6, ml, s0, a) } tmp_str = 'ciA [0000C]' // C.printf(sc6.str, ml, s0.str, a) // println("\n$temp_s") @@ -73,7 +73,7 @@ fn test_format() { a2 := 125 sc7 := '[%9x] [%9X] [%-9x] [%-9X] [%09x] [%09X]' - temp_s = strconv.v_sprintf(sc7, a2, a2, a2, a2, a2, a2) + temp_s = unsafe { strconv.v_sprintf(sc7, a2, a2, a2, a2, a2, a2) } tmp_str = '[ 7d] [ 7D] [7d ] [7D ] [00000007d] [00000007D]' // C.printf(sc7.str, a2, a2, a2, a2, a2, a2) // println("\n$temp_s") @@ -99,7 +99,7 @@ fn test_format() { mut cnt := 0 sc8 := '[%20g][%20G]|' for x < 12 { - temp_s = strconv.v_sprintf(sc8, ft, ft) + temp_s = unsafe { strconv.v_sprintf(sc8, ft, ft) } // C.printf(sc8.str, ft, ft) // println("\n$temp_s") assert temp_s == g_test[cnt] @@ -111,11 +111,11 @@ fn test_format() { fn test_sprintf_does_not_double_free_on_g() { x := 3.141516 - assert strconv.v_sprintf('aaa %G', x) == 'aaa 3.141516' + assert unsafe { strconv.v_sprintf('aaa %G', x) } == 'aaa 3.141516' } fn test_sprintf_with_escape() { n := 69 - s := strconv.v_sprintf('%d is 100%% awesome', n) + s := unsafe { strconv.v_sprintf('%d is 100%% awesome', n) } assert s == '69 is 100% awesome' } diff --git a/vlib/v/tests/anon_sum_type_test.v b/vlib/v/tests/anon_sum_type_test.v deleted file mode 100644 index 2e080a0d25..0000000000 --- a/vlib/v/tests/anon_sum_type_test.v +++ /dev/null @@ -1,41 +0,0 @@ -fn returns_sumtype() int|string { - return 1 -} - -fn returns_sumtype_reverse() int|string { - return 1 -} - -fn test_stringification() { - x := returns_sumtype() - y := returns_sumtype_reverse() - assert '${x}' == '${y}' -} - -struct Milk { - egg int|string -} - -fn test_struct_with_inline_sumtype() { - m := Milk{ - egg: 1 - } - assert m.egg is int -} - -interface IMilk { - egg int|string -} - -fn receive_imilk(milk IMilk) {} - -fn test_interface_with_inline_sumtype() { - m := Milk{ - egg: 1 - } - receive_imilk(m) -} - -fn returns_sumtype_in_multireturn() (int|string, string) { - return 1, '' -} diff --git a/vlib/v/tests/array_init_test.v b/vlib/v/tests/array_init_test.v index 2da51c8d60..a8337a49a0 100644 --- a/vlib/v/tests/array_init_test.v +++ b/vlib/v/tests/array_init_test.v @@ -247,7 +247,7 @@ fn test_array_init_inferred_from_option() { println(b) } -fn read() ?[]string { +fn read() ![]string { return error('failed') } diff --git a/vlib/v/tests/assign_option_of_multi_return_with_heap_test.v b/vlib/v/tests/assign_option_of_multi_return_with_heap_test.v index 2ba9ce8ead..7fd4ce1703 100644 --- a/vlib/v/tests/assign_option_of_multi_return_with_heap_test.v +++ b/vlib/v/tests/assign_option_of_multi_return_with_heap_test.v @@ -12,7 +12,7 @@ pub: details Possibilities } -fn (t PossOwner) get_file(path string) ?(PossOwner, Poss1) { +fn (t PossOwner) get_file(path string) !(PossOwner, Poss1) { match t.details { Poss1 { return t, t.details } else { return error('not a file') } diff --git a/vlib/v/tests/attribute_test.v b/vlib/v/tests/attribute_test.v index 19d7c9278f..2cb921cb77 100644 --- a/vlib/v/tests/attribute_test.v +++ b/vlib/v/tests/attribute_test.v @@ -13,7 +13,7 @@ pub struct PubStructAttrTest { struct StructFieldAttrTest { foo string [attr: bar; attr0; attr1: 'foo'] bar int [attr0: 123; attr1: true; attr2: false] - baz bool [prefix.attr0] = false + baz bool [prefix.attr0] = true } [testing] diff --git a/vlib/v/tests/autogen_free_test.v b/vlib/v/tests/autogen_free_test.v index 73def0c6a1..00c6ba8f09 100644 --- a/vlib/v/tests/autogen_free_test.v +++ b/vlib/v/tests/autogen_free_test.v @@ -12,12 +12,12 @@ struct SubInfo { fn test_autogen_free() { info := &Info{} - info.free() + unsafe { info.free() } assert true } fn test_multiple_autogen_free() { info := &Info{} - info.free() + unsafe { info.free() } assert true } diff --git a/vlib/v/tests/cast_to_anon_sumtype_test.v b/vlib/v/tests/cast_to_anon_sumtype_test.v deleted file mode 100644 index dc5f13ca33..0000000000 --- a/vlib/v/tests/cast_to_anon_sumtype_test.v +++ /dev/null @@ -1,5 +0,0 @@ -fn test_cast_to_anon_sumtype() { - x := string|none(none) - println(x) - assert '${x}' == 'string|none(none)' -} diff --git a/vlib/v/tests/comptime_map_it_test.v b/vlib/v/tests/comptime_map_it_test.v index a99417b73e..d2c532f596 100644 --- a/vlib/v/tests/comptime_map_it_test.v +++ b/vlib/v/tests/comptime_map_it_test.v @@ -24,7 +24,7 @@ fn encode[T](typ T) map[string]Any { fn test_main() { a := Arr{[5], [2.0], ['asdf']} r := encode[Arr](a) - assert r['ints'] == Any([Any(5)]) - assert r['floats'] == Any([Any(2.0)]) - assert r['strs'] == Any([Any('asdf')]) + assert unsafe { r['ints'] } == Any([Any(5)]) + assert unsafe { r['floats'] } == Any([Any(2.0)]) + assert unsafe { r['strs'] } == Any([Any('asdf')]) } diff --git a/vlib/v/tests/const_test.v b/vlib/v/tests/const_test.v index e727715d5f..cb1408ebfb 100644 --- a/vlib/v/tests/const_test.v +++ b/vlib/v/tests/const_test.v @@ -23,7 +23,7 @@ struct Foo { name string = 'foo' } -fn foo_decode(name string) ?Foo { +fn foo_decode(name string) !Foo { if name == 'baz' { return error('baz is not allowed') } @@ -32,7 +32,7 @@ fn foo_decode(name string) ?Foo { pub const ( def = foo_decode('baz') or { Foo{} } - bar = foo_decode('bar')? + bar = foo_decode('bar')! ) fn test_opt_const() { diff --git a/vlib/v/tests/defer/defer_return_test.v b/vlib/v/tests/defer/defer_return_test.v index f37ac04db1..6fa0677ae2 100644 --- a/vlib/v/tests/defer/defer_return_test.v +++ b/vlib/v/tests/defer/defer_return_test.v @@ -77,7 +77,7 @@ fn test_defer_opt_return() { assert y.n == 1 } -fn option_return_err(mut a Qwe) ?Qwe { +fn option_return_err(mut a Qwe) !Qwe { defer { a.n += 5 } diff --git a/vlib/v/tests/empty_struct_compare_test.v b/vlib/v/tests/empty_struct_compare_test.v index e75ece99b8..79e2056556 100644 --- a/vlib/v/tests/empty_struct_compare_test.v +++ b/vlib/v/tests/empty_struct_compare_test.v @@ -30,7 +30,7 @@ struct Foo { struct Bar { pub: - foo ?Foo = none + foo ?Foo } fn test_main() { diff --git a/vlib/v/tests/enum_test.v b/vlib/v/tests/enum_test.v index 7a4d59bd95..e8b6b0fdb4 100644 --- a/vlib/v/tests/enum_test.v +++ b/vlib/v/tests/enum_test.v @@ -4,7 +4,7 @@ enum Color { green } -fn enum_option_helper(b bool) ?Color { +fn enum_option_helper(b bool) !Color { if b { return .red } diff --git a/vlib/v/tests/fn_multiple_returns_test.v b/vlib/v/tests/fn_multiple_returns_test.v index 05992e3494..7f6c4bb3e5 100644 --- a/vlib/v/tests/fn_multiple_returns_test.v +++ b/vlib/v/tests/fn_multiple_returns_test.v @@ -20,10 +20,10 @@ fn fn_mr_get_user() (string, int, []string, UserData) { return 'joe', 34, groups, data } -fn split_to_two(s string) ?(string, string) { +fn split_to_two(s string) !(string, string) { mut tokens := s.split_nth(' ', 2) if s.len == 0 { - return none + return error('error') } if tokens.len != 2 { return error('error') @@ -51,7 +51,7 @@ fn test_multiple_ret() { // none case wrapper1 := fn () (string, string) { res2_1, res2_2 := split_to_two('') or { - assert err.msg() == '' + assert err.msg() == 'error' return 'replaced', 'val' } return res2_1, res2_2 diff --git a/vlib/v/tests/fn_ptr_call_test.v b/vlib/v/tests/fn_ptr_call_test.v index e3a449666c..1db1707a0e 100644 --- a/vlib/v/tests/fn_ptr_call_test.v +++ b/vlib/v/tests/fn_ptr_call_test.v @@ -1,12 +1,12 @@ struct Animal { mut: - age fn (p int) int + age fn (p int) int = unsafe { nil } duck Duck } struct Duck { mut: - age &fn (p int) int + age &fn (p int) int = unsafe { nil } } fn test_main() { diff --git a/vlib/v/tests/fn_shared_return_test.v b/vlib/v/tests/fn_shared_return_test.v index 648993a788..3a8c79cdab 100644 --- a/vlib/v/tests/fn_shared_return_test.v +++ b/vlib/v/tests/fn_shared_return_test.v @@ -10,7 +10,7 @@ fn f() shared St { return x } -fn g(good bool) ?shared St { +fn g(good bool) !shared St { if !good { return error('no shared St created') } @@ -28,8 +28,8 @@ fn test_shared_fn_return() { assert val == 3.25 } -fn shared_opt_propagate(good bool) ?f64 { - shared x := g(good)? +fn shared_opt_propagate(good bool) !f64 { + shared x := g(good)! ret := rlock x { x.x } diff --git a/vlib/v/tests/for_in_mut_iterator_val_test.v b/vlib/v/tests/for_in_mut_iterator_val_test.v index 15bacedbff..5932259fe5 100644 --- a/vlib/v/tests/for_in_mut_iterator_val_test.v +++ b/vlib/v/tests/for_in_mut_iterator_val_test.v @@ -11,7 +11,7 @@ const ( struct Packet { pid int - handle fn () string + handle fn () string = unsafe { nil } restricted bool } @@ -24,14 +24,14 @@ mut: fn (mut p Reader) next() ?&Packet { if p.index + 1 > packets.len { - return error('') + return none } if p.index !in packets { - return error('') + return none } p.index++ - return packets[p.index - 1] + return unsafe { packets[p.index - 1] } } fn test_for_in_mut_interator_val() { diff --git a/vlib/v/tests/for_in_mut_struct_val_test.v b/vlib/v/tests/for_in_mut_struct_val_test.v index 337f55d478..0e0332abc3 100644 --- a/vlib/v/tests/for_in_mut_struct_val_test.v +++ b/vlib/v/tests/for_in_mut_struct_val_test.v @@ -18,7 +18,7 @@ mut: fn (mut s StructsRowIterator) next() ?[]int { if s.position >= s.array.len { - return error('out of range') + return none } defer { s.position++ diff --git a/vlib/v/tests/generic_empty_interface_to_struct_test.v b/vlib/v/tests/generic_empty_interface_to_struct_test.v index c6792151bd..a372802c6f 100644 --- a/vlib/v/tests/generic_empty_interface_to_struct_test.v +++ b/vlib/v/tests/generic_empty_interface_to_struct_test.v @@ -8,7 +8,7 @@ struct Container { concrete Any } -fn (container &Container) get_first_struct[T]() ?&T { +fn (container &Container) get_first_struct[T]() !&T { concrete := container.concrete if concrete is T { println(concrete.a) diff --git a/vlib/v/tests/generic_struct_recursive_test.v b/vlib/v/tests/generic_struct_recursive_test.v index e58d2e3fe9..40bb91489e 100644 --- a/vlib/v/tests/generic_struct_recursive_test.v +++ b/vlib/v/tests/generic_struct_recursive_test.v @@ -1,7 +1,7 @@ struct Node[T] { mut: value T - next ?&Node[T] = none + next ?&Node[T] } fn test_main() { diff --git a/vlib/v/tests/generic_sumtype_init_in_generic_fn_call_test.v b/vlib/v/tests/generic_sumtype_init_in_generic_fn_call_test.v index c488ffd3ad..6edc8af6c0 100644 --- a/vlib/v/tests/generic_sumtype_init_in_generic_fn_call_test.v +++ b/vlib/v/tests/generic_sumtype_init_in_generic_fn_call_test.v @@ -1,6 +1,6 @@ pub type Result[S] = Ok[S] | string -pub fn (x Result[S]) unwrap[S]() ?S { +pub fn (x Result[S]) unwrap[S]() !S { match x { Ok[S] { return x.value diff --git a/vlib/v/tests/generics_call_with_reference_arg_test.v b/vlib/v/tests/generics_call_with_reference_arg_test.v index 7bd7f19081..d2717528ab 100644 --- a/vlib/v/tests/generics_call_with_reference_arg_test.v +++ b/vlib/v/tests/generics_call_with_reference_arg_test.v @@ -16,7 +16,7 @@ fn fill(mut s MyStruct[i64]) { fn test_generics_call_with_reference_arg() { mut s := MyStruct[i64]{ pos: 1 - buffer: []&i64{len: 2} + buffer: unsafe { []&i64{len: 2} } } fill(mut s) println(s.pos) 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 557d343dbc..abaff794e1 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 @@ -13,7 +13,7 @@ fn test_generics_with_nested_external_generics_fn() { mut arr := [11, 32, 24, 45, 57, 32, 37, 52, 37, 24] println(arr) - ret := sample[int](arr, 5)? + ret := sample[int](arr, 5)! println(ret) assert ret == [32, 45, 57, 11, 37] diff --git a/vlib/v/tests/heap_reference_test.v b/vlib/v/tests/heap_reference_test.v index 5828516eaa..1c4461e22f 100644 --- a/vlib/v/tests/heap_reference_test.v +++ b/vlib/v/tests/heap_reference_test.v @@ -13,7 +13,7 @@ pub: name string } -pub fn (mut gitstructure GitStructure) repo_get(name string) ?&GitRepo { +pub fn (mut gitstructure GitStructure) repo_get(name string) !&GitRepo { for r in gitstructure.repos { if r.name == name { if name != '' { @@ -60,7 +60,7 @@ pub mut: repos []GitRepo } -pub fn (mut gitstructure GitStructureNoRef) repo_get(name string) ?&GitRepo { +pub fn (mut gitstructure GitStructureNoRef) repo_get(name string) !&GitRepo { for r in gitstructure.repos { if r.name == name { if name != '' { diff --git a/vlib/v/tests/if_guard_test.v b/vlib/v/tests/if_guard_test.v index e8d36e59e1..b1c99905d5 100644 --- a/vlib/v/tests/if_guard_test.v +++ b/vlib/v/tests/if_guard_test.v @@ -1,4 +1,4 @@ -fn f(n int) ?f64 { +fn f(n int) !f64 { if n < 0 { return error('negative') } diff --git a/vlib/v/tests/map_get_assign_blank_test.v b/vlib/v/tests/map_get_assign_blank_test.v index 01088ca652..7733cf86a4 100644 --- a/vlib/v/tests/map_get_assign_blank_test.v +++ b/vlib/v/tests/map_get_assign_blank_test.v @@ -2,7 +2,7 @@ type Abc = int | string fn test_map_get_decl_assign_blank() { x := map[string]Abc{} - _ := x['nonexisting'] + _ := unsafe { x['nonexisting'] } if y := x['nonexisting'] { println(y) } @@ -11,7 +11,7 @@ fn test_map_get_decl_assign_blank() { fn test_map_get_assign_blank() { x := map[string]Abc{} - _ = x['nonexisting'] + _ = unsafe { x['nonexisting'] } if y := x['nonexisting'] { println(y) } diff --git a/vlib/v/tests/match_error_to_none_test.v b/vlib/v/tests/match_error_to_none_test.v index 1a2c99d7d1..c628e65a60 100644 --- a/vlib/v/tests/match_error_to_none_test.v +++ b/vlib/v/tests/match_error_to_none_test.v @@ -1,24 +1,22 @@ fn do_a_thing(i int) ?int { if i < 0 { - return error("can't be negative") - } - if i == 0 { return none } return i } fn test_match_error_to_none() { - i := 0 - if r := do_a_thing(i) { - println(r) - } else { - match err { - none { - assert true - } - else { - assert false + for i := -1; i < 1; i++ { + if r := do_a_thing(i) { + println(r) + } else { + match err { + none { + assert true + } + else { + assert false + } } } } 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 05d49547f2..fdc4869d4c 100644 --- a/vlib/v/tests/match_expr_with_assign_sumtype_test.v +++ b/vlib/v/tests/match_expr_with_assign_sumtype_test.v @@ -12,9 +12,9 @@ enum Operator { type Value = Operator | int struct Expression { - left ?&Expression = none + left ?&Expression val Value - right ?&Expression = none + right ?&Expression } enum State { diff --git a/vlib/v/tests/match_sumtype_var_with_none_test.v b/vlib/v/tests/match_sumtype_var_with_none_test.v deleted file mode 100644 index 9f163c064e..0000000000 --- a/vlib/v/tests/match_sumtype_var_with_none_test.v +++ /dev/null @@ -1,13 +0,0 @@ -fn number() int|none { - return none -} - -fn test_match_sumtype_var_with_none() { - n := number() - ret := match n { - int { 'n: ${n}' } - none { '?' } - } - println(ret) - assert ret == '?' -} diff --git a/vlib/v/tests/modules/sub/foo.v b/vlib/v/tests/modules/sub/foo.v index 6b1d9e9b35..761e48aeaf 100644 --- a/vlib/v/tests/modules/sub/foo.v +++ b/vlib/v/tests/modules/sub/foo.v @@ -8,3 +8,8 @@ struct C.sub_foo { } pub type Foo = C.sub_foo + +// avoiding compiler warnings: module 'c (sub.foo.c)' is imported but never used +fn bar() { + _ = c.used_import +} diff --git a/vlib/v/tests/nested_option_call_test.v b/vlib/v/tests/nested_option_call_test.v index 5fe69c57a5..788ee478ea 100644 --- a/vlib/v/tests/nested_option_call_test.v +++ b/vlib/v/tests/nested_option_call_test.v @@ -30,7 +30,7 @@ mut: z f64 } -fn (mut s St) raise() ?f64 { +fn (mut s St) raise() !f64 { return error('some error') } @@ -52,8 +52,8 @@ fn test_nested_or_method_call() { assert x.z == 2.25 } -fn (mut s St) aa_propagate() ? { - f := retf(s.raise()?) +fn (mut s St) aa_propagate() ! { + f := retf(s.raise()!) s.z = 7.5 println(f) } diff --git a/vlib/v/tests/option_2_test.v b/vlib/v/tests/option_2_test.v index 1123db6f15..5f6bb980b4 100644 --- a/vlib/v/tests/option_2_test.v +++ b/vlib/v/tests/option_2_test.v @@ -1,4 +1,4 @@ -fn f(n int) ?int { +fn f(n int) !int { if n < 0 { return error('negative arg') } diff --git a/vlib/v/tests/option_default_values_test.v b/vlib/v/tests/option_default_values_test.v index 4c4d43a3b5..46a44d5916 100644 --- a/vlib/v/tests/option_default_values_test.v +++ b/vlib/v/tests/option_default_values_test.v @@ -2,28 +2,28 @@ struct Abc { x int } -fn i_0(x int) ?int { +fn i_0(x int) !int { if x == 0 { return error('my error 1') } return x } -fn struct_0(x int) ?Abc { +fn struct_0(x int) !Abc { if x == 0 { return error('my error 2') } return Abc{x} } -fn string_0(x int) ?string { +fn string_0(x int) !string { if x == 0 { return error('my error 3') } return '${x}' } -fn b_0(b bool) ?bool { +fn b_0(b bool) !bool { if b == false { return error('my error 4') } diff --git a/vlib/v/tests/option_expr_with_array_value_test.v b/vlib/v/tests/option_expr_with_array_value_test.v index 57a058d1b9..183eb41977 100644 --- a/vlib/v/tests/option_expr_with_array_value_test.v +++ b/vlib/v/tests/option_expr_with_array_value_test.v @@ -2,7 +2,7 @@ struct Empty { empty string } -fn print_error() ?[]Empty { +fn print_error() ![]Empty { mut test := []Empty{} test << Empty{ empty: 'Test' diff --git a/vlib/v/tests/option_if_assign_and_fallthrough_test.v b/vlib/v/tests/option_if_assign_and_fallthrough_test.v index d3b6ebb181..088a9ddc04 100644 --- a/vlib/v/tests/option_if_assign_and_fallthrough_test.v +++ b/vlib/v/tests/option_if_assign_and_fallthrough_test.v @@ -1,4 +1,4 @@ -fn err_call(ok bool) ?int { +fn err_call(ok bool) !int { if ok { return 42 } diff --git a/vlib/v/tests/option_in_loop_test.v b/vlib/v/tests/option_in_loop_test.v index 733c39046b..40ea324094 100644 --- a/vlib/v/tests/option_in_loop_test.v +++ b/vlib/v/tests/option_in_loop_test.v @@ -1,4 +1,4 @@ -fn opt_0_10_20(x int) ?int { +fn opt_0_10_20(x int) !int { if x < 0 || (x >= 10 && x <= 20) { return error('invalid') } diff --git a/vlib/v/tests/option_struct_init_with_ref_opt_test.v b/vlib/v/tests/option_struct_init_with_ref_opt_test.v index 3b9b5258eb..8aa40f4767 100644 --- a/vlib/v/tests/option_struct_init_with_ref_opt_test.v +++ b/vlib/v/tests/option_struct_init_with_ref_opt_test.v @@ -1,14 +1,14 @@ struct Node { value int mut: - prev ?&Node = none - next ?&Node = none + prev ?&Node + next ?&Node } struct LinkedList { mut: - head ?&Node = none - tail ?&Node = none + head ?&Node + tail ?&Node } pub fn (mut l LinkedList) push(value int) { diff --git a/vlib/v/tests/option_test.v b/vlib/v/tests/option_test.v index f5689a379b..3062ef61c7 100644 --- a/vlib/v/tests/option_test.v +++ b/vlib/v/tests/option_test.v @@ -1,5 +1,5 @@ // TODO: remove this after the deprecation period for `?Type` representing both Result and Option passes. -fn opt_err_with_code(code int) ?string { +fn opt_err_with_code(code int) !string { return error_with_code('hi', code) } @@ -20,7 +20,7 @@ fn test_err_with_code() { _ := v } -fn opt_err() ?string { +fn opt_err() !string { return error('hi') } @@ -33,7 +33,7 @@ fn test_err() { println(v) // suppress not used error } -fn err_call(ok bool) ?int { +fn err_call(ok bool) !int { if !ok { return error('Not ok!') } @@ -79,7 +79,7 @@ fn test_if_else_opt() { } } -fn for_opt_default() ?string { +fn for_opt_default() !string { return error('awww') } @@ -99,13 +99,13 @@ fn foo_str() ?string { return 'something' } -fn propagate_option(b bool) ?int { - a := err_call(b)? +fn propagate_option(b bool) !int { + a := err_call(b)! return a } -fn propagate_different_type(b bool) ?bool { - err_call(b)? +fn propagate_different_type(b bool) !bool { + err_call(b)! return true } @@ -137,7 +137,7 @@ fn or_return_val() int { return a } -fn or_return_error() ?int { +fn or_return_error() !int { a := ret_none() or { return error('Nope') } return a } @@ -282,7 +282,7 @@ fn test_option_val_with_empty_or() { } fn test_option_void_return_types_of_anon_fn() { - f := fn (i int) ? { + f := fn (i int) ! { if i == 0 { return error('0') } @@ -297,12 +297,12 @@ fn test_option_void_return_types_of_anon_fn() { } struct Foo { - f fn (int) ? + f fn (int) ! [required] } fn test_option_void_return_types_of_anon_fn_in_struct() { foo := Foo{ - f: fn (i int) ? { + f: fn (i int) ! { if i == 0 { return error('0') } @@ -327,7 +327,7 @@ struct CC { str string } -fn option_sum_type(a int) ?AA { +fn option_sum_type(a int) !AA { match a { 1 { return BB{'Test'} diff --git a/vlib/v/tests/option_void_test.v b/vlib/v/tests/option_void_test.v index aa627e8f37..e63d795628 100644 --- a/vlib/v/tests/option_void_test.v +++ b/vlib/v/tests/option_void_test.v @@ -1,4 +1,4 @@ -fn foo() ? { +fn foo() ! { return error('something') } @@ -10,7 +10,7 @@ fn test_option_void() { } } -fn bar() ? { +fn bar() ! { return error('bar error') } @@ -27,7 +27,7 @@ fn test_option_void_with_empty_or() { assert true } -fn option_void(a int) ? { +fn option_void(a int) ! { if a != 0 { return } else { diff --git a/vlib/v/tests/or_expr_with_multi_stmts_test.v b/vlib/v/tests/or_expr_with_multi_stmts_test.v index 7eea61bd4e..44b781023d 100644 --- a/vlib/v/tests/or_expr_with_multi_stmts_test.v +++ b/vlib/v/tests/or_expr_with_multi_stmts_test.v @@ -7,6 +7,6 @@ fn test_or_expr_with_multi_stmts() { assert x == -100 } -fn fmt_test() ?int { +fn fmt_test() !int { return error('foo') } diff --git a/vlib/v/tests/or_expr_with_nested_match_expr_test.v b/vlib/v/tests/or_expr_with_nested_match_expr_test.v index 3dacc7e456..57840b08c1 100644 --- a/vlib/v/tests/or_expr_with_nested_match_expr_test.v +++ b/vlib/v/tests/or_expr_with_nested_match_expr_test.v @@ -21,7 +21,7 @@ fn delete_secret_v1() API_error { println(response) } -fn req_do() ?string { +fn req_do() !string { return error('dial_tcp failed') } diff --git a/vlib/v/tests/shared_fn_return_test.v b/vlib/v/tests/shared_fn_return_test.v index 1d5a45bfda..4b8cacb1dd 100644 --- a/vlib/v/tests/shared_fn_return_test.v +++ b/vlib/v/tests/shared_fn_return_test.v @@ -10,7 +10,7 @@ fn f() St { return x } -fn g(good bool) ?St { +fn g(good bool) !St { if !good { return error('no St created') } @@ -28,8 +28,8 @@ fn test_shared_fn_return() { assert val == 3.25 } -fn shared_opt_propagate(good bool) ?f64 { - shared x := g(good)? +fn shared_opt_propagate(good bool) !f64 { + shared x := g(good)! ret := rlock x { x.x } diff --git a/vlib/v/tests/string_array_of_ref_type_test.v b/vlib/v/tests/string_array_of_ref_type_test.v index 6f226db5d3..8b55929f63 100644 --- a/vlib/v/tests/string_array_of_ref_type_test.v +++ b/vlib/v/tests/string_array_of_ref_type_test.v @@ -1,5 +1,5 @@ fn test_string_array_of_ref_type() { - a := []&int{len: 2} + a := unsafe { []&int{len: 2} } println(a) assert '${a}' == '[nil, nil]' } diff --git a/vlib/v/tests/string_option_none_test.v b/vlib/v/tests/string_option_none_test.v deleted file mode 100644 index 50b7bd9a2b..0000000000 --- a/vlib/v/tests/string_option_none_test.v +++ /dev/null @@ -1,22 +0,0 @@ -struct MyError { - msg string - code int -} - -fn (err MyError) msg() string { - return err.msg -} - -fn (err MyError) code() int { - return err.code -} - -fn foo() int|none|IError { - return MyError{} -} - -fn test_string_option_none() { - x := foo() - println(x) - assert true -} diff --git a/vlib/v/tests/struct_selector_or_block_test.v b/vlib/v/tests/struct_selector_or_block_test.v index 2c5f25ec9d..2ebd36e8c1 100644 --- a/vlib/v/tests/struct_selector_or_block_test.v +++ b/vlib/v/tests/struct_selector_or_block_test.v @@ -3,12 +3,12 @@ interface Greeting { } struct Hello { - tt ?string = none + tt ?string value string } struct Hi { - tt ?string = none + tt ?string } fn greet(g Greeting) string { diff --git a/vlib/v/tests/struct_test.v b/vlib/v/tests/struct_test.v index 80286b0ea5..483bbc0303 100644 --- a/vlib/v/tests/struct_test.v +++ b/vlib/v/tests/struct_test.v @@ -360,13 +360,13 @@ fn test_struct_with_default_values_no_init() { } struct FieldsWithOptionVoidReturnType { - f fn () ? - g fn () ? + f fn () ! [required] + g fn () ? [required] } fn test_fields_anon_fn_with_option_void_return_type() { foo := FieldsWithOptionVoidReturnType{ - f: fn () ? { + f: fn () ! { return error('oops') } g: fn () ? { diff --git a/vlib/v/tests/sumtype_with_none_test.v b/vlib/v/tests/sumtype_with_none_test.v deleted file mode 100644 index f061e3de09..0000000000 --- a/vlib/v/tests/sumtype_with_none_test.v +++ /dev/null @@ -1,16 +0,0 @@ -fn string_none() string|none { - return none -} - -fn test_sumtype_with_none() { - x := string_none() - res := match x { - string { - false - } - none { - true - } - } - assert res -} diff --git a/vlib/v/tests/typeof_test.v b/vlib/v/tests/typeof_test.v index 5e768cd351..a9d411a99d 100644 --- a/vlib/v/tests/typeof_test.v +++ b/vlib/v/tests/typeof_test.v @@ -1,11 +1,10 @@ fn test_typeof_on_simple_expressions() { a := int(123) - assert typeof(int(42)) == 'int' - assert typeof(f64(3.14)) == 'f64' - assert typeof(int(2) + 2 * 10) == 'int' - assert typeof(f64(1.0) * 12.2) == 'f64' - // assert typeof(1.0 * f32(12.2)) == 'f32' - assert typeof(a) == 'int' + assert typeof(int(42)).name == 'int' + assert typeof(f64(3.14)).name == 'f64' + assert typeof(int(2) + 2 * 10).name == 'int' + assert typeof(f64(1.0) * 12.2).name == 'f64' + // assert typeof(1.0 * f32(12.2)).name == 'f32' assert typeof(a).name == 'int' // a2 := 123 // assert typeof(a2) == 'int_literal' @@ -18,8 +17,6 @@ fn test_typeof_on_simple_expressions() { fn test_arrays() { aint := []int{} astring := []string{} - assert typeof(aint) == '[]int' - assert typeof(astring) == '[]string' assert typeof(aint).name == '[]int' assert typeof(astring).name == '[]string' } @@ -38,12 +35,10 @@ struct FooBar { } fn test_typeof_on_structs() { - assert typeof(FooBar{}) == 'FooBar' + assert typeof(FooBar{}).name == 'FooBar' astruct_static := [2]FooBar{} astruct_dynamic := [FooBar{}, FooBar{}] - assert typeof(astruct_static) == '[2]FooBar' assert typeof(astruct_static).name == '[2]FooBar' - assert typeof(astruct_dynamic) == '[]FooBar' assert typeof(astruct_dynamic).name == '[]FooBar' } @@ -64,9 +59,6 @@ fn test_typeof_on_sumtypes() { c := MySumType(FooBar{ x: 43 }) - assert typeof(a) == 'int' - assert typeof(b) == 'f32' - assert typeof(c) == 'FooBar' assert a.type_name() == 'int' assert b.type_name() == 'f32' assert c.type_name() == 'FooBar' @@ -110,10 +102,10 @@ fn test_typeof_on_sumtypes_of_structs() { b := fexpr(2) c := fexpr(3) d := ExprType(UnaryExpr{}) - assert typeof(a) == 'UnaryExpr' - assert typeof(b) == 'BinExpr' - assert typeof(c) == 'BoolExpr' - assert typeof(d) == 'UnaryExpr' + assert typeof(a).name == 'ExprType' + assert typeof(b).name == 'ExprType' + assert typeof(c).name == 'ExprType' + assert typeof(d).name == 'ExprType' assert a.type_name() == 'UnaryExpr' assert b.type_name() == 'BinExpr' assert c.type_name() == 'BoolExpr' @@ -136,10 +128,10 @@ fn myfn4() i8 { } fn test_typeof_on_fn() { - assert typeof(myfn) == 'fn (int) int' - assert typeof(myfn2) == 'fn ()' - assert typeof(myfn3) == 'fn (int, string) u8' - assert typeof(myfn4) == 'fn () i8' + assert typeof(myfn).name == 'fn (int) int' + assert typeof(myfn2).name == 'fn ()' + assert typeof(myfn3).name == 'fn (int, string) u8' + assert typeof(myfn4).name == 'fn () i8' assert typeof(myfn).name == typeof(myfn) assert typeof(&myfn).name == '&fn (int) int' assert typeof(myfn2).name == typeof(myfn2) diff --git a/vlib/v/tests/vsh_envbang_test.v b/vlib/v/tests/vsh_envbang_test.v index 09474ee517..b9d1a35556 100644 --- a/vlib/v/tests/vsh_envbang_test.v +++ b/vlib/v/tests/vsh_envbang_test.v @@ -19,14 +19,14 @@ fn test_envbang_script_runs() { import os println('hello') println(os.args) -")? - os.chmod(rnd_vsh_script_path, 0o700)? +")! + os.chmod(rnd_vsh_script_path, 0o700)! res := os.execute('${os.quoted_path(rnd_vsh_script_path)} abc 123 -option') assert res.exit_code == 0 lines := res.output.split_into_lines() assert lines[0] == 'hello' assert lines[1].ends_with(", 'abc', '123', '-option']") - os.rm(rnd_vsh_script_path)? + os.rm(rnd_vsh_script_path)! } [noreturn]