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

fix tests

This commit is contained in:
S-YOU 2019-06-27 02:03:35 +09:00 committed by Alexander Medvednikov
parent 2ca6859982
commit d998313bb1
6 changed files with 9 additions and 7 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.dSYM *.dSYM
*_test

View File

@ -14,7 +14,7 @@ const (
47, 48, 49, 50, 51] 47, 48, 49, 50, 51]
) )
fn decode(data string) string { pub fn decode(data string) string {
p := data.cstr() p := data.cstr()
len := data.len len := data.len
mut pad := 0 mut pad := 0
@ -25,7 +25,7 @@ fn decode(data string) string {
str_len := L / 4 * 3 + pad str_len := L / 4 * 3 + pad
mut str := malloc(str_len + 2) mut str := malloc(str_len + 2)
mut j := 0 mut j := 0
for i := 0; i < L; i += 4 { for i := 0; i < L; i = i+4 {
n := (Index[p[i]] << 18) | (Index[p[i + 1]] << 12) | n := (Index[p[i]] << 18) | (Index[p[i + 1]] << 12) |
(Index[p[i + 2]] << 6) | (Index[p[i + 3]]) (Index[p[i + 2]] << 6) | (Index[p[i + 3]])
str[j] = n >> 16 str[j] = n >> 16
@ -44,7 +44,7 @@ fn decode(data string) string {
} }
} }
str[str_len + 1] = `\0` str[str_len + 1] = `\0`
return tos(str, str_len+2) return tos(str, str_len+1)
} }
const ( const (

View File

@ -143,7 +143,7 @@ fn (s string) int() int {
} }
fn (s string) f32() f32 { fn (s string) f32() f32 {
return C.atof(s.str) return C.atof(s.str)
} }
// == // ==
@ -332,7 +332,7 @@ pub fn (s string) right(n int) string {
// puts(substr.str) will print 'rivet' // puts(substr.str) will print 'rivet'
// Avoid using C functions with these substrs! // Avoid using C functions with these substrs!
pub fn (s string) substr(start, end int) string { pub fn (s string) substr(start, end int) string {
/* /*
if start > end || start >= s.len || end > s.len || start < 0 || end < 0 { if start > end || start >= s.len || end > s.len || start < 0 || end < 0 {
panic('substr($start, $end) out of bounds (len=$s.len)') panic('substr($start, $end) out of bounds (len=$s.len)')
return '' return ''

View File

@ -289,4 +289,5 @@ fn test_all_after() {
s := 'fn hello' s := 'fn hello'
q := s.all_after('fn ') q := s.all_after('fn ')
assert q == 'hello' assert q == 'hello'
}

View File

@ -8,7 +8,7 @@ v.c:
curl -Os https://raw.githubusercontent.com/vlang/vc/master/v.c curl -Os https://raw.githubusercontent.com/vlang/vc/master/v.c
test: v test: v
find .. -name '*_test.v' | xargs ./v {} find .. -name '*_test.v' -print0 | xargs -0 -n1 ./v
clean: clean:
-rm -f v.c v -rm -f v.c v

View File

@ -33,7 +33,7 @@ struct Vec3 {
z f32 z f32
} }
fn vec3(x, y, z f32) Vec3 { pub fn vec3(x, y, z f32) Vec3 {
res := Vec3 { res := Vec3 {
x: x, x: x,
y: y, y: y,