File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 138
138
rand ( KernelSpecs ::CustomRangeFloat . new ( 1.0 ) ..KernelSpecs ::CustomRangeFloat . new ( 42.0 ) ) . should be_an_instance_of ( KernelSpecs ::CustomRangeFloat )
139
139
rand ( Time . now ..Time . now ) . should be_an_instance_of ( Time )
140
140
end
141
+
142
+ it "is random on boot" do
143
+ results = 2 . times . map {
144
+ out = ruby_exe ( 'p rand' , options : '--disable-gems' )
145
+ Float ( out )
146
+ }
147
+ results . size . should == 2
148
+ # this is technically flaky, but very unlikely in a good distribution
149
+ results [ 0 ] . should_not == results [ 1 ]
150
+ end
141
151
end
142
152
143
153
describe "Kernel#rand" do
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ fails:Kernel.rand given an exclusive range returns a Float between the two given
4
4
fails:Kernel.rand returns nil when range is backwards
5
5
fails:Kernel.rand returns the range start/end when Float range is 0
6
6
fails:Kernel.rand supports custom object types
7
+ slow:Kernel.rand is random on boot
Original file line number Diff line number Diff line change @@ -395,7 +395,9 @@ def thread_variables
395
395
end
396
396
end
397
397
398
- Thread . current . send :internal_thread_initialize
398
+ Truffle ::Boot . redo do
399
+ Thread . current . send :internal_thread_initialize
400
+ end
399
401
400
402
class ThreadGroup
401
403
def initialize
You can’t perform that action at this time.
0 commit comments