blob: 35e1bf6851550207f9f305e01e8cfa6785baeb85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
show_limit %q{
fibers = []
begin
fiber = Fiber.new{Fiber.yield}
fiber.resume
fibers << fiber
raise Exception, "skipping" if fibers.count >= 10_000
rescue Exception => error
puts "Fiber count: #{fibers.count} (#{error})"
break
end while true
}
assert_equal %q{ok}, %q{
Fiber.new{
}.resume
:ok
}
assert_equal %q{ok}, %q{
10_000.times.collect{Fiber.new{}}
:ok
}
assert_equal %q{ok}, %q{
fibers = 100.times.collect{Fiber.new{Fiber.yield}}
fibers.each(&:resume)
fibers.each(&:resume)
:ok
}
assert_normal_exit %q{
at_exit { Fiber.new{}.resume }
}
assert_normal_exit %q{
Fiber.new(&Object.method(:class_eval)).resume("foo")
}, '[ruby-dev:34128]'
|