mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_symbol.rb (test_no_inadvertent_symbol_creation3):
remove an assertion depending on default const_missing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9261088ec1
commit
a99ef20400
1 changed files with 39 additions and 35 deletions
|
@ -162,10 +162,11 @@ class TestSymbol < Test::Unit::TestCase
|
|||
feature5072 = '[ruby-core:38367]'
|
||||
c = Class.new
|
||||
s = "gadzooks"
|
||||
{:respond_to? => "#{s}1", :method_defined? => "#{s}2",
|
||||
:public_method_defined? => "#{s}3", :private_method_defined? => "#{s}4",
|
||||
:protected_method_defined? => "#{s}5", :const_defined? => "A#{s}",
|
||||
:instance_variable_defined? => "@#{s}", :class_variable_defined? => "@@#{s}"
|
||||
{
|
||||
:respond_to? => "#{s}1", :method_defined? => "#{s}2",
|
||||
:public_method_defined? => "#{s}3", :private_method_defined? => "#{s}4",
|
||||
:protected_method_defined? => "#{s}5", :const_defined? => "A#{s}",
|
||||
:instance_variable_defined? => "@#{s}", :class_variable_defined? => "@@#{s}"
|
||||
}.each do |meth, str|
|
||||
msg = "#{meth}(#{str}) #{feature5072}"
|
||||
assert !c.send(meth, str), msg
|
||||
|
@ -177,22 +178,22 @@ class TestSymbol < Test::Unit::TestCase
|
|||
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
|
||||
{
|
||||
: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, (str, ret)|
|
||||
msg = "#{meth}(#{str}) #{feature5079}"
|
||||
if ret.is_a?(Class) && (ret < Exception)
|
||||
assert_raises(ret){c.send(meth, str)}
|
||||
assert_raise(ret, msg) {c.send(meth, str)}
|
||||
else
|
||||
assert(c.send(meth, str) == ret, msg)
|
||||
assert_equal(ret, c.send(meth, str), msg)
|
||||
end
|
||||
assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
|
||||
end
|
||||
|
@ -201,33 +202,36 @@ class TestSymbol < Test::Unit::TestCase
|
|||
def test_no_inadvertent_symbol_creation3
|
||||
feature5089 = '[ruby-core:38447]'
|
||||
c = Class.new do
|
||||
def self.const_missing(const_name)
|
||||
raise NameError, const_name.to_s
|
||||
end
|
||||
def self.alias_method(str)
|
||||
super(:puts, str)
|
||||
end
|
||||
end
|
||||
s = "gadzoooks"
|
||||
{:alias_method => ["#{s}1", NameError],
|
||||
:autoload? => ["#{s}2", nil],
|
||||
:const_get => ["A#{s}3", NameError],
|
||||
:private_class_method => ["#{s}4", NameError],
|
||||
:private_constant => ["#{s}5", NameError],
|
||||
:private => ["#{s}6", NameError],
|
||||
:protected => ["#{s}7", NameError],
|
||||
:public => ["#{s}8", NameError],
|
||||
:public_class_method => ["#{s}9", NameError],
|
||||
:public_constant => ["#{s}10", NameError],
|
||||
:remove_method => ["#{s}11", NameError],
|
||||
:undef_method => ["#{s}12", NameError],
|
||||
:untrace_var => ["#{s}13", NameError],
|
||||
}.each do |meth, arr|
|
||||
str, ret = arr
|
||||
{
|
||||
:alias_method => ["#{s}1", NameError],
|
||||
:autoload? => ["#{s}2", nil],
|
||||
# :const_get => ["A#{s}3", NameError],
|
||||
:private_class_method => ["#{s}4", NameError],
|
||||
:private_constant => ["#{s}5", NameError],
|
||||
:private => ["#{s}6", NameError],
|
||||
:protected => ["#{s}7", NameError],
|
||||
:public => ["#{s}8", NameError],
|
||||
:public_class_method => ["#{s}9", NameError],
|
||||
:public_constant => ["#{s}10", NameError],
|
||||
:remove_method => ["#{s}11", NameError],
|
||||
:undef_method => ["#{s}12", NameError],
|
||||
:untrace_var => ["#{s}13", NameError],
|
||||
}.each do |meth, (str, ret)|
|
||||
msg = "#{meth}(#{str}) #{feature5089}"
|
||||
if ret.is_a?(Class) && (ret < Exception)
|
||||
assert_raises(ret){c.send(meth, str)}
|
||||
assert_raise(ret, msg) {c.send(meth, str)}
|
||||
else
|
||||
assert(c.send(meth, str) == ret, msg)
|
||||
assert_equal(ret, c.send(meth, str), msg)
|
||||
end
|
||||
assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
|
||||
assert(!Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue