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.2.1.180 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.179 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.178 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.177 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.176 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.175 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.174 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.173 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.172 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.171 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.170 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.169 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.167 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.166 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.165 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.164 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.163 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.162 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.161 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee
trackler-2.2.1.160 tracks/coffeescript/exercises/accumulate/accumulate_test.spec.coffee