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

tests: add regression tests for typeof map and array of fns (#8458)

This commit is contained in:
Ruofan XU 2021-01-31 18:20:15 +08:00 committed by GitHub
parent 09c65163b4
commit ae60ea4ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,3 +57,17 @@ fn test_map_with_fns() {
assert func('ccccccc', '') == 27 assert func('ccccccc', '') == 27
} }
} }
fn foo3(a string) int {
return 10 + a.len
}
fn test_map_and_array_with_fns_typeof_and_direct_call() {
a := [foo3]
assert typeof(a).name == '[]fn (string) int'
assert a[0]('hello') == 15
b := {'one': foo3}
assert typeof(b).name == 'map[string]fn (string) int'
// TODO: enable this
// assert b['one']('hi') == 12
}