Add List.extend and List.to_list, plus some more tests

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-09-30 19:53:31 -07:00
parent a370d3a56f
commit a7d7d8e564
4 changed files with 110 additions and 4 deletions

51
tests/list.npp Normal file
View File

@@ -0,0 +1,51 @@
# List type operator and function tests
a = []
println("to_str")
println(a.to_str())
println([1, 2, 3])
println(["a", "b", "c"])
println(["a\nb\nc"])
println("push and pop")
a.push(1234)
a.push(56)
println(a)
println(a.pop())
println(a)
a.push(99)
a.push(100)
println(a)
a.pop()
a.pop()
a.push('99')
a.push('100')
println(a)
println("len")
println(a.len())
a.pop()
println(a.len())
a.pop()
println(a.len())
a.pop()
println(a.len())
println("extend")
a.extend([1, 2, 3])
println(a)
a.extend([1, 2, 3])
println(a)
a.extend(['a', 's', 'd', 'f'])
println(a)
println("constructor")
println(List("asdf"))
println(List([1, 2, 3]))
# ensure that creating a new list actually clones it
b = [1, 2, 3]
c = List(b)
c.pop()
println(b)
println(c)