Reorganize trailing comma code a bit.
- Split out syntax error tests. - Avoid redundant handling of empty literals.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
[1,,2] // expect error
|
||||
@@ -0,0 +1 @@
|
||||
[1,,] // expect error
|
||||
@@ -0,0 +1 @@
|
||||
[,] // expect error
|
||||
@@ -8,3 +8,17 @@ var list = [
|
||||
|
||||
IO.print(list[0]) // expect: a
|
||||
IO.print(list[1]) // expect: b
|
||||
|
||||
// Newline after trailing comma.
|
||||
list = ["c",
|
||||
|
||||
]
|
||||
|
||||
IO.print(list[0]) // expect: c
|
||||
|
||||
// Newline in empty list.
|
||||
list = [
|
||||
|
||||
]
|
||||
|
||||
IO.print(list.count) // expect: 0
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
var list = [
|
||||
"a",
|
||||
"b",
|
||||
]
|
||||
var list = ["a", "b",]
|
||||
|
||||
IO.print(list[0]) // expect: a
|
||||
IO.print(list[1]) // expect: b
|
||||
|
||||
// Invalid syntax
|
||||
IO.print(new Fiber { Meta.eval("[,]") }.try()) // expect: Could not compile source code.
|
||||
IO.print(new Fiber { Meta.eval("[1,,]") }.try()) // expect: Could not compile source code.
|
||||
IO.print(new Fiber { Meta.eval("[1,,2]") }.try()) // expect: Could not compile source code.
|
||||
|
||||
Reference in New Issue
Block a user