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

gen: fix arr.last().field (#7076)

This commit is contained in:
Enzo
2020-12-02 04:35:00 +01:00
committed by GitHub
parent ff26f0539c
commit d8b8aca51e
2 changed files with 27 additions and 1 deletions

View File

@ -1002,6 +1002,27 @@ fn test_array_string_pop() {
assert a.cap == 3
}
fn test_array_first() {
a := [3]
assert a.first() == 3
b := [1, 2, 3, 4]
assert b.first() == 1
c := ['abc', 'def']
assert c.first()[0] == `a`
s := [Chunk{'a'}]
assert s.first().val == 'a'
}
fn test_array_last() {
a := [3]
assert a.last() == 3
b := [1, 2, 3, 4]
assert b.last() == 4
c := ['abc', 'def']
assert c.last()[0] == `d`
s := [Chunk{'a'}]
assert s.last().val == 'a'
}
[direct_array_access]
fn test_direct_array_access() {