summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 12:20:06 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 12:20:06 +0000
commiteb0761408524b45266940fc02c86cf3a0f5b87af (patch)
tree5db1aba02aaeb8dc1c643729c380dc42fa165124 /test
parent017eb0f12c4f631d673aca5447511344b093c102 (diff)
merge revision(s) 49055: [Backport #10667]
* thread.c (rb_thread_variable_get): fix dynamic symbol keys. rb_check_id() returns non-zero only for static symbols, whereas thread local variable keys can be dynamic symbols. [ruby-core:67185] [Bug #10667] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/symbol/test_inadvertent_creation.rb8
-rw-r--r--test/ruby/test_thread.rb10
2 files changed, 17 insertions, 1 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb
index abcb5d9ccb..b180d08b04 100644
--- a/test/-ext-/symbol/test_inadvertent_creation.rb
+++ b/test/-ext-/symbol/test_inadvertent_creation.rb
@@ -202,7 +202,13 @@ module Test_Symbol
Thread.current.thread_variable_set(:test, nil)
name = noninterned_name
assert_nil(Thread.current.thread_variable_get(name))
- assert_not_interned(name)
+ assert_not_pinneddown(name)
+ end
+
+ def test_thread_variable_set
+ name = noninterned_name
+ Thread.current.thread_variable_set(name, 42)
+ assert_not_pinneddown(name)
end
def test_thread_variable?
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index fba4737009..87d5f0f79e 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -432,6 +432,16 @@ class TestThread < Test::Unit::TestCase
end
end
+ def test_thread_local_dynamic_symbol
+ bug10667 = '[ruby-core:67185] [Bug #10667]'
+ t = Thread.new {}.join
+ key_str = "foo#{rand}"
+ key_sym = key_str.to_sym
+ t.thread_variable_set(key_str, "bar")
+ assert_equal("bar", t.thread_variable_get(key_str), "#{bug10667}: string key")
+ assert_equal("bar", t.thread_variable_get(key_sym), "#{bug10667}: symbol key")
+ end
+
def test_select_wait
assert_nil(IO.select(nil, nil, nil, 0.001))
t = Thread.new do