mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Add tests for the optimization of trailing return statements
This documents current behavior. When #1038 was fixed, we also optimized away trailing "undefined" and "return undefined", but that is no longer the case.
This commit is contained in:
parent
eda4f0c55b
commit
8980647f32
1 changed files with 13 additions and 0 deletions
|
@ -240,3 +240,16 @@ test "#1435 Indented property access", ->
|
|||
rec.rec()
|
||||
.rec()
|
||||
1
|
||||
|
||||
test "#1038 Optimize trailing return statements", ->
|
||||
compile = (code) -> CoffeeScript.compile(code, bare: yes).trim().replace(/\s+/g, " ")
|
||||
|
||||
eq "(function() {});", compile("->")
|
||||
eq "(function() {});", compile("-> return")
|
||||
eq "(function() { return void 0; });", compile("-> undefined")
|
||||
eq "(function() { return void 0; });", compile("-> return undefined")
|
||||
eq "(function() { foo(); });", compile("""
|
||||
->
|
||||
foo()
|
||||
return
|
||||
""")
|
||||
|
|
Loading…
Reference in a new issue