tests: use u8 everywhere

master
Alexander Medvednikov 2022-04-15 18:34:15 +03:00
parent fbb9e65c0f
commit 1c6f63ac0a
29 changed files with 60 additions and 58 deletions

View File

@ -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 {

View File

@ -1,5 +1,5 @@
fn main() {
mut bc := []byte{}
mut bc := []u8{}
bc << [0xCA, 0xFE, 0xBA, 0xBE]
println(bc)
}

View File

@ -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

View File

@ -26,7 +26,7 @@ fn main() {
sm := string(mm)
println(sm)
//
arr := []byte{}
arr := []u8{}
sa := string(arr)
println(sa)
//

View File

@ -2,7 +2,7 @@ const size = -1
fn main() {
a := [size]int{}
b := [0]byte{}
b := [0]u8{}
println(a)
println(b)
}

View File

@ -1,4 +1,4 @@
fn uu8(a byte) {}
fn uu8(a u8) {}
fn arr(a []int) {}

View File

@ -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)
}

View File

@ -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)

View File

@ -1,5 +1,5 @@
s := ''
s.len = 123
//
b := []byte{}
b := []u8{}
b.len = 34

View File

@ -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{})

View File

@ -1,4 +1,4 @@
type Int = byte | int
type Int = int | u8
fn main() {
i := Int(0)

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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 {}

View File

@ -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)
}

View File

@ -11,7 +11,7 @@ pub:
f u64
pub mut:
g string
h byte
h u8
}
fn comptime_for() {

View File

@ -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
}

View File

@ -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

View File

@ -1 +1 @@
fn C.PQgetvalue(voidptr, int, int) &byte
fn C.PQgetvalue(voidptr, int, int) &u8

View File

@ -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 {

View File

@ -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`' }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
union Un {
i int
b byte
b u8
}

View File

@ -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{}

View File

@ -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()
}

View File

@ -1,4 +1,4 @@
type Byte = byte
type Byte = u8
fn (b Byte) str() string {
return 'hello'