summaryrefslogtreecommitdiffstats
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
commitd1e04a013decd7565d816617022b152e03990fb5 (patch)
tree0fc819920d5c613be02decdb3524b17841a5fab5 /bootstraptest
parent8e83377617d11f1187cb299b3b883f2d40ee3f02 (diff)
downloadruby-d1e04a013decd7565d816617022b152e03990fb5.tar.gz
ruby-d1e04a013decd7565d816617022b152e03990fb5.tar.xz
ruby-d1e04a013decd7565d816617022b152e03990fb5.zip
add test for thread local variable with fiber.
git-svn-id: http://svn.ruby-lang.org/repos/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 0b8c795cd..f978e24f6 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]
+}