Sha256: 73b90edbe41e1c804c3441c6ddda041509019d9129fdf0cb81001ffd76340a04

Contents?: true

Size: 611 Bytes

Versions: 7

Compression:

Stored size: 611 Bytes

Contents

require 'promise'

describe 'Promise#trace' do
  it 'calls the block with all the previous results' do
    x = 42

    Promise.value(1).then { 2 }.then { 3 }.trace {|a, b, c|
      x = a + b + c
    }

    x.should == 6
  end

  it 'calls the then after the trace' do
    x = 42

    Promise.value(1).then { 2 }.then { 3 }.trace {|a, b, c|
      a + b + c
    }.then { |v| x = v }

    x.should == 6
  end

  it 'works after a when' do
    x = 42

    Promise.value(1).then {
      Promise.when Promise.value(2), Promise.value(3)
    }.trace {|a, b|
      x = a + b[0] + b[1]
    }

    x.should == 6
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
opal-0.6.3 spec/opal/stdlib/promise/trace_spec.rb
opal-cj-0.7.0.beta2 spec/opal/stdlib/promise/trace_spec.rb
opal-cj-0.7.0.beta1 spec/opal/stdlib/promise/trace_spec.rb
opal-0.7.0.beta1 spec/opal/stdlib/promise/trace_spec.rb
opal-0.6.2 spec/opal/stdlib/promise/trace_spec.rb
opal-0.6.1 spec/opal/stdlib/promise/trace_spec.rb
opal-0.6.0 spec/opal/stdlib/promise/trace_spec.rb