mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
compiler: add [..2]
& [2..]
support for slices
This commit is contained in:
parent
e80cf185b9
commit
a075ce160e
6 changed files with 47 additions and 10 deletions
|
@ -118,10 +118,13 @@ fn test_right() {
|
|||
a := [1, 2, 3, 4]
|
||||
b := a.right(1)
|
||||
c := a[1..a.len]
|
||||
d := a[1..]
|
||||
assert b[0] == 2
|
||||
assert b[1] == 3
|
||||
assert c[0] == 2
|
||||
assert c[1] == 3
|
||||
assert d[0] == 2
|
||||
assert d[1] == 3
|
||||
}
|
||||
|
||||
fn test_right_with_n_bigger_than_array_size() {
|
||||
|
@ -142,10 +145,13 @@ fn test_left() {
|
|||
a := [1, 2, 3]
|
||||
b := a.left(2)
|
||||
c := a[0..2]
|
||||
d := a[..2]
|
||||
assert b[0] == 1
|
||||
assert b[1] == 2
|
||||
assert c[0] == 1
|
||||
assert c[1] == 2
|
||||
assert d[0] == 1
|
||||
assert d[1] == 2
|
||||
}
|
||||
|
||||
fn test_slice() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue