tests: use u8 everywhere
parent
80b35fe0c6
commit
de310491bb
|
@ -17,7 +17,7 @@ fn frame(mut ctx gg.Context) {
|
||||||
ctx.begin()
|
ctx.begin()
|
||||||
id := ctx.new_streaming_image(ctx.width, ctx.height, 4, pixel_format: .rgba8)
|
id := ctx.new_streaming_image(ctx.width, ctx.height, 4, pixel_format: .rgba8)
|
||||||
mut img := ctx.get_cached_image_by_idx(id)
|
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 y in 0 .. img.height {
|
||||||
for x in 0 .. img.width {
|
for x in 0 .. img.width {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
mut bc := []byte{}
|
mut bc := []u8{}
|
||||||
bc << [0xCA, 0xFE, 0xBA, 0xBE]
|
bc << [0xCA, 0xFE, 0xBA, 0xBE]
|
||||||
println(bc)
|
println(bc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn C.no() // untyped
|
fn C.no() // untyped
|
||||||
fn C.y1(int)
|
fn C.y1(int)
|
||||||
fn C.ret()byte
|
fn C.ret() u8
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
C.no(1) // allowed
|
C.no(1) // allowed
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn main() {
|
||||||
sm := string(mm)
|
sm := string(mm)
|
||||||
println(sm)
|
println(sm)
|
||||||
//
|
//
|
||||||
arr := []byte{}
|
arr := []u8{}
|
||||||
sa := string(arr)
|
sa := string(arr)
|
||||||
println(sa)
|
println(sa)
|
||||||
//
|
//
|
||||||
|
|
|
@ -2,7 +2,7 @@ const size = -1
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
a := [size]int{}
|
a := [size]int{}
|
||||||
b := [0]byte{}
|
b := [0]u8{}
|
||||||
println(a)
|
println(a)
|
||||||
println(b)
|
println(b)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
fn uu8(a byte) {}
|
fn uu8(a u8) {}
|
||||||
|
|
||||||
fn arr(a []int) {}
|
fn arr(a []int) {}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
mut f := fn(i int) byte {}
|
mut f := fn (i int) u8 {}
|
||||||
f = 4
|
f = 4
|
||||||
mut p := &f
|
mut p := &f
|
||||||
p = &[f]
|
p = &[f]
|
||||||
_ = p
|
_ = p
|
||||||
i := 0
|
i := 0
|
||||||
println(i)
|
println(i)
|
||||||
f = fn(mut a []int) { println(i) }
|
f = fn (mut a []int) {
|
||||||
|
println(i)
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
type Int = byte | int
|
type Int = int | u8
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
i := Int(0)
|
i := Int(0)
|
||||||
if mut i is int {
|
if mut i is int {
|
||||||
i = 1
|
i = 1
|
||||||
} else if mut i is byte {
|
} else if mut i is u8 {
|
||||||
i = 2
|
i = 2
|
||||||
}
|
}
|
||||||
println(i)
|
println(i)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
s := ''
|
s := ''
|
||||||
s.len = 123
|
s.len = 123
|
||||||
//
|
//
|
||||||
b := []byte{}
|
b := []u8{}
|
||||||
b.len = 34
|
b.len = 34
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn (d Dog) speak() {}
|
||||||
struct Cat {}
|
struct Cat {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if IoS(1) is byte {
|
if IoS(1) is u8 {
|
||||||
println('not cool')
|
println('not cool')
|
||||||
}
|
}
|
||||||
a := Animal(Dog{})
|
a := Animal(Dog{})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
type Int = byte | int
|
type Int = int | u8
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
i := Int(0)
|
i := Int(0)
|
||||||
|
|
|
@ -2,21 +2,21 @@ module main
|
||||||
|
|
||||||
struct Animal {
|
struct Animal {
|
||||||
mut:
|
mut:
|
||||||
height byte
|
height u8
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_animal(height byte) ?Animal {
|
fn new_animal(height u8) ?Animal {
|
||||||
if height < 10 {
|
if height < 10 {
|
||||||
return error('Too small to be an animal!')
|
return error('Too small to be an animal!')
|
||||||
}
|
}
|
||||||
|
|
||||||
return Animal{ height: height }
|
return Animal{
|
||||||
|
height: height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mut dog := new_animal(9) or {
|
mut dog := new_animal(9) or { none }
|
||||||
none
|
|
||||||
}
|
|
||||||
|
|
||||||
println(dog)
|
println(dog)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn main() {
|
||||||
]
|
]
|
||||||
x := []int{len: 10, cap: 100, init: 1}
|
x := []int{len: 10, cap: 100, init: 1}
|
||||||
_ := expected_flags
|
_ := expected_flags
|
||||||
buf := [100]byte{}
|
buf := [100]u8{}
|
||||||
println(x)
|
println(x)
|
||||||
println(buf)
|
println(buf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub:
|
||||||
f u64
|
f u64
|
||||||
pub mut:
|
pub mut:
|
||||||
g string
|
g string
|
||||||
h byte
|
h u8
|
||||||
}
|
}
|
||||||
|
|
||||||
fn comptime_for() {
|
fn comptime_for() {
|
||||||
|
|
|
@ -18,11 +18,11 @@ fn main() {
|
||||||
// from another .v file
|
// from another .v file
|
||||||
|
|
||||||
struct VerifyKey {
|
struct VerifyKey {
|
||||||
public_key [public_key_size]byte
|
public_key [public_key_size]u8
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SigningKey {
|
struct SigningKey {
|
||||||
secret_key [secret_key_size]byte
|
secret_key [secret_key_size]u8
|
||||||
pub:
|
pub:
|
||||||
verify_key VerifyKey
|
verify_key VerifyKey
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,4 @@ fn proc_pidpath(int, voidptr, int) int
|
||||||
|
|
||||||
fn C.realpath(&char, &char) &char
|
fn C.realpath(&char, &char) &char
|
||||||
|
|
||||||
fn C.chmod(&byte, int) int
|
fn C.chmod(&u8, int) int
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
fn C.PQgetvalue(voidptr, int, int) &byte
|
fn C.PQgetvalue(voidptr, int, int) &u8
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pub interface ReaderWriter {
|
pub interface ReaderWriter {
|
||||||
read(mut buf []byte) ?int // from Reader
|
read(mut buf []u8) ?int // from Reader
|
||||||
write(buf []byte) ?int // from Writer
|
write(buf []u8) ?int // from Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Speaker {
|
interface Speaker {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pub fn str_escaped(b byte) string {
|
pub fn str_escaped(b u8) string {
|
||||||
str := match b {
|
str := match b {
|
||||||
0 { '`\\' + '0`' } // Bug is preventing \\0 in a literal
|
0 { '`\\' + '0`' } // Bug is preventing \\0 in a literal
|
||||||
7 { '`\\a`' }
|
7 { '`\\a`' }
|
||||||
|
|
|
@ -3,7 +3,7 @@ module abcde
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
pub mut:
|
pub mut:
|
||||||
// inline before field
|
// inline before field
|
||||||
buf []byte
|
buf []u8
|
||||||
str_calls int
|
str_calls int
|
||||||
len int
|
len int
|
||||||
initial_size int = 1
|
initial_size int = 1
|
||||||
|
@ -12,7 +12,7 @@ pub mut:
|
||||||
pub fn new_builder(initial_size int) Builder {
|
pub fn new_builder(initial_size int) Builder {
|
||||||
return Builder{
|
return Builder{
|
||||||
// buf: make(0, initial_size)
|
// buf: make(0, initial_size)
|
||||||
buf: []byte{cap: initial_size}
|
buf: []u8{cap: initial_size}
|
||||||
str_calls: 0 // after str_calls
|
str_calls: 0 // after str_calls
|
||||||
len: 0 // after len
|
len: 0 // after len
|
||||||
initial_size: initial_size // final
|
initial_size: initial_size // final
|
||||||
|
|
|
@ -14,7 +14,7 @@ mut:
|
||||||
store &Store = &Store(0)
|
store &Store = &Store(0)
|
||||||
cursor TreeCursor
|
cursor TreeCursor
|
||||||
module_name string
|
module_name string
|
||||||
src_text []byte
|
src_text []u8
|
||||||
// skips the local scopes and registers only
|
// skips the local scopes and registers only
|
||||||
// the top-level ones regardless of its
|
// the top-level ones regardless of its
|
||||||
// visibility
|
// visibility
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
type FooBar = Bar | Foo
|
type FooBar = Bar | Foo
|
||||||
pub type PublicBar = Bar | Foo | FooBar
|
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
|
type Float = f32 | f64
|
||||||
|
|
||||||
// Alias type
|
// Alias type
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
union Un {
|
union Un {
|
||||||
i int
|
i int
|
||||||
b byte
|
b u8
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
struct S1 {
|
struct S1 {
|
||||||
pub mut:
|
pub mut:
|
||||||
v byte
|
v u8
|
||||||
module:
|
module:
|
||||||
i int
|
i int
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ struct S2 {
|
||||||
module:
|
module:
|
||||||
j int
|
j int
|
||||||
mut:
|
mut:
|
||||||
v byte
|
v u8
|
||||||
}
|
}
|
||||||
|
|
||||||
mut s := S1{}
|
mut s := S1{}
|
||||||
|
|
|
@ -37,7 +37,7 @@ fn dump_of_callexpr() {
|
||||||
vfile := @FILE
|
vfile := @FILE
|
||||||
dump(os.file_name(vfile))
|
dump(os.file_name(vfile))
|
||||||
mut f := os.open_file(@FILE, 'r') or { return }
|
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 })
|
dump(f.read(mut buf) or { -999 })
|
||||||
f.close()
|
f.close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
type Byte = byte
|
type Byte = u8
|
||||||
|
|
||||||
fn (b Byte) str() string {
|
fn (b Byte) str() string {
|
||||||
return 'hello'
|
return 'hello'
|
||||||
|
|
Loading…
Reference in New Issue