@@ -68,35 +68,36 @@ def dereferenceable_subject(value, opts = {})
6868 expect ( m . take ( 0.1 ) ) . to eq MVar ::TIMEOUT
6969 end
7070
71- context 'when a block is given' do
71+ end
7272
73- it 'yields current value to the block and puts back value' do
74- m = MVar . new ( 14 )
75- expect { |b | m . take ( &b ) } . to yield_with_args ( 14 )
76- expect ( m . take ) . to eq ( 14 )
77- end
73+ describe '#borrow' do
7874
79- it 'puts back value even if an exception is raised ' do
80- m = MVar . new ( 14 )
81- expect { m . take { fail 'boom!' } } . to raise_error ( 'boom!' )
82- expect ( m . take ) . to eq ( 14 )
83- end
75+ it 'yields current value to the block and puts back value ' do
76+ m = MVar . new ( 14 )
77+ expect { | b | m . borrow ( & b ) } . to yield_with_args ( 14 )
78+ expect ( m . take ) . to eq ( 14 )
79+ end
8480
85- it 'returns the returned value of the block ' do
86- m = MVar . new ( 14 )
87- expect ( m . take { 2 } ) . to eq ( 2 )
88- expect ( m . take ) . to eq ( 14 )
89- end
81+ it 'puts back value even if an exception is raised ' do
82+ m = MVar . new ( 14 )
83+ expect { m . borrow { fail 'boom!' } } . to raise_error ( 'boom!' )
84+ expect ( m . take ) . to eq ( 14 )
85+ end
9086
91- it 'returns TIMEOUT on timeout on an empty MVar' do
92- m = MVar . new
93- expect ( m . take ( 0.1 ) { } ) . to eq MVar ::TIMEOUT
94- end
87+ it 'returns the returned value of the block' do
88+ m = MVar . new ( 14 )
89+ expect ( m . borrow { 2 } ) . to eq ( 2 )
90+ expect ( m . take ) . to eq ( 14 )
91+ end
9592
93+ it 'returns TIMEOUT on timeout on an empty MVar' do
94+ m = MVar . new
95+ expect ( m . borrow ( 0.1 ) { } ) . to eq MVar ::TIMEOUT
9696 end
9797
9898 end
9999
100+
100101 describe '#put' do
101102
102103 it 'sets the MVar to be empty' do
0 commit comments