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:
parent
d53d85d03e
commit
cb1815885c
3 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
11
test/fixtures/generation/statements_as_expressions.coffee
vendored
Normal file
11
test/fixtures/generation/statements_as_expressions.coffee
vendored
Normal 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
|
||||
)
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue