Sha256: 23d8cec9844ca2878f1a150cfc69148bcc289bb089e48ea9b4632cd686e1906f

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

require 'test_helper'

class PromiseTest < Test::Unit::TestCase
  def test_new_promise_is_not_completed
    promise = Dharma.promise
    
    assert !promise.completed?
  end

  def test_completed_promise_is_completed
    promise = Dharma.promise
    
    assert promise.try_complete(1)
    assert promise.completed?
  end

  def test_try_complete_twice
    promise = Dharma.promise

    assert promise.try_complete(1)
    assert !promise.try_complete(2)
    assert_equal 1, promise.result
  end

  def test_completing_with_an_exception
    promise = Dharma.promise

    promise.try_complete(Exception.new('broken'))

    assert promise.failure?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dharma-0.9.1 test/promise_test.rb
dharma-0.9.0 test/promise_test.rb