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

cgen: fix arr.insert(0, [1,2,3]) and arr.prepend([1,2,3])

This commit is contained in:
yuyi
2020-06-18 18:08:11 +08:00
committed by GitHub
parent b806fff90a
commit 930c3d73c1
3 changed files with 81 additions and 28 deletions

View File

@@ -134,6 +134,15 @@ fn test_insert() {
assert b[0] == f64(1.1)
}
fn test_insert_many() {
mut a := [3, 4]
a.insert(0, [1, 2])
assert a == [1,2,3,4]
b := [5,6]
a.insert(1, b)
assert a == [1,5,6,2,3,4]
}
fn test_prepend() {
mut a := []int{}
assert a.len == 0
@@ -147,6 +156,15 @@ fn test_prepend() {
assert b[0] == f64(1.1)
}
fn test_prepend_many() {
mut a := [3,4]
a.prepend([1,2])
assert a == [1,2,3,4]
b := [5,6]
a.prepend(b)
assert a == [5,6,1,2,3,4]
}
fn test_strings() {
a := ['a', 'b', 'c']
assert a.str() == "['a', 'b', 'c']"
@@ -166,7 +184,6 @@ fn test_compare_ints() {
}
*/
fn test_repeat() {
{
a := [0].repeat(5)