lib/test/unit/testcase.rb in test-unit-3.0.2 vs lib/test/unit/testcase.rb in test-unit-3.0.3
- old
+ new
@@ -107,20 +107,19 @@
require "test/unit"
DESCENDANTS << sub_class
super
end
- @@added_methods = {}
+ @@added_method_names = {}
def method_added(name) # :nodoc:
super
- _added_methods = added_methods
+ added_method_names = (@@added_method_names[self] ||= {})
stringified_name = name.to_s
- if _added_methods.include?(stringified_name)
+ if added_method_names.key?(stringified_name)
attribute(:redefined, {:backtrace => caller}, {}, stringified_name)
end
- _attributes = attributes_table[stringified_name] || {}
- source_location = _attributes[:source_location]
+ source_location = find_attribute(stringified_name, :source_location)
if source_location
path, line = source_location
else
path, line, = caller[0].split(/:(\d+)/,2)
line = line.to_i if line
@@ -128,15 +127,15 @@
method_locations << {
:method_name => stringified_name,
:path => path,
:line => line,
}
- _added_methods << stringified_name
+ added_method_names[stringified_name] = true
end
- def added_methods # :nodoc:
- @@added_methods[self] ||= []
+ def added_method_names # :nodoc:
+ (@@added_method_names[self] ||= {}).keys
end
# Rolls up all of the test* methods in the fixture into
# one suite, creating a new instance of the fixture for
# each method.
@@ -337,11 +336,11 @@
# @return [Test::Unit::TestCase] Created sub test case class.
def sub_test_case(name, &block)
parent_test_case = self
sub_test_case = Class.new(self) do
singleton_class = class << self; self; end
- singleton_class.send(:define_method, :name) do
+ singleton_class.__send__(:define_method, :name) do
[parent_test_case.name, name].compact.join("::")
end
end
sub_test_case.class_eval(&block)
sub_test_case
@@ -702,10 +701,10 @@
def handle_exception(exception)
self.class.exception_handlers.each do |handler|
if handler.respond_to?(:call)
handled = handler.call(self, exception)
else
- handled = send(handler, exception)
+ handled = __send__(handler, exception)
end
return true if handled
end
false
end