1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Allowing both end-points of slices to be implicit.

This commit is contained in:
clutchski 2011-12-20 19:21:26 -05:00
parent 0f1dbffa40
commit 2e06316e31
4 changed files with 151 additions and 225 deletions

View file

@ -291,6 +291,8 @@
return new Range($1, null, $2);
}), o('RangeDots Expression', function() {
return new Range(null, $2, $1);
}), o('RangeDots', function() {
return new Range(null, null, $1);
})
],
ArgList: [

File diff suppressed because one or more lines are too long

View file

@ -343,6 +343,7 @@ grammar =
o 'Expression RangeDots Expression', -> new Range $1, $3, $2
o 'Expression RangeDots', -> new Range $1, null, $2
o 'RangeDots Expression', -> new Range null, $2, $1
o 'RangeDots', -> new Range null, null, $1
]
# The **ArgList** is both the list of objects passed into a function call,

View file

@ -39,6 +39,8 @@ test "unbounded slicing", ->
for a in [-shared.length+1...shared.length]
arrayEq shared[..a][...-1] , shared[...a]
arrayEq [1, 2, 3], [1, 2, 3][..]
test "#930, #835, #831, #746 #624: inclusive slices to -1 should slice to end", ->
arrayEq shared, shared[0..-1]
arrayEq shared, shared[..-1]
@ -79,6 +81,9 @@ test "unbounded splicing", ->
ary[...3] = [7, 8, 9]
arrayEq [7, 8, 9, 9, 8, 7], ary
ary[..] = [1, 2, 3]
arrayEq [1, 2, 3], ary
test "splicing with variables as endpoints", ->
[a, b] = [1, 8]