Fix #5201: allow leading breaking elision (#5202)

* allow simple breaking elision

* add tests

* use OptComma

* more tests

* trigger CI
This commit is contained in:
Julian Rosse 2019-04-22 13:21:37 -04:00 committed by Geoffrey Booth
parent ca0ac814b3
commit 0574b664e8
4 changed files with 144 additions and 92 deletions

View File

@ -1118,10 +1118,9 @@
function() {
return $1.concat($3);
}),
o('ArgElisionList OptElisions TERMINATOR ArgElision',
o('ArgElisionList OptComma TERMINATOR ArgElision',
function() {
return $1.concat($2,
$4);
return $1.concat($4);
}),
o('INDENT ArgElisionList OptElisions OUTDENT',
function() {
@ -1168,6 +1167,10 @@
o(',',
function() {
return new Elision;
}),
o('Elision TERMINATOR',
function() {
return $1;
})
],
// Just simple, comma-separated, required arguments (no fancy syntax). We need

File diff suppressed because one or more lines are too long

View File

@ -564,7 +564,7 @@ grammar =
ArgElisionList: [
o 'ArgElision'
o 'ArgElisionList , ArgElision', -> $1.concat $3
o 'ArgElisionList OptElisions TERMINATOR ArgElision', -> $1.concat $2, $4
o 'ArgElisionList OptComma TERMINATOR ArgElision', -> $1.concat $4
o 'INDENT ArgElisionList OptElisions OUTDENT', -> $2.concat $3
o 'ArgElisionList OptElisions INDENT ArgElisionList OptElisions OUTDENT', -> $1.concat $2, $4, $5
]
@ -586,6 +586,7 @@ grammar =
Elision: [
o ',', -> new Elision
o 'Elision TERMINATOR', -> $1
]
# Just simple, comma-separated, required arguments (no fancy syntax). We need

View File

@ -293,3 +293,52 @@ test "for-from comprehensions over Array", ->
array2 = (a + b for [a, b] from [[10, 20], [30, 40], [50, 60]] when a + b >= 70)
ok array2.join(' ') is '70 110'
test "#5201: simple indented elisions", ->
arr1 = [
,
1,
2,
,
,
3,
4,
5,
6
,
,
8,
9,
]
eq arr1.length, 12
eq arr1[5], 3
eq arr1[9], undefined
arr2 = [
,
,
1,
2,
,
3,
,
4,
5
6
,
,
,
]
eq arr2.length, 12
eq arr2[8], 5
eq arr2[1], undefined
arr3 = [
,
,
,
]
eq arr3.length, 3
arr4 = [, , ,]
eq arr4.length, 3