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