1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tests: fix some tests

This commit is contained in:
Alexander Medvednikov 2020-07-24 01:55:55 +02:00
parent d2675b89c0
commit ec443c65a8
3 changed files with 26 additions and 26 deletions

View File

@ -67,7 +67,7 @@ pub fn (mut d Digest) write(p_ []byte) int {
n := copy(d.x[d.nx..], p)
d.nx += n
if d.nx == chunk {
block(d, d.x)
block(mut d, d.x)
d.nx = 0
}
if n >= p.len {
@ -78,7 +78,7 @@ pub fn (mut d Digest) write(p_ []byte) int {
}
if p.len >= chunk {
n := p.len &~ (chunk - 1)
block(d, p[..n])
block(mut d, p[..n])
if n >= p.len {
p = []
} else {
@ -138,7 +138,7 @@ pub fn sum(data []byte) []byte {
return d.checksum()
}
fn block(dig &Digest, p []byte) {
fn block(mut dig Digest, p []byte) {
// For now just use block_generic until we have specific
// architecture optimized versions
block_generic(mut dig, p)

View File

@ -18,7 +18,7 @@ fn init() {
// new_default returns a new instance of the default RNG. If the seed is not provided, the current time will be used to seed the instance.
pub fn new_default(config PRNGConfigStruct) &wyrand.WyRandRNG {
rng := &wyrand.WyRandRNG{}
mut rng := &wyrand.WyRandRNG{}
rng.seed(config.seed)
return rng
}

View File

@ -10,7 +10,7 @@ const (
)
fn test_parse_valid_cflags() {
t := table.new_table()
mut t := table.new_table()
expected_flags := [
make_flag('freebsd', '-I', '/usr/local/include/freetype2'),
make_flag('linux', '-l', 'glfw'),
@ -21,14 +21,14 @@ fn test_parse_valid_cflags() {
make_flag(no_os, '-l', 'mysqlclient'),
make_flag(no_os, no_name, '-test')
]
parse_valid_flag(t, '-lmysqlclient')
parse_valid_flag(t, '-test')
parse_valid_flag(t, 'darwin -framework Cocoa')
parse_valid_flag(t, 'freebsd -I/usr/local/include/freetype2')
parse_valid_flag(t, 'linux -lglfw')
parse_valid_flag(t, 'mingw -mwindows')
parse_valid_flag(t, 'solaris -L/opt/local/lib')
parse_valid_flag(t, 'windows -lgdi32')
parse_valid_flag(mut t, '-lmysqlclient')
parse_valid_flag(mut t, '-test')
parse_valid_flag(mut t, 'darwin -framework Cocoa')
parse_valid_flag(mut t, 'freebsd -I/usr/local/include/freetype2')
parse_valid_flag(mut t, 'linux -lglfw')
parse_valid_flag(mut t, 'mingw -mwindows')
parse_valid_flag(mut t, 'solaris -L/opt/local/lib')
parse_valid_flag(mut t, 'windows -lgdi32')
assert t.cflags.len == expected_flags.len
for f in expected_flags {
assert t.has_cflag(f)
@ -36,29 +36,29 @@ fn test_parse_valid_cflags() {
}
fn test_parse_invalid_cflags() {
t := table.new_table()
mut t := table.new_table()
// -I, -L, -l must have values
assert_parse_invalid_flag(t, 'windows -l')
assert_parse_invalid_flag(t, '-I')
assert_parse_invalid_flag(t, '-L')
assert_parse_invalid_flag(mut t, 'windows -l')
assert_parse_invalid_flag(mut t, '-I')
assert_parse_invalid_flag(mut t, '-L')
// OS/compiler name only is not allowed
assert_parse_invalid_flag(t, 'darwin')
assert_parse_invalid_flag(t, 'freebsd')
assert_parse_invalid_flag(t, 'linux')
assert_parse_invalid_flag(t, 'mingw')
assert_parse_invalid_flag(t, 'solaris')
assert_parse_invalid_flag(t, 'windows')
assert_parse_invalid_flag(mut t, 'darwin')
assert_parse_invalid_flag(mut t, 'freebsd')
assert_parse_invalid_flag(mut t, 'linux')
assert_parse_invalid_flag(mut t, 'mingw')
assert_parse_invalid_flag(mut t, 'solaris')
assert_parse_invalid_flag(mut t, 'windows')
// Empty flag is not allowed
assert_parse_invalid_flag(t, no_flag)
assert_parse_invalid_flag(mut t, no_flag)
assert t.cflags.len == 0
}
fn parse_valid_flag(t &table.Table, flag string) {
fn parse_valid_flag(mut t table.Table, flag string) {
t.parse_cflag(flag, module_name, cdefines) or {
}
}
fn assert_parse_invalid_flag(t &table.Table, flag string) {
fn assert_parse_invalid_flag(mut t table.Table, flag string) {
t.parse_cflag(flag, module_name, cdefines) or {
return
}