File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 6
6
Kernel . should have_private_instance_method ( :sleep )
7
7
end
8
8
9
+ it "returns an Integer" do
10
+ sleep ( 0.001 ) . should be_kind_of ( Integer )
11
+ end
12
+
9
13
it "accepts a Float" do
10
- sleep ( 0.1 ) . should be_close ( 0 , 2 )
14
+ sleep ( 0.001 ) . should >= 0
11
15
end
12
16
13
17
it "accepts a Fixnum" do
14
- sleep ( 0 ) . should be_close ( 0 , 2 )
18
+ sleep ( 0 ) . should >= 0
15
19
end
16
20
17
21
it "accepts a Rational" do
18
- sleep ( Rational ( 1 , 9 ) ) . should be_close ( 0 , 2 )
22
+ sleep ( Rational ( 1 , 999 ) ) . should >= 0
19
23
end
20
24
21
25
it "raises an ArgumentError when passed a negative duration" do
Original file line number Diff line number Diff line change 72
72
73
73
it "sleeps when the mutex is locked" do
74
74
@m . lock
75
- start = Time . now
76
- @s . rb_mutex_sleep ( @m , 0.1 )
77
- ( Time . now - start ) . should be_close ( 0.1 , 0.2 )
75
+ t1 = Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
76
+ @s . rb_mutex_sleep ( @m , 0.001 )
77
+ t2 = Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
78
+ ( t2 - t1 ) . should >= 0
78
79
@m . locked? . should be_true
79
80
end
80
81
end
You can’t perform that action at this time.
0 commit comments