Sha256: ee45d1d6277986bb5ed348a36b8ab5dded3dacb1e4447295cd9afdb4f2eb71c7

Contents?: true

Size: 1000 Bytes

Versions: 396

Compression:

Stored size: 1000 Bytes

Contents

require './accumulate'

describe '[].accumulate()', ->

  it 'empty accumulation', ->
    accumulator = (e) -> e * e
    expect([].accumulate(accumulator)).toEqual []

  xit 'accumulate squares', ->
    accumulator = (number) -> number * number
    expect([1, 2, 3].accumulate accumulator).toEqual [1, 4, 9]

  xit 'accumulate upcases', ->
    accumulator = (word) -> word.toUpperCase()
    result      = 'hello world'.split(/\s/).accumulate accumulator

    expect(result).toEqual ['HELLO', 'WORLD']

  xit 'accumulate reversed strings', ->
    accumulator = (word) -> word.split('').reverse().join('')
    result      = 'the quick brown fox etc'.split(/\s/).accumulate accumulator

    expect(result).toEqual ["eht", "kciuq", "nworb", "xof", "cte"]

  xit 'accumulate recursively', ->
    result = 'a b c'.split(/\s+/).accumulate (char)  ->
      '1 2 3'.split(/\s+/).accumulate (digit) -> "#{char}#{digit}"

    expect(result).toEqual([["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]])

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.0.6.20 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.19 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.18 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.17 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.16 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.15 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.14 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.13 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.12 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.11 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.10 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.9 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.8 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.7 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.6 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.5 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.4 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.3 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.2 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.0.6.1 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee