summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-23 15:05:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-23 15:05:03 +0000
commit4dc1a2180946ab793adee5eb235fc4ee8fa4cefe (patch)
tree7c078ba1c20373d9c36610c6c98de775e9f44a51 /test
parenta7c15b2617620b79ea734faf31dacc8e72ed5ad1 (diff)
* error.c (rb_name_error_str): new function to raise NameError
with the name string but not ID. * object.c, proc.c, variable.c: more removal of inadvertent symbol creation. [Feature #5079] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_symbol.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 2a21c78540..0113504b14 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -172,4 +172,29 @@ class TestSymbol < Test::Unit::TestCase
assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
end
end
+
+ def test_no_inadvertent_symbol_creation2
+ feature5079 = '[ruby-core:38404]'
+ c = Class.new
+ s = "gadzoooks"
+ {:instance_variable_get => ["@#{s}1", nil],
+ :class_variable_get => ["@@#{s}1", NameError],
+ :remove_instance_variable => ["@#{s}2", NameError],
+ :remove_class_variable => ["@@#{s}2", NameError],
+ :remove_const => ["A#{s}", NameError],
+ :method => ["#{s}1", NameError],
+ :public_method => ["#{s}2", NameError],
+ :instance_method => ["#{s}3", NameError],
+ :public_instance_method => ["#{s}4", NameError],
+ }.each do |meth, arr|
+ str, ret = arr
+ msg = "#{meth}(#{str}) #{feature5079}"
+ if ret.is_a?(Class) && (ret < Exception)
+ assert_raises(ret){c.send(meth, str)}
+ else
+ assert(c.send(meth, str) == ret, msg)
+ end
+ assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
+ end
+ end
end