summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-27 09:51:24 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-27 09:51:24 +0000
commitcc09ba4699b438773177639beac10b66bf2c98c1 (patch)
tree0fc819920d5c613be02decdb3524b17841a5fab5 /bootstraptest
parent1ff31c2d2de0a863e638357e1673b1fbb559cecd (diff)
add test for thread local variable with fiber.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_knownbug.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/bootstraptest/test_knownbug.rb b/bootstraptest/test_knownbug.rb
index 0b8c795cde..f978e24f6a 100644
--- a/bootstraptest/test_knownbug.rb
+++ b/bootstraptest/test_knownbug.rb
@@ -12,3 +12,38 @@ assert_finish 1, %q{
sleep 0.1
w.write "a"
}, '[ruby-dev:31866]'
+
+assert_equal "[[nil, 1, 1, nil, nil], [nil, 2, 2, nil]]", %q{
+ def tvar(var, val)
+ old = Thread.current[var]
+ begin
+ Thread.current[var] = val
+ yield
+ ensure
+ Thread.current[var] = old
+ end
+ end
+ ary1 = []
+ ary2 = []
+ fb = Fiber.new {
+ ary2 << Thread.current[:v]
+ tvar(:v, 2) {
+ ary2 << Thread.current[:v]
+ Fiber.yield
+ ary2 << Thread.current[:v]
+ }
+ ary2 << Thread.current[:v]
+ Fiber.yield
+ ary2 << Thread.current[:v]
+ }
+ ary1 << Thread.current[:v]
+ tvar(:v,1) {
+ ary1 << Thread.current[:v]
+ fb.resume
+ ary1 << Thread.current[:v]
+ }
+ ary1 << Thread.current[:v]
+ fb.resume
+ ary1 << Thread.current[:v]
+ [ary1, ary2]
+}