mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
patched up array comprehensions somewhat. Parens are still a necessary evil, and there's still probably plenty of edge cases
This commit is contained in:
parent
2f75854a61
commit
6f81ac3684
5 changed files with 85 additions and 25 deletions
|
|
@ -36,7 +36,7 @@ class ParserTest < Test::Unit::TestCase
|
|||
assert body.operator == '*'
|
||||
end
|
||||
|
||||
def test_lexing_if_statement
|
||||
def test_parsing_if_statement
|
||||
the_if = @par.parse("clap_your_hands() if happy").expressions.first
|
||||
assert the_if.is_a? IfNode
|
||||
assert the_if.condition.literal == 'happy'
|
||||
|
|
@ -44,6 +44,14 @@ class ParserTest < Test::Unit::TestCase
|
|||
assert the_if.body.variable.literal == 'clap_your_hands'
|
||||
end
|
||||
|
||||
def test_parsing_array_comprehension
|
||||
nodes = @par.parse("i for x, i in [10, 9, 8, 7, 6, 5] if i % 2 is 0.").expressions
|
||||
assert nodes.first.is_a? ForNode
|
||||
assert nodes.first.body.literal == 'i'
|
||||
assert nodes.first.filter.operator == '==='
|
||||
assert nodes.first.source.literal.objects.last.value == "5"
|
||||
end
|
||||
|
||||
def test_parsing
|
||||
nodes = @par.parse(File.read('test/fixtures/each.cs'))
|
||||
assign = nodes.expressions.first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue