Reorganize tests.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
var a = []
|
||||
a.add(1)
|
||||
io.write(a) // expect: [1]
|
||||
a.add(2)
|
||||
io.write(a) // expect: [1, 2]
|
||||
a.add(3)
|
||||
io.write(a) // expect: [1, 2, 3]
|
||||
|
||||
// Returns added element.
|
||||
io.write(a.add(4)) // expect: 4
|
||||
@@ -0,0 +1,7 @@
|
||||
io.write([].count) // expect: 0
|
||||
io.write([1].count) // expect: 1
|
||||
io.write([1, 2, 3, 4].count) // expect: 4
|
||||
|
||||
// TODO(bob): Literal syntax, including newline handling.
|
||||
// TODO(bob): Unterminated list literal.
|
||||
// TODO(bob): Subscript operator.
|
||||
@@ -0,0 +1,25 @@
|
||||
// Returns elements.
|
||||
var list = ["a", "b", "c", "d"]
|
||||
io.write(list[0]) // expect: a
|
||||
io.write(list[1]) // expect: b
|
||||
io.write(list[2]) // expect: c
|
||||
io.write(list[3]) // expect: d
|
||||
|
||||
// Allows indexing backwards from the end.
|
||||
io.write(list[-4]) // expect: a
|
||||
io.write(list[-3]) // expect: b
|
||||
io.write(list[-2]) // expect: c
|
||||
io.write(list[-1]) // expect: d
|
||||
|
||||
// Handle out of bounds.
|
||||
// TODO(bob): Should halt the fiber or raise an error somehow.
|
||||
io.write(list[4]) // expect: null
|
||||
io.write(list[-5]) // expect: null
|
||||
|
||||
// Handle wrong argument type.
|
||||
// TODO(bob): Should halt the fiber or raise an error somehow.
|
||||
io.write(list[true]) // expect: null
|
||||
|
||||
// Handle non-integer index.
|
||||
// TODO(bob): Should halt the fiber or raise an error somehow.
|
||||
io.write(list[1.5]) // expect: null
|
||||
@@ -0,0 +1,4 @@
|
||||
io.write([] is List) // expect: true
|
||||
io.write([] is Object) // expect: true
|
||||
io.write([] is Bool) // expect: false
|
||||
io.write([].type == List) // expect: true
|
||||
Reference in New Issue
Block a user