test/exclude_methods_test.rb in ruby-prof-1.1.0 vs test/exclude_methods_test.rb in ruby-prof-1.2.0

- old
+ new

@@ -41,17 +41,16 @@ def test_methods_can_be_profiled obj = ExcludeMethodsClass.new prf = RubyProf::Profile.new - result = prf.profile { 5.times {obj.a} } + result = prf.profile {obj.a} methods = result.threads.first.methods.sort.reverse - assert_equal(10, methods.count) assert_equal('ExcludeMethodsTest#test_methods_can_be_profiled', methods[0].full_name) - assert_equal('Integer#times', methods[1].full_name) - assert_equal('ExcludeMethodsClass#a', methods[2].full_name) + assert_equal('ExcludeMethodsClass#a', methods[1].full_name) + assert_equal('Integer#times', methods[2].full_name) assert_equal('ExcludeMethodsClass#b', methods[3].full_name) assert_equal('<Class::ExcludeMethodsClass>#e', methods[4].full_name) assert_equal('<Class::ExcludeMethodsClass>#f', methods[5].full_name) assert_equal('Kernel#sleep', methods[6].full_name) assert_equal('ExcludeMethodsModule#c', methods[7].full_name) @@ -63,11 +62,11 @@ obj = ExcludeMethodsClass.new prf = RubyProf::Profile.new prf.exclude_methods!(Integer, :times) - result = prf.profile { 5.times {obj.a} } + result = prf.profile {obj.a} methods = result.threads.first.methods.sort.reverse assert_equal(9, methods.count) assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden1', methods[0].full_name) assert_equal('ExcludeMethodsClass#a', methods[1].full_name) @@ -86,11 +85,11 @@ prf.exclude_methods!(Integer, :times) prf.exclude_methods!(ExcludeMethodsClass.singleton_class, :f) prf.exclude_methods!(ExcludeMethodsModule.singleton_class, :d) - result = prf.profile { 5.times {obj.a} } + result = prf.profile {obj.a} methods = result.threads.first.methods.sort.reverse assert_equal(7, methods.count) assert_equal('ExcludeMethodsTest#test_methods_can_be_hidden2', methods[0].full_name) assert_equal('ExcludeMethodsClass#a', methods[1].full_name) @@ -105,17 +104,23 @@ obj = ExcludeMethodsClass.new prf = RubyProf::Profile.new prf.exclude_common_methods! - result = prf.profile { 5.times {obj.a} } + result = prf.profile {obj.a} methods = result.threads.first.methods.sort.reverse assert_equal(9, methods.count) assert_equal('ExcludeMethodsTest#test_exclude_common_methods1', methods[0].full_name) assert_equal('ExcludeMethodsClass#a', methods[1].full_name) assert_equal('ExcludeMethodsClass#b', methods[2].full_name) + assert_equal('<Class::ExcludeMethodsClass>#e', methods[3].full_name) + assert_equal('<Class::ExcludeMethodsClass>#f', methods[4].full_name) + assert_equal('Kernel#sleep', methods[5].full_name) + assert_equal('ExcludeMethodsModule#c', methods[6].full_name) + assert_equal('<Module::ExcludeMethodsModule>#d', methods[7].full_name) + assert_equal('Kernel#class', methods[8].full_name) end def test_exclude_common_methods2 obj = ExcludeMethodsClass.new @@ -128,17 +133,17 @@ assert_equal('ExcludeMethodsClass#b', methods[2].full_name) end private - def assert_method_has_been_eliminated(result, eliminated_method) + def assert_method_has_been_excluded(result, excluded_method) result.threads.each do |thread| thread.methods.each do |method| - method.call_infos.each do |ci| - assert(ci.target != eliminated_method, "broken self") - assert(ci.parent.target != eliminated_method, "broken parent") if ci.parent + method.call_trees.each do |ci| + assert(ci.target != excluded_method, "broken self") + assert(ci.parent.target != excluded_method, "broken parent") if ci.parent ci.children.each do |callee| - assert(callee.target != eliminated_method, "broken kid") + assert(callee.target != excluded_method, "broken kid") end end end end end