Sha256: 43448d4f4569bc79c6bb7494b6650dc16f8867857f694dd5ee7fce266499de9c

Contents?: true

Size: 751 Bytes

Versions: 12

Compression:

Stored size: 751 Bytes

Contents

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

describe Thread::Channel do
	it 'receives in the proper order' do
		ch = Thread.channel
		ch.send 'lol'
		ch.send 'wut'

		ch.receive.should == 'lol'
		ch.receive.should == 'wut'
	end

	it 'receives with constraints properly' do
		ch = Thread.channel
		ch.send 'lol'
		ch.send 'wut'

		ch.receive { |v| v == 'wut' }.should == 'wut'
		ch.receive.should == 'lol'
	end

	it 'receives nil when using non blocking mode and the channel is empty' do
		ch = Thread.channel

		ch.receive!.should == nil
	end

	it 'guards sending properly' do
		ch = Thread.channel { |v| v.is_a? Integer }

		expect {
			ch.send 23
		}.to_not raise_error

		expect {
			ch.send 'lol'
		}.to raise_error
	end
end

Version data entries

12 entries across 12 versions & 2 rubygems

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