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

some more tests

This commit is contained in:
Alexander Medvednikov 2019-06-27 14:28:12 +02:00
parent 8c4f7749df
commit 959cc2ea03
3 changed files with 64 additions and 1 deletions

View File

@ -493,7 +493,6 @@ fn (p mut Parser) async_fn_call(f Fn, method_ph int, receiver_var, receiver_type
}
fn (p mut Parser) fn_call(f Fn, method_ph int, receiver_var, receiver_type string) {
//if !f.is_public && !f.is_c && f.pkg != p.pkg && f.pkg != 'builtin' {
if !f.is_public && !f.is_c && !p.is_test && f.pkg != p.pkg {
p.error('function `$f.name` is private')
}

21
json/json_test.v Normal file
View File

@ -0,0 +1,21 @@
import json
struct User {
age int
nums []int
}
fn test_parse_user() {
s := '{"age": 10, "nums": [1,2,3]}'
u := json.decode(User, s) or {
exit(1)
return
}
assert u.age == 10
assert u.nums.len == 3
assert u.nums[0] == 1
assert u.nums[1] == 2
assert u.nums[2] == 3
}

43
tests/fn_test.v Normal file
View File

@ -0,0 +1,43 @@
type myfn fn (int) string
type myfn2 fn (a int, b int) int
type myfn3 fn (int, int)
fn myfn4(string)
fn foobar()
fn slopediv(num u32, den u32) int
type f1 fn ()
type f2 fn (voidptr)
type f3 fn (voidptr, voidptr)
type f4 fn (voidptr) int
type f5 fn (int, int) int
type f6 fn (int, int)
fn C.atoi(byteptr) int
fn foo() {
}
type actionf_v fn ()
type actionf_p1 fn (voidptr)
type actionf_p2 fn (voidptr, voidptr)
fn myprint(s string, ..) {
println('my print')
}
fn test_fns() {
// no asserts for now, just test function declarations above
}