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

pull/8474/head
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
1 changed files with 14 additions and 0 deletions

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
}