fixing an off-by-one error in Splat compilation

This commit is contained in:
Jeremy Ashkenas 2010-02-20 18:25:36 -05:00
parent 2d3f6b80c1
commit a93229b14d
3 changed files with 15 additions and 3 deletions

View File

@ -376,7 +376,7 @@
}
}
this.last = parts[parts.length - 1];
this.source = parts.length > 1 ? parts.slice(0, parts.length).join('') : null;
this.source = parts.length > 1 ? parts.slice(0, (parts.length - 1)).join('') : null;
code = parts.join('').replace(/\)\(\)\)/, '()))');
if (!(soaked)) {
return code;

View File

@ -283,7 +283,7 @@ ValueNode: exports.ValueNode: inherit Node, {
parts.push(part)
@last: parts[parts.length - 1]
@source: if parts.length > 1 then parts[0...parts.length].join('') else null
@source: if parts.length > 1 then parts[0...(parts.length - 1)].join('') else null
code: parts.join('').replace(/\)\(\)\)/, '()))')
return code unless soaked
'(' + code + ')'

View File

@ -32,4 +32,16 @@ medalists "Mighty Mouse", contenders...
ok gold is "Mighty Mouse"
ok silver is "Michael Phelps"
ok bronze is "Liu Xiang"
ok the_field.length is 8
ok the_field.length is 8
obj: {
name: 'bob'
accessor: (args...) ->
[@name].concat(args).join(' ')
getNames: ->
args: ['jane', 'ted']
@accessor(args...)
}
ok obj.getNames() is 'bob jane ted'