Project

General

Profile

Bug #17985 ยป bug17882-gcmod.rb

Repro: a mod of `bootstraptest/test_ractor.rb:224` - xtkoba (Tee KOBAYASHI), 06/14/2021 06:08 PM

 
1

    
2
def test n
3
  rs = (1..n).map do |i|
4
    Ractor.new(i) do |i|
5
      "r#{i}"
6
    end
7
  end
8
  as = []
9
  all_rs = rs.dup
10

    
11
  n.times{
12
    r, obj = Ractor.select(*rs)
13
    as << [r, obj]
14
    rs.delete(r)
15
  }
16

    
17
  if as.map{|r, o| r.object_id}.sort == all_rs.map{|r| r.object_id}.sort &&
18
     as.map{|r, o| o}.sort == (1..n).map{|i| "r#{i}"}.sort
19
    'ok'
20
  else
21
    'ng'
22
  end
23
end
24

    
25
GC.disable
26

    
27
p 30.times.map{|i|
28
  test i
29
}
30

    
31
GC.start