Sha256: d151b41a96729f47796d558a8977e181fb5d451b1798583a3428b5008d280df2

Contents?: true

Size: 534 Bytes

Versions: 12

Compression:

Stored size: 534 Bytes

Contents

#! /usr/bin/env ruby
require 'rubygems'
require 'thread/promise'

describe Thread::Promise do
	it 'delivers a value properly' do
		p = Thread.promise

		Thread.new {
			sleep 0.2

			p << 42
		}

		p.value.should == 42
	end

	it 'properly checks if anything has been delivered' do
		p = Thread.promise

		Thread.new {
			sleep 0.2

			p << 42
		}

		p.delivered?.should == false
		sleep 0.3
		p.delivered?.should == true
	end

	it 'does not block when a timeout is passed' do
		p = Thread.promise

		p.value(0).should == nil
	end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
thread-0.1.4 tests/promise_spec.rb
thread-0.1.3 tests/promise_spec.rb
thread-0.1.2 tests/promise_spec.rb
vinted-thread-0.1.1 tests/promise_spec.rb
thread-0.1.1 tests/promise_spec.rb
thread-0.1.0 tests/promise_spec.rb
thread-0.0.8.1 tests/promise_spec.rb
thread-0.0.8 tests/promise_spec.rb
thread-0.0.7 tests/promise_spec.rb
thread-0.0.6.2 tests/promise_spec.rb
thread-0.0.6.1 tests/promise_spec.rb
thread-0.0.6 tests/promise_spec.rb