adding test for body-less while, using null as the body so JSLint doesn't get in a tizzy

This commit is contained in:
Jeremy Ashkenas
2010-01-09 11:58:50 -05:00
parent ae58e2ec6c
commit 7befbddae2
2 changed files with 8 additions and 2 deletions

View File

@@ -609,7 +609,7 @@ module CoffeeScript
o[:top] = true o[:top] = true
cond = @condition.compile(o) cond = @condition.compile(o)
post = returns ? "\n#{idt}return null;" : '' post = returns ? "\n#{idt}return null;" : ''
return write("#{idt}while (#{cond});#{post}") if @body.nil? return write("#{idt}while (#{cond}) null;#{post}") if @body.nil?
write("#{idt}while (#{cond}) {\n#{@body.compile(o)}\n#{idt}}#{post}") write("#{idt}while (#{cond}) {\n#{@body.compile(o)}\n#{idt}}#{post}")
end end
end end

View File

@@ -23,4 +23,10 @@ print(func() is null)
str: "\\" str: "\\"
reg: /\\/ reg: /\\/
print(reg(str) and str is '\\') print(reg(str) and str is '\\')
i: 10
while i -= 1
print(i is 0)