@@ -68,35 +68,36 @@ def dereferenceable_subject(value, opts = {})
68
68
expect ( m . take ( 0.1 ) ) . to eq MVar ::TIMEOUT
69
69
end
70
70
71
- context 'when a block is given' do
71
+ end
72
72
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
78
74
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
84
80
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
90
86
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
95
92
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
96
96
end
97
97
98
98
end
99
99
100
+
100
101
describe '#put' do
101
102
102
103
it 'sets the MVar to be empty' do
0 commit comments