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

adding a statement-as-expression test, and returning null from while loops, if asked

This commit is contained in:
Jeremy Ashkenas 2010-01-03 18:58:34 -05:00
parent d53d85d03e
commit cb1815885c
3 changed files with 16 additions and 4 deletions

View file

@ -575,12 +575,13 @@ module CoffeeScript
end
def compile_node(o)
o.delete(:return)
returns = o.delete(:return)
indent = o[:indent]
o[:indent] += TAB
o[:top] = true
cond = @condition.compile(o)
write("#{indent}while (#{cond}) {\n#{@body.compile(o)}\n#{indent}}")
post = returns ? "\n#{indent}return null;" : ''
write("#{indent}while (#{cond}) {\n#{@body.compile(o)}\n#{indent}}#{post}")
end
end

View file

@ -0,0 +1,11 @@
# Everything should be able to be an expression.
result: while sunny?
go_outside()
print(3 + try
nonexistent.no_way
catch error
print(error)
3
)

View file

@ -14,8 +14,8 @@ class ExecutionTest < Test::Unit::TestCase
end
end
def test_lintless_coffeescript
no_warnings `bin/coffee -l test/fixtures/execution/*.coffee`
def test_lintless_tests
no_warnings `bin/coffee -l test/fixtures/*/*.coffee`
end
def test_lintless_examples