compiler: add [..2] & [2..] support for slices

This commit is contained in:
joe-conigliaro 2019-10-27 17:36:04 +11:00 committed by Alexander Medvednikov
parent e80cf185b9
commit a075ce160e
6 changed files with 47 additions and 10 deletions

View file

@ -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() {