From cc09ba4699b438773177639beac10b66bf2c98c1 Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 27 Sep 2007 09:51:24 +0000 Subject: 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 --- bootstraptest/test_knownbug.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'bootstraptest/test_knownbug.rb') 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] +} -- cgit v1.2.3