Sha256: 881c7c7cf9d65840dbfc7a8dff1f57c5254d53cfd34da15eb9eae2214dbbc005

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

# Chaining
# --------

# shared identity function
id = (_) -> if arguments.length is 1 then _ else Array::slice.call(arguments)



# Basic chained function calls.
identityWrap = (x) ->
  -> x

result = identityWrap(identityWrap(true))()()

ok result


# Should be able to look at prototypes on keywords.
obj =
  withAt:   -> @::prop
  withThis: -> this::prop
  proto:
    prop: 100
obj.prototype = obj.proto
eq obj.withAt()  , 100
eq obj.withThis(), 100


# Chained accesses split on period/newline, backwards and forwards.
str = 'god'

result = str.
  split('').
  reverse().
  reverse().
  reverse()

ok result.join('') is 'dog'

result = str
  .split('')
  .reverse()
  .reverse()
  .reverse()

ok result.join('') is 'dog'


# Newline suppression for operators.
six =
  1 +
  2 +
  3

ok six is 6


# Ensure that indented array literals don't trigger whitespace rewriting.
func = () ->
  ok arguments.length is 1

func(
  [[[[[],
                []],
              [[]]]],
    []])

greeting = id(
              """
              Hello
              """)

ok greeting is "Hello"

ok not Date
::
?.foo, '`?.` and `::` should also continue lines'

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
spade-packager-0.1.0.1 packages/coffee-script/test/test_chaining.coffee
spade-packager-0.1.0 packages/coffee-script/test/test_chaining.coffee
spade-0.0.8.1 packages/coffee-script/test/test_chaining.coffee
spade-0.0.7 packages/coffee-script/test/test_chaining.coffee
spade-0.0.6 packages/coffee-script/test/test_chaining.coffee
spade-0.0.5 packages/coffee-script/test/test_chaining.coffee
spade-0.0.4 packages/coffee-script/test/test_chaining.coffee
spade-0.0.3 packages/coffee-script/test/test_chaining.coffee
spade-0.0.2 packages/coffee-script/test/test_chaining.coffee
spade-0.0.1 packages/coffee-script/test/test_chaining.coffee