mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix array.filter(anon_fn)
This commit is contained in:
@ -529,6 +529,21 @@ fn test_filter() {
|
||||
//assert arr.filter(arr % 2).len == 5
|
||||
}
|
||||
|
||||
fn test_anon_fn_filter() {
|
||||
filter_num := fn (i int) bool {
|
||||
return i % 2 == 0
|
||||
}
|
||||
assert [1,2,3,4,5].filter(filter_num) == [2,4]
|
||||
}
|
||||
|
||||
fn test_anon_fn_arg_filter() {
|
||||
a := [1,2,3,4].filter(fn (i int) bool {
|
||||
return i % 2 == 0
|
||||
})
|
||||
|
||||
assert a == [2,4]
|
||||
}
|
||||
|
||||
fn map_test_helper_1(i int) int {
|
||||
return i * i
|
||||
}
|
||||
|
Reference in New Issue
Block a user