mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
adding an if/else/chain test
This commit is contained in:
@@ -202,7 +202,7 @@
|
|||||||
this.i += indent.length;
|
this.i += indent.length;
|
||||||
next_character = this.chunk.match(MULTI_DENT)[4];
|
next_character = this.chunk.match(MULTI_DENT)[4];
|
||||||
prev = this.tokens[this.tokens.length - 2];
|
prev = this.tokens[this.tokens.length - 2];
|
||||||
no_newlines = next_character === '.' || (this.value().match(NO_NEWLINE) && prev && (prev[0] !== '.') && !this.value().match(CODE));
|
no_newlines = next_character === '.' || (this.value() && this.value().match(NO_NEWLINE) && prev && (prev[0] !== '.') && !this.value().match(CODE));
|
||||||
if (no_newlines) {
|
if (no_newlines) {
|
||||||
return this.suppress_newlines(indent);
|
return this.suppress_newlines(indent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ lex::indent_token: ->
|
|||||||
@i += indent.length
|
@i += indent.length
|
||||||
next_character: @chunk.match(MULTI_DENT)[4]
|
next_character: @chunk.match(MULTI_DENT)[4]
|
||||||
prev: @tokens[@tokens.length - 2]
|
prev: @tokens[@tokens.length - 2]
|
||||||
no_newlines: next_character is '.' or (@value().match(NO_NEWLINE) and prev and (prev[0] isnt '.') and not @value().match(CODE))
|
no_newlines: next_character is '.' or (@value() and @value().match(NO_NEWLINE) and prev and (prev[0] isnt '.') and not @value().match(CODE))
|
||||||
return @suppress_newlines(indent) if no_newlines
|
return @suppress_newlines(indent) if no_newlines
|
||||||
size: indent.match(LAST_DENTS).reverse()[0].match(LAST_DENT)[1].length
|
size: indent.match(LAST_DENTS).reverse()[0].match(LAST_DENT)[1].length
|
||||||
return @newline_token(indent) if size is @indent
|
return @newline_token(indent) if size is @indent
|
||||||
|
|||||||
@@ -13,4 +13,14 @@ puts result
|
|||||||
first: if false then false else second: if false then false else true
|
first: if false then false else second: if false then false else true
|
||||||
|
|
||||||
puts first
|
puts first
|
||||||
puts second
|
puts second
|
||||||
|
|
||||||
|
|
||||||
|
result: if false
|
||||||
|
false
|
||||||
|
else if NaN
|
||||||
|
false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
|
||||||
|
puts result
|
||||||
Reference in New Issue
Block a user