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

57 lines
762 B
CoffeeScript
Raw Normal View History

# Basic chained function calls.
2010-07-25 01:23:37 -04:00
identityWrap = (x) ->
-> x
2010-07-25 01:23:37 -04:00
result = identityWrap(identityWrap(true))()()
ok result
# Chained accesses split on period/newline, backwards and forwards.
2010-07-25 01:23:37 -04:00
str = 'god'
2010-07-25 01:23:37 -04:00
result = str.
split('').
reverse().
reverse().
reverse()
ok result.join('') is 'dog'
2010-07-25 01:23:37 -04:00
result = str
.split('')
.reverse()
.reverse()
.reverse()
ok result.join('') is 'dog'
# Newline suppression for operators.
2010-07-25 01:23:37 -04:00
six =
1 +
2 +
3
2010-04-18 00:41:47 -04:00
ok six is 6
# Ensure that indented array literals don't trigger whitespace rewriting.
func = () ->
ok arguments.length is 1
func(
[[[[[],
[]],
[[]]]],
[]])
id = (x) -> x
greeting = id(
"""
Hello
""")
ok greeting is "Hello"