diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-27 09:51:24 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-09-27 09:51:24 +0000 |
commit | cc09ba4699b438773177639beac10b66bf2c98c1 (patch) | |
tree | 0fc819920d5c613be02decdb3524b17841a5fab5 /bootstraptest/test_knownbug.rb | |
parent | 1ff31c2d2de0a863e638357e1673b1fbb559cecd (diff) | |
download | ruby-cc09ba4699b438773177639beac10b66bf2c98c1.tar.gz |
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/test_knownbug.rb')
-rw-r--r-- | bootstraptest/test_knownbug.rb | 35 |
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] +} |