Skip to content

Commit f3b4b3f

Browse files
committed
Refactored more buggy tests.
1 parent 02f6906 commit f3b4b3f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

spec/concurrent/atomic/condition_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module Concurrent
7070
expect(result).to be_woken_up
7171
expect(result).not_to be_timed_out
7272
expect(result.remaining_time).to be_nil
73-
expect(t.status).to be_falsey
73+
t.kill
7474
end
7575

7676
it 'should return a woken up result when is woken up by #broadcast' do
@@ -98,7 +98,7 @@ module Concurrent
9898
expect(result).to be_woken_up
9999
expect(result).not_to be_timed_out
100100
expect(result.remaining_time).to be_nil
101-
expect(t.status).to be_falsey
101+
t.kill
102102
end
103103
end
104104
end
@@ -152,7 +152,7 @@ module Concurrent
152152
expect(result).to be_woken_up
153153
expect(result).not_to be_timed_out
154154
expect(result.remaining_time).to be < 1.0
155-
expect(t.status).to be_falsey
155+
t.kill
156156
end
157157

158158
it 'should return remaining time when is woken up by #broadcast' do
@@ -181,7 +181,7 @@ module Concurrent
181181
expect(result).to be_woken_up
182182
expect(result).not_to be_timed_out
183183
expect(result.remaining_time).to be < 1.0
184-
expect(t.status).to be_falsey
184+
t.kill
185185
end
186186

187187
it 'should return 0 or negative number if timed out' do
@@ -201,7 +201,7 @@ module Concurrent
201201
expect(result).not_to be_woken_up
202202
expect(result).to be_timed_out
203203
expect(result.remaining_time).to be_less_than_or_equal_to(0)
204-
expect(t.status).to be_falsey
204+
t.kill
205205
end
206206
end
207207
end

spec/concurrent/utility/timer_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ module Concurrent
1919
it 'executes the block after the given number of seconds' do
2020
latch = CountDownLatch.new(1)
2121
duration = Hitimes::Interval.measure do
22-
Concurrent::timer(0.1){ latch.count_down }
22+
Concurrent::timer(0.2){ latch.count_down }
2323
latch.wait(1)
2424
end
25-
expect(duration).to be_within(0.05).of(0.1)
25+
expect(duration).to be_within(0.1).of(0.2)
2626
end
2727

2828
it 'suppresses exceptions thrown by the block' do
2929
expect {
30-
Concurrent::timer(0.5){ raise Exception }
30+
Concurrent::timer(0.1){ raise Exception }
31+
sleep(0.2)
3132
}.to_not raise_error
3233
end
3334

@@ -38,7 +39,7 @@ module Concurrent
3839
expected = args
3940
latch.count_down
4041
end
41-
latch.wait(0.2)
42+
latch.wait(1)
4243
expect(expected).to eq [1, 2, 3]
4344
end
4445

0 commit comments

Comments
 (0)