mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
array: map() test
This commit is contained in:
parent
4ef10c92f4
commit
f40d672a12
@ -356,6 +356,7 @@ fn test_reduce() {
|
|||||||
fn test_filter() {
|
fn test_filter() {
|
||||||
a := [1, 2, 3, 4, 5, 6]
|
a := [1, 2, 3, 4, 5, 6]
|
||||||
b := a.filter(it % 2 == 0)
|
b := a.filter(it % 2 == 0)
|
||||||
|
assert b.len == 3
|
||||||
assert b[0] == 2
|
assert b[0] == 2
|
||||||
assert b[1] == 4
|
assert b[1] == 4
|
||||||
assert b[2] == 6
|
assert b[2] == 6
|
||||||
@ -365,6 +366,20 @@ fn test_filter() {
|
|||||||
assert d[1] == 'awesome'
|
assert d[1] == 'awesome'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_map() {
|
||||||
|
a := [1, 2, 3, 4, 5, 6]
|
||||||
|
b := a.map(it * 10)
|
||||||
|
assert b.len == 6
|
||||||
|
assert b[0] == 10
|
||||||
|
assert b[1] == 20
|
||||||
|
assert b[2] == 30
|
||||||
|
c := ['v', 'is', 'awesome']
|
||||||
|
d := c.map(it.to_upper())
|
||||||
|
assert d[0] == 'V'
|
||||||
|
assert d[1] == 'IS'
|
||||||
|
assert d[2] == 'AWESOME'
|
||||||
|
}
|
||||||
|
|
||||||
fn test_array_str() {
|
fn test_array_str() {
|
||||||
numbers := [1, 2, 3]
|
numbers := [1, 2, 3]
|
||||||
numbers2 := [numbers, [4, 5, 6]] // dup str() bug
|
numbers2 := [numbers, [4, 5, 6]] // dup str() bug
|
||||||
|
Loading…
Reference in New Issue
Block a user