From de310491bb4aef811ccc5e4a18e690bbb2c28dbd Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 15 Apr 2022 18:34:15 +0300 Subject: [PATCH] tests: use u8 everywhere --- vlib/gg/testdata/remove_image_from_cache.vv | 2 +- .../array_append_array_type_mismatch_err.vv | 2 +- vlib/v/checker/tests/c_fn_surplus_args.vv | 4 +-- vlib/v/checker/tests/cast_string_err.vv | 2 +- .../checker/tests/compare_unsigned_signed.vv | 2 +- vlib/v/checker/tests/fixed_array_size_err.vv | 2 +- vlib/v/checker/tests/fn_args.vv | 2 +- vlib/v/checker/tests/fn_var.vv | 6 +++-- .../tests/if_mut_with_immutable_var_err.vv | 4 +-- .../checker/tests/immutable_builtin_modify.vv | 2 +- vlib/v/checker/tests/is_type_invalid.vv | 2 +- .../tests/match_mut_with_immutable_var_err.vv | 2 +- .../tests/optional_or_block_none_err.vv | 14 +++++----- vlib/v/checker/tests/ptr_slice.vv | 10 +++---- vlib/v/checker/tests/struct_type_cast_err.vv | 26 +++++++++---------- vlib/v/fmt/tests/array_newlines_keep.vv | 2 +- vlib/v/fmt/tests/comptime_keep.vv | 2 +- .../v/fmt/tests/fixed_size_array_type_keep.vv | 4 +-- .../tests/fn_headers_with_no_bodies_keep.vv | 2 +- vlib/v/fmt/tests/fn_with_anon_params_keep.vv | 2 +- .../interface_declaration_comments_keep.vv | 4 +-- .../match_range_expression_branches_keep.vv | 2 +- .../tests/struct_init_with_comments_keep.vv | 4 +-- vlib/v/fmt/tests/symbol_registration_keep.vv | 2 +- vlib/v/fmt/tests/types_expected.vv | 2 +- vlib/v/fmt/tests/union_keep.vv | 2 +- vlib/v/parser/tests/struct_module_section.vv | 4 +-- vlib/v/tests/inout/dump_expression.vv | 2 +- .../inout/printing_alias_has_str_method.vv | 2 +- 29 files changed, 60 insertions(+), 58 deletions(-) diff --git a/vlib/gg/testdata/remove_image_from_cache.vv b/vlib/gg/testdata/remove_image_from_cache.vv index 2b2385ed23..01eed818d1 100644 --- a/vlib/gg/testdata/remove_image_from_cache.vv +++ b/vlib/gg/testdata/remove_image_from_cache.vv @@ -17,7 +17,7 @@ fn frame(mut ctx gg.Context) { ctx.begin() id := ctx.new_streaming_image(ctx.width, ctx.height, 4, pixel_format: .rgba8) mut img := ctx.get_cached_image_by_idx(id) - mut bytes := []byte{len: img.width * img.height * 4, cap: img.width * img.height * 4} + mut bytes := []u8{len: img.width * img.height * 4, cap: img.width * img.height * 4} for y in 0 .. img.height { for x in 0 .. img.width { unsafe { diff --git a/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv b/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv index 45de913508..e2570c8625 100644 --- a/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv +++ b/vlib/v/checker/tests/array_append_array_type_mismatch_err.vv @@ -1,5 +1,5 @@ fn main() { - mut bc := []byte{} + mut bc := []u8{} bc << [0xCA, 0xFE, 0xBA, 0xBE] println(bc) } diff --git a/vlib/v/checker/tests/c_fn_surplus_args.vv b/vlib/v/checker/tests/c_fn_surplus_args.vv index e7c6466ded..30da2f34ad 100644 --- a/vlib/v/checker/tests/c_fn_surplus_args.vv +++ b/vlib/v/checker/tests/c_fn_surplus_args.vv @@ -1,6 +1,6 @@ fn C.no() // untyped fn C.y1(int) -fn C.ret()byte +fn C.ret() u8 fn main() { C.no(1) // allowed @@ -16,4 +16,4 @@ fn main() { } [trusted] -fn C.af()int +fn C.af() int diff --git a/vlib/v/checker/tests/cast_string_err.vv b/vlib/v/checker/tests/cast_string_err.vv index 85d50c359c..19d27d7b26 100644 --- a/vlib/v/checker/tests/cast_string_err.vv +++ b/vlib/v/checker/tests/cast_string_err.vv @@ -26,7 +26,7 @@ fn main() { sm := string(mm) println(sm) // - arr := []byte{} + arr := []u8{} sa := string(arr) println(sa) // diff --git a/vlib/v/checker/tests/compare_unsigned_signed.vv b/vlib/v/checker/tests/compare_unsigned_signed.vv index ed6fc040ed..e880b58c00 100644 --- a/vlib/v/checker/tests/compare_unsigned_signed.vv +++ b/vlib/v/checker/tests/compare_unsigned_signed.vv @@ -9,7 +9,7 @@ fn main() { // unsigned == literal _ = byte(-1) == -1 // false! _ = -1 == u16(-1) // false! - + // unsigned == signed _ = u16(-1) == int(-1) _ = int(-1) != byte(-1) diff --git a/vlib/v/checker/tests/fixed_array_size_err.vv b/vlib/v/checker/tests/fixed_array_size_err.vv index eb27c2bf8d..00becde95c 100644 --- a/vlib/v/checker/tests/fixed_array_size_err.vv +++ b/vlib/v/checker/tests/fixed_array_size_err.vv @@ -2,7 +2,7 @@ const size = -1 fn main() { a := [size]int{} - b := [0]byte{} + b := [0]u8{} println(a) println(b) } diff --git a/vlib/v/checker/tests/fn_args.vv b/vlib/v/checker/tests/fn_args.vv index 5cfdff5992..71760cf59b 100644 --- a/vlib/v/checker/tests/fn_args.vv +++ b/vlib/v/checker/tests/fn_args.vv @@ -1,4 +1,4 @@ -fn uu8(a byte) {} +fn uu8(a u8) {} fn arr(a []int) {} diff --git a/vlib/v/checker/tests/fn_var.vv b/vlib/v/checker/tests/fn_var.vv index 0a48b5d740..c46eb7065a 100644 --- a/vlib/v/checker/tests/fn_var.vv +++ b/vlib/v/checker/tests/fn_var.vv @@ -1,8 +1,10 @@ -mut f := fn(i int) byte {} +mut f := fn (i int) u8 {} f = 4 mut p := &f p = &[f] _ = p i := 0 println(i) -f = fn(mut a []int) { println(i) } +f = fn (mut a []int) { + println(i) +} diff --git a/vlib/v/checker/tests/if_mut_with_immutable_var_err.vv b/vlib/v/checker/tests/if_mut_with_immutable_var_err.vv index 4c84c91420..429c17b8cd 100644 --- a/vlib/v/checker/tests/if_mut_with_immutable_var_err.vv +++ b/vlib/v/checker/tests/if_mut_with_immutable_var_err.vv @@ -1,10 +1,10 @@ -type Int = byte | int +type Int = int | u8 fn main() { i := Int(0) if mut i is int { i = 1 - } else if mut i is byte { + } else if mut i is u8 { i = 2 } println(i) diff --git a/vlib/v/checker/tests/immutable_builtin_modify.vv b/vlib/v/checker/tests/immutable_builtin_modify.vv index e6cb7060b8..5f06db98c2 100644 --- a/vlib/v/checker/tests/immutable_builtin_modify.vv +++ b/vlib/v/checker/tests/immutable_builtin_modify.vv @@ -1,5 +1,5 @@ s := '' s.len = 123 // -b := []byte{} +b := []u8{} b.len = 34 diff --git a/vlib/v/checker/tests/is_type_invalid.vv b/vlib/v/checker/tests/is_type_invalid.vv index 2e7f774567..a2afa2ca88 100644 --- a/vlib/v/checker/tests/is_type_invalid.vv +++ b/vlib/v/checker/tests/is_type_invalid.vv @@ -11,7 +11,7 @@ fn (d Dog) speak() {} struct Cat {} fn main() { - if IoS(1) is byte { + if IoS(1) is u8 { println('not cool') } a := Animal(Dog{}) diff --git a/vlib/v/checker/tests/match_mut_with_immutable_var_err.vv b/vlib/v/checker/tests/match_mut_with_immutable_var_err.vv index 56a5760808..18c3292963 100644 --- a/vlib/v/checker/tests/match_mut_with_immutable_var_err.vv +++ b/vlib/v/checker/tests/match_mut_with_immutable_var_err.vv @@ -1,4 +1,4 @@ -type Int = byte | int +type Int = int | u8 fn main() { i := Int(0) diff --git a/vlib/v/checker/tests/optional_or_block_none_err.vv b/vlib/v/checker/tests/optional_or_block_none_err.vv index c1970a306e..45315d381f 100644 --- a/vlib/v/checker/tests/optional_or_block_none_err.vv +++ b/vlib/v/checker/tests/optional_or_block_none_err.vv @@ -1,22 +1,22 @@ module main struct Animal { - mut: - height byte +mut: + height u8 } -fn new_animal(height byte) ?Animal { +fn new_animal(height u8) ?Animal { if height < 10 { return error('Too small to be an animal!') } - return Animal{ height: height } + return Animal{ + height: height + } } fn main() { - mut dog := new_animal(9) or { - none - } + mut dog := new_animal(9) or { none } println(dog) } diff --git a/vlib/v/checker/tests/ptr_slice.vv b/vlib/v/checker/tests/ptr_slice.vv index 2249ab9039..e36c8e7a2f 100644 --- a/vlib/v/checker/tests/ptr_slice.vv +++ b/vlib/v/checker/tests/ptr_slice.vv @@ -2,12 +2,12 @@ struct Foo { } fn jeje() &Foo { - return &Foo{} + return &Foo{} } fn main() { - fs := jeje()[1..] - println(fs) - vs := byteptr(0)[..3] - println(vs) + fs := jeje()[1..] + println(fs) + vs := byteptr(0)[..3] + println(vs) } diff --git a/vlib/v/checker/tests/struct_type_cast_err.vv b/vlib/v/checker/tests/struct_type_cast_err.vv index a27eefdb81..2a28ae2793 100644 --- a/vlib/v/checker/tests/struct_type_cast_err.vv +++ b/vlib/v/checker/tests/struct_type_cast_err.vv @@ -1,17 +1,17 @@ -struct Foo{} +struct Foo {} fn main() { - foo := Foo{} - _ := string(foo) - _ := int(foo) - _ := u64(foo) - _ := u32(foo) - _ := rune(foo) - _ := byte(foo) - _ := i8(foo) - _ := i64(foo) - _ := int(foo) - _ = &I1(foo) + foo := Foo{} + _ := string(foo) + _ := int(foo) + _ := u64(foo) + _ := u32(foo) + _ := rune(foo) + _ := byte(foo) + _ := i8(foo) + _ := i64(foo) + _ := int(foo) + _ = &I1(foo) } -interface I1{} +interface I1 {} diff --git a/vlib/v/fmt/tests/array_newlines_keep.vv b/vlib/v/fmt/tests/array_newlines_keep.vv index 11fded188f..f8667795e0 100644 --- a/vlib/v/fmt/tests/array_newlines_keep.vv +++ b/vlib/v/fmt/tests/array_newlines_keep.vv @@ -11,7 +11,7 @@ fn main() { ] x := []int{len: 10, cap: 100, init: 1} _ := expected_flags - buf := [100]byte{} + buf := [100]u8{} println(x) println(buf) } diff --git a/vlib/v/fmt/tests/comptime_keep.vv b/vlib/v/fmt/tests/comptime_keep.vv index 987e513dd7..da5aa7884d 100644 --- a/vlib/v/fmt/tests/comptime_keep.vv +++ b/vlib/v/fmt/tests/comptime_keep.vv @@ -11,7 +11,7 @@ pub: f u64 pub mut: g string - h byte + h u8 } fn comptime_for() { diff --git a/vlib/v/fmt/tests/fixed_size_array_type_keep.vv b/vlib/v/fmt/tests/fixed_size_array_type_keep.vv index fbe0001a14..3c91216679 100644 --- a/vlib/v/fmt/tests/fixed_size_array_type_keep.vv +++ b/vlib/v/fmt/tests/fixed_size_array_type_keep.vv @@ -18,11 +18,11 @@ fn main() { // from another .v file struct VerifyKey { - public_key [public_key_size]byte + public_key [public_key_size]u8 } struct SigningKey { - secret_key [secret_key_size]byte + secret_key [secret_key_size]u8 pub: verify_key VerifyKey } diff --git a/vlib/v/fmt/tests/fn_headers_with_no_bodies_keep.vv b/vlib/v/fmt/tests/fn_headers_with_no_bodies_keep.vv index 98d04768d2..9b6d22119a 100644 --- a/vlib/v/fmt/tests/fn_headers_with_no_bodies_keep.vv +++ b/vlib/v/fmt/tests/fn_headers_with_no_bodies_keep.vv @@ -2,4 +2,4 @@ fn proc_pidpath(int, voidptr, int) int fn C.realpath(&char, &char) &char -fn C.chmod(&byte, int) int +fn C.chmod(&u8, int) int diff --git a/vlib/v/fmt/tests/fn_with_anon_params_keep.vv b/vlib/v/fmt/tests/fn_with_anon_params_keep.vv index ab6a13ab77..cc01a9f2d3 100644 --- a/vlib/v/fmt/tests/fn_with_anon_params_keep.vv +++ b/vlib/v/fmt/tests/fn_with_anon_params_keep.vv @@ -1 +1 @@ -fn C.PQgetvalue(voidptr, int, int) &byte +fn C.PQgetvalue(voidptr, int, int) &u8 diff --git a/vlib/v/fmt/tests/interface_declaration_comments_keep.vv b/vlib/v/fmt/tests/interface_declaration_comments_keep.vv index 8a7a6d94f8..c74c3a6608 100644 --- a/vlib/v/fmt/tests/interface_declaration_comments_keep.vv +++ b/vlib/v/fmt/tests/interface_declaration_comments_keep.vv @@ -1,6 +1,6 @@ pub interface ReaderWriter { - read(mut buf []byte) ?int // from Reader - write(buf []byte) ?int // from Writer + read(mut buf []u8) ?int // from Reader + write(buf []u8) ?int // from Writer } interface Speaker { diff --git a/vlib/v/fmt/tests/match_range_expression_branches_keep.vv b/vlib/v/fmt/tests/match_range_expression_branches_keep.vv index ae99b0ff35..25303b9470 100644 --- a/vlib/v/fmt/tests/match_range_expression_branches_keep.vv +++ b/vlib/v/fmt/tests/match_range_expression_branches_keep.vv @@ -1,4 +1,4 @@ -pub fn str_escaped(b byte) string { +pub fn str_escaped(b u8) string { str := match b { 0 { '`\\' + '0`' } // Bug is preventing \\0 in a literal 7 { '`\\a`' } diff --git a/vlib/v/fmt/tests/struct_init_with_comments_keep.vv b/vlib/v/fmt/tests/struct_init_with_comments_keep.vv index 60576b2d49..303b8a70ef 100644 --- a/vlib/v/fmt/tests/struct_init_with_comments_keep.vv +++ b/vlib/v/fmt/tests/struct_init_with_comments_keep.vv @@ -3,7 +3,7 @@ module abcde pub struct Builder { pub mut: // inline before field - buf []byte + buf []u8 str_calls int len int initial_size int = 1 @@ -12,7 +12,7 @@ pub mut: pub fn new_builder(initial_size int) Builder { return Builder{ // buf: make(0, initial_size) - buf: []byte{cap: initial_size} + buf: []u8{cap: initial_size} str_calls: 0 // after str_calls len: 0 // after len initial_size: initial_size // final diff --git a/vlib/v/fmt/tests/symbol_registration_keep.vv b/vlib/v/fmt/tests/symbol_registration_keep.vv index 66b201d78e..c9fdb5d828 100644 --- a/vlib/v/fmt/tests/symbol_registration_keep.vv +++ b/vlib/v/fmt/tests/symbol_registration_keep.vv @@ -14,7 +14,7 @@ mut: store &Store = &Store(0) cursor TreeCursor module_name string - src_text []byte + src_text []u8 // skips the local scopes and registers only // the top-level ones regardless of its // visibility diff --git a/vlib/v/fmt/tests/types_expected.vv b/vlib/v/fmt/tests/types_expected.vv index 1eed4362d6..b90e5be8e1 100644 --- a/vlib/v/fmt/tests/types_expected.vv +++ b/vlib/v/fmt/tests/types_expected.vv @@ -2,7 +2,7 @@ type FooBar = Bar | Foo pub type PublicBar = Bar | Foo | FooBar -type Uint = byte | u16 | u32 | u64 // This should stay on the same line +type Uint = u16 | u32 | u64 | u8 // This should stay on the same line type Float = f32 | f64 // Alias type diff --git a/vlib/v/fmt/tests/union_keep.vv b/vlib/v/fmt/tests/union_keep.vv index 5872d03643..f47d84f3a8 100644 --- a/vlib/v/fmt/tests/union_keep.vv +++ b/vlib/v/fmt/tests/union_keep.vv @@ -1,4 +1,4 @@ union Un { i int - b byte + b u8 } diff --git a/vlib/v/parser/tests/struct_module_section.vv b/vlib/v/parser/tests/struct_module_section.vv index d15a49ceaf..932d348f26 100644 --- a/vlib/v/parser/tests/struct_module_section.vv +++ b/vlib/v/parser/tests/struct_module_section.vv @@ -1,6 +1,6 @@ struct S1 { pub mut: - v byte + v u8 module: i int } @@ -9,7 +9,7 @@ struct S2 { module: j int mut: - v byte + v u8 } mut s := S1{} diff --git a/vlib/v/tests/inout/dump_expression.vv b/vlib/v/tests/inout/dump_expression.vv index 713d172249..96bdcd8f32 100644 --- a/vlib/v/tests/inout/dump_expression.vv +++ b/vlib/v/tests/inout/dump_expression.vv @@ -37,7 +37,7 @@ fn dump_of_callexpr() { vfile := @FILE dump(os.file_name(vfile)) mut f := os.open_file(@FILE, 'r') or { return } - mut buf := []byte{len: 10} + mut buf := []u8{len: 10} dump(f.read(mut buf) or { -999 }) f.close() } diff --git a/vlib/v/tests/inout/printing_alias_has_str_method.vv b/vlib/v/tests/inout/printing_alias_has_str_method.vv index 3b79901af9..0d610df2fb 100644 --- a/vlib/v/tests/inout/printing_alias_has_str_method.vv +++ b/vlib/v/tests/inout/printing_alias_has_str_method.vv @@ -1,4 +1,4 @@ -type Byte = byte +type Byte = u8 fn (b Byte) str() string { return 'hello'