mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
[CS2] return and export default can now accept implicit objects (#4532)
* Start with the test I want to pass: return an implicit (braces-less) object * Update Rewriter class to follow pattern of nodes.coffee; move debugging snippet to where it’ll work in CS2 * Allow export default implicit object * `return` assumes a continuation onto the next line *if* the next line is indented * Fix comment; improve test
This commit is contained in:
@@ -353,6 +353,28 @@ test "export default object", ->
|
||||
};"""
|
||||
eq toJS(input), output
|
||||
|
||||
test "export default implicit object", ->
|
||||
input = "export default foo: 'bar', baz: 'qux'"
|
||||
output = """
|
||||
export default {
|
||||
foo: 'bar',
|
||||
baz: 'qux'
|
||||
};"""
|
||||
eq toJS(input), output
|
||||
|
||||
test "export default multiline implicit object", ->
|
||||
input = """
|
||||
export default
|
||||
foo: 'bar',
|
||||
baz: 'qux'
|
||||
"""
|
||||
output = """
|
||||
export default {
|
||||
foo: 'bar',
|
||||
baz: 'qux'
|
||||
};"""
|
||||
eq toJS(input), output
|
||||
|
||||
test "export default assignment expression", ->
|
||||
input = "export default foo = 'bar'"
|
||||
output = """
|
||||
|
||||
@@ -575,3 +575,15 @@ test "#4324: Shorthand after interpolated key", ->
|
||||
obj = {"#{1}": 1, a}
|
||||
eq 1, obj[1]
|
||||
eq 2, obj.a
|
||||
|
||||
test "#1263: Braceless object return", ->
|
||||
fn = ->
|
||||
return
|
||||
a: 1
|
||||
b: 2
|
||||
c: -> 3
|
||||
|
||||
obj = fn()
|
||||
eq 1, obj.a
|
||||
eq 2, obj.b
|
||||
eq 3, obj.c()
|
||||
|
||||
Reference in New Issue
Block a user