Skip to content

Commit 75455b6

Browse files
committed
Updated Event truthy specs to check for explicit true/false.
1 parent 3b9eb6d commit 75455b6

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

spec/concurrent/atomic/event_spec.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module Concurrent
3232
Thread.new{ subject.wait.tap{ latch.count_down } }
3333
sleep(0.1)
3434
subject.set
35-
expect(latch.wait(1)).to be_truthy
35+
expect(latch.wait(1)).to be true
3636
end
3737

3838
it 'sets the state to set' do
@@ -49,12 +49,12 @@ module Concurrent
4949
end
5050

5151
it 'returns true if not previously set' do
52-
expect(subject.try?).to be_truthy
52+
expect(subject.try?).to be true
5353
end
5454

5555
it 'returns false if previously set' do
5656
subject.set
57-
expect(subject.try?).to be_falsey
57+
expect(subject.try?).to be false
5858
end
5959
end
6060

@@ -69,20 +69,20 @@ module Concurrent
6969
latch = CountDownLatch.new(1)
7070
Thread.new{ subject.wait.tap{ latch.count_down } }
7171
subject.reset
72-
expect(latch.wait(0.1)).to be_falsey
72+
expect(latch.wait(0.1)).to be false
7373
end
7474

7575
it 'does not interrupt waiting threads when event is unset' do
7676
latch = CountDownLatch.new(1)
7777
Thread.new{ subject.wait.tap{ latch.count_down } }
7878
subject.reset
79-
expect(latch.wait(0.1)).to be_falsey
79+
expect(latch.wait(0.1)).to be false
8080
subject.set
81-
expect(latch.wait(0.1)).to be_truthy
81+
expect(latch.wait(0.1)).to be true
8282
end
8383

8484
it 'returns true when called on an unset event' do
85-
expect(subject.reset).to be_truthy
85+
expect(subject.reset).to be true
8686
end
8787

8888
it 'sets the state of a set event to unset' do
@@ -95,7 +95,7 @@ module Concurrent
9595
it 'returns true when called on a set event' do
9696
subject.set
9797
expect(subject).to be_set
98-
expect(subject.reset).to be_truthy
98+
expect(subject.reset).to be true
9999
end
100100
end
101101

@@ -133,42 +133,42 @@ module Concurrent
133133
latch = CountDownLatch.new(1)
134134
subject.set
135135
Thread.new{ subject.wait(1000); latch.count_down }
136-
expect(latch.wait(0.1)).to be_truthy
136+
expect(latch.wait(0.1)).to be true
137137
end
138138

139139
it 'returns true once the event is set' do
140140
subject.set
141-
expect(subject.wait).to be_truthy
141+
expect(subject.wait).to be true
142142
end
143143

144144
it 'blocks indefinitely when the timer is nil' do
145145
subject.reset
146146
latch = CountDownLatch.new(1)
147147
Thread.new{ subject.wait.tap{ latch.count_down } }
148-
expect(latch.wait(0.1)).to be_falsey
148+
expect(latch.wait(0.1)).to be false
149149
subject.set
150-
expect(latch.wait(0.1)).to be_truthy
150+
expect(latch.wait(0.1)).to be true
151151
end
152152

153153
it 'stops waiting when the timer expires' do
154154
subject.reset
155155
latch = CountDownLatch.new(1)
156156
Thread.new{ subject.wait(0.2); latch.count_down }
157-
expect(latch.wait(0.1)).to be_falsey
158-
expect(latch.wait).to be_truthy
157+
expect(latch.wait(0.1)).to be false
158+
expect(latch.wait).to be true
159159
end
160160

161161
it 'returns false when the timer expires' do
162162
subject.reset
163-
expect(subject.wait(1)).to be_falsey
163+
expect(subject.wait(1)).to be false
164164
end
165165

166166
it 'triggers multiple waiting threads' do
167167
latch = CountDownLatch.new(5)
168168
subject.reset
169169
5.times{ Thread.new{ subject.wait; latch.count_down } }
170170
subject.set
171-
expect(latch.wait(0.2)).to be_truthy
171+
expect(latch.wait(0.2)).to be true
172172
end
173173

174174
it 'behaves appropriately if wait begins while #set is processing' do
@@ -177,7 +177,7 @@ module Concurrent
177177
5.times{ Thread.new{ subject.wait(5) } }
178178
subject.set
179179
5.times{ Thread.new{ subject.wait; latch.count_down } }
180-
expect(latch.wait(0.2)).to be_truthy
180+
expect(latch.wait(0.2)).to be true
181181
end
182182
end
183183

@@ -199,7 +199,7 @@ def subject.simulate_spurious_wake_up
199199
sleep(0.1)
200200
subject.simulate_spurious_wake_up
201201

202-
expect(latch.wait(0.1)).to be_falsey
202+
expect(latch.wait(0.1)).to be false
203203
end
204204

205205
it 'should resist to spurious wake ups with timeout' do
@@ -209,8 +209,8 @@ def subject.simulate_spurious_wake_up
209209
sleep(0.1)
210210
subject.simulate_spurious_wake_up
211211

212-
expect(latch.wait(0.1)).to be_falsey
213-
expect(latch.wait(1)).to be_truthy
212+
expect(latch.wait(0.1)).to be false
213+
expect(latch.wait(1)).to be true
214214
end
215215
end
216216
end

0 commit comments

Comments
 (0)