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

v test-cleancode: ensure more .v files are kept vmft-ed

This commit is contained in:
Delyan Angelov 2021-03-14 12:17:31 +02:00
parent eebc8a9d7a
commit ddbe57e00a
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 24 additions and 20 deletions

View File

@ -27,6 +27,8 @@ const (
'vlib/builtin/array_test.v', 'vlib/builtin/array_test.v',
'vlib/builtin/string.v', 'vlib/builtin/string.v',
'vlib/builtin/map.v', 'vlib/builtin/map.v',
'vlib/builtin/int.v',
'vlib/builtin/option.v',
'vlib/math/bits/bits.v', 'vlib/math/bits/bits.v',
'vlib/orm/', 'vlib/orm/',
'vlib/term/colors.v', 'vlib/term/colors.v',
@ -42,17 +44,17 @@ const (
'vlib/v/eval/', 'vlib/v/eval/',
'vlib/v/fmt/', 'vlib/v/fmt/',
'vlib/v/gen/c/', 'vlib/v/gen/c/',
/* 'vlib/v/gen/js/', */ //'vlib/v/gen/js/',
'vlib/v/gen/x64/', 'vlib/v/gen/x64/',
'vlib/v/live/', 'vlib/v/live/',
'vlib/v/markused/', 'vlib/v/markused/',
'vlib/v/parser/', 'vlib/v/parser/',
/* 'vlib/v/pkgconfig/', */ 'vlib/v/pkgconfig/',
'vlib/v/pref/', 'vlib/v/pref/',
'vlib/v/preludes', 'vlib/v/preludes',
'vlib/v/scanner/', 'vlib/v/scanner/',
'vlib/v/table/', 'vlib/v/table/',
/* 'vlib/v/tests/', */ //'vlib/v/tests/',
'vlib/v/token/', 'vlib/v/token/',
'vlib/v/util/', 'vlib/v/util/',
'vlib/v/vcache/', 'vlib/v/vcache/',

View File

@ -65,7 +65,7 @@ fn (nn int) str_l(max int) string {
if n == 0 { if n == 0 {
return '0' return '0'
} }
mut buf := unsafe {malloc(max + 1)} mut buf := unsafe { malloc(max + 1) }
mut is_neg := false mut is_neg := false
if n < 0 { if n < 0 {
n = -n n = -n
@ -136,7 +136,7 @@ pub fn (nn u32) str() string {
return '0' return '0'
} }
max := 12 max := 12
mut buf := unsafe {malloc(max + 1)} mut buf := unsafe { malloc(max + 1) }
mut index := max mut index := max
unsafe { unsafe {
buf[index--] = `\0` buf[index--] = `\0`
@ -283,7 +283,7 @@ fn u64_to_hex(nn u64, len byte) string {
n = n >> 4 n = n >> 4
} }
return string{ return string{
str: unsafe {memdup(buf, len + 1)} str: unsafe { memdup(buf, len + 1) }
len: len len: len
} }
} }
@ -306,7 +306,7 @@ fn u64_to_hex_no_leading_zeros(nn u64, len byte) string {
} }
res_len := len - i res_len := len - i
return string{ return string{
str: unsafe {memdup(&buf[i], res_len + 1)} str: unsafe { memdup(&buf[i], res_len + 1) }
len: res_len len: res_len
} }
} }
@ -448,7 +448,7 @@ pub fn (b byte) str() string {
// Example: assert byte(97).ascii_str() == 'a' // Example: assert byte(97).ascii_str() == 'a'
pub fn (b byte) ascii_str() string { pub fn (b byte) ascii_str() string {
mut str := string{ mut str := string{
str: unsafe {malloc(2)} str: unsafe { malloc(2) }
len: 1 len: 1
} }
unsafe { unsafe {

View File

@ -5,7 +5,7 @@ module builtin
// IError holds information about an error instance // IError holds information about an error instance
pub interface IError { pub interface IError {
msg string msg string
code int code int
} }
@ -23,7 +23,9 @@ struct None__ {
code int code int
} }
fn (_ None__) str() string { return 'none' } fn (_ None__) str() string {
return 'none'
}
// error returns a default error instance containing the error given in `message`. // error returns a default error instance containing the error given in `message`.
// Example: `if ouch { return error('an error occurred') }` // Example: `if ouch { return error('an error occurred') }`
@ -38,7 +40,7 @@ pub fn error(message string) IError {
// `if ouch { return error_with_code('an error occurred', 1) }` // `if ouch { return error_with_code('an error occurred', 1) }`
[inline] [inline]
pub fn error_with_code(message string, code int) IError { pub fn error_with_code(message string, code int) IError {
return &Error { return &Error{
msg: message msg: message
code: code code: code
} }

View File

@ -1,5 +1,5 @@
import os import os
import pkgconfig import v.pkgconfig
const vexe = os.getenv('VEXE') const vexe = os.getenv('VEXE')
@ -49,12 +49,11 @@ fn test_samples() {
assert x.url == '' assert x.url == ''
assert x.version == '2.64.3' assert x.version == '2.64.3'
assert x.description == 'Dynamic module loader for GLib' assert x.description == 'Dynamic module loader for GLib'
assert x.libs == assert x.libs == ['-Wl,--export-dynamic', '-L/usr/lib/x86_64-linux-gnu', '-lgmodule-2.0',
['-Wl,--export-dynamic', '-L/usr/lib/x86_64-linux-gnu', '-lgmodule-2.0', '-pthread', '-lglib-2.0', '-lpcre'] '-pthread', '-lglib-2.0', '-lpcre']
assert x.libs_private == ['-ldl', '-pthread'] assert x.libs_private == ['-ldl', '-pthread']
assert x.cflags == assert x.cflags == ['-I/usr/include', '-pthread', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include']
['-I/usr/include', '-pthread', '-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include'] assert x.vars == map{
assert x.vars == {
'prefix': '/usr' 'prefix': '/usr'
'libdir': '/usr/lib/x86_64-linux-gnu' 'libdir': '/usr/lib/x86_64-linux-gnu'
'includedir': '/usr/include' 'includedir': '/usr/include'
@ -71,9 +70,10 @@ fn test_samples() {
assert x.modname == 'glib-2.0' assert x.modname == 'glib-2.0'
assert x.libs == ['-L/usr/lib/x86_64-linux-gnu', '-lglib-2.0', '-lpcre'] assert x.libs == ['-L/usr/lib/x86_64-linux-gnu', '-lglib-2.0', '-lpcre']
assert x.libs_private == ['-pthread'] assert x.libs_private == ['-pthread']
assert x.cflags == assert x.cflags == ['-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include',
['-I/usr/include/glib-2.0', '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include', '-I/usr/include'] '-I/usr/include',
assert x.vars == { ]
assert x.vars == map{
'prefix': '/usr' 'prefix': '/usr'
'libdir': '/usr/lib/x86_64-linux-gnu' 'libdir': '/usr/lib/x86_64-linux-gnu'
'includedir': '/usr/include' 'includedir': '/usr/include'