Sha256: 138d5d32b20a9d3fd5fe4a09ca3bee8b52d7cc773b42e52f38c126baecdf7762

Contents?: true

Size: 499 Bytes

Versions: 6

Compression:

Stored size: 499 Bytes

Contents

require 'thread/future'

describe Thread::Future do
	it 'delivers a value properly' do
		f = Thread.future {
			sleep 0.02
			42
		}

		expect(f.value).to eq(42)
	end

	it 'properly checks if anything has been delivered' do
		f = Thread.future {
			sleep 0.02

			42
		}

		expect(f.delivered?).to eq(false)
		sleep 0.03
		expect(f.delivered?).to eq(true)
	end

	it 'does not block when a timeout is passed' do
		f = Thread.future {
			sleep 0.02

			42
		}

		expect(f.value(0)).to be_nil
	end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
thread-0.2.2 spec/thread/future_spec.rb
thread-0.2.1 spec/thread/future_spec.rb
seekingalpha_thread-1.0.1 spec/thread/future_spec.rb
thread-0.2.0 spec/thread/future_spec.rb
thread-0.1.7 spec/thread/future_spec.rb
thread-0.1.6 spec/thread/future_spec.rb