correct spacing around operators in slice output

This commit is contained in:
Michael Ficarra 2012-05-20 16:32:10 -04:00
parent b8149812cd
commit 972a5299d5
5 changed files with 6 additions and 6 deletions

View File

@ -535,7 +535,7 @@
case end:
stack.pop();
if (!stack.length) {
return str.slice(0, +i+1 || 9e9);
return str.slice(0, +i + 1 || 9e9);
}
end = stack[stack.length - 1];
continue;

View File

@ -1151,7 +1151,7 @@
fromStr = from && from.compile(o, LEVEL_PAREN) || '0';
compiled = to && to.compile(o, LEVEL_PAREN);
if (to && !(!this.range.exclusive && +compiled === -1)) {
toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "+" + compiled + "+1 || 9e9"));
toStr = ', ' + (this.range.exclusive ? compiled : SIMPLENUM.test(compiled) ? "" + (+compiled + 1) : (compiled = to.compile(o, LEVEL_ACCESS), "+" + compiled + " + 1 || 9e9"));
}
return ".slice(" + fromStr + (toStr || '') + ")";
};

View File

@ -121,7 +121,7 @@
startIndex = 0;
condition = function(token, i) {
var one, tag, three, two, _ref, _ref1;
_ref = this.tokens.slice(i + 1, +(i + 3)+1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
_ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
return false;
}
@ -196,7 +196,7 @@
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
noCall = true;
}
_ref = tokens.slice(i - 1, +(i + 1)+1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
_ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
seenSingle = false;
seenControl = false;

View File

@ -787,7 +787,7 @@ exports.Slice = class Slice extends Base
"#{+compiled + 1}"
else
compiled = to.compile o, LEVEL_ACCESS
"+#{compiled}+1 || 9e9"
"+#{compiled} + 1 || 9e9"
".slice(#{ fromStr }#{ toStr or '' })"
#### Obj

View File

@ -61,7 +61,7 @@ test "#1722: operator precedence in unbounded slice compilation", ->
arrayEq [0..n], list[..n or 0]
arrayEq [0..n], list[..if n then n else 0]
test "#2349: slicing to numeric strings", ->
test "#2349: inclusive slicing to numeric strings", ->
arrayEq [0, 1], [0..10][.."1"]