test/basic_test.rb in ruby-prof-0.7.4 vs test/basic_test.rb in ruby-prof-0.7.5

- old
+ new

@@ -113,10 +113,16 @@ assert_in_delta(0.1, methods[2].total_time, 0.01) assert_in_delta(0, methods[2].wait_time, 0.01) assert_in_delta(0.1, methods[2].self_time, 0.01) end + + if RUBY_VERSION < '1.9' + PARENT = Object + else + PARENT = BasicObject + end def test_instance_methods result = RubyProf.profile do C1.new.hello end @@ -134,25 +140,26 @@ assert_equal('BasicTest#test_instance_methods', methods[0].full_name) assert_equal('C1#hello', methods[1].full_name) assert_equal('Kernel#sleep', methods[2].full_name) assert_equal('Class#new', methods[3].full_name) - assert_equal('<Class::Object>#allocate', methods[4].full_name) - assert_equal('Object#initialize', methods[5].full_name) + + assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name) + assert_equal("#{PARENT}#initialize", methods[5].full_name) # Check times - assert_in_delta(0.2, methods[0].total_time, 0.01) + assert_in_delta(0.2, methods[0].total_time, 0.02) assert_in_delta(0, methods[0].wait_time, 0.01) assert_in_delta(0, methods[0].self_time, 0.01) - assert_in_delta(0.2, methods[1].total_time, 0.01) + assert_in_delta(0.2, methods[1].total_time, 0.02) assert_in_delta(0, methods[1].wait_time, 0.01) assert_in_delta(0, methods[1].self_time, 0.01) - assert_in_delta(0.2, methods[2].total_time, 0.01) + assert_in_delta(0.2, methods[2].total_time, 0.02) assert_in_delta(0, methods[2].wait_time, 0.01) - assert_in_delta(0.2, methods[2].self_time, 0.01) + assert_in_delta(0.2, methods[2].self_time, 0.02) assert_in_delta(0, methods[3].total_time, 0.01) assert_in_delta(0, methods[3].wait_time, 0.01) assert_in_delta(0, methods[3].self_time, 0.01) @@ -181,21 +188,21 @@ assert_equal('BasicTest#test_module_methods', methods[0].full_name) assert_equal('M1#hello', methods[1].full_name) assert_equal('Kernel#sleep', methods[2].full_name) # Check times - assert_in_delta(0.3, methods[0].total_time, 0.01) + assert_in_delta(0.3, methods[0].total_time, 0.02) assert_in_delta(0, methods[0].wait_time, 0.01) assert_in_delta(0, methods[0].self_time, 0.01) - assert_in_delta(0.3, methods[1].total_time, 0.01) + assert_in_delta(0.3, methods[1].total_time, 0.02) assert_in_delta(0, methods[1].wait_time, 0.01) assert_in_delta(0, methods[1].self_time, 0.01) - assert_in_delta(0.3, methods[2].total_time, 0.01) + assert_in_delta(0.3, methods[2].total_time, 0.02) assert_in_delta(0, methods[2].wait_time, 0.01) - assert_in_delta(0.3, methods[2].self_time, 0.01) + assert_in_delta(0.3, methods[2].self_time, 0.02) end def test_module_instance_methods result = RubyProf.profile do C2.new.hello @@ -214,24 +221,24 @@ assert_equal('BasicTest#test_module_instance_methods', methods[0].full_name) assert_equal('M1#hello', methods[1].full_name) assert_equal('Kernel#sleep', methods[2].full_name) assert_equal('Class#new', methods[3].full_name) - assert_equal('<Class::Object>#allocate', methods[4].full_name) - assert_equal('Object#initialize', methods[5].full_name) - + assert_equal("<Class::#{PARENT}>#allocate", methods[4].full_name) + assert_equal("#{PARENT}#initialize", methods[5].full_name) + # Check times - assert_in_delta(0.3, methods[0].total_time, 0.01) - assert_in_delta(0, methods[0].wait_time, 0.01) + assert_in_delta(0.3, methods[0].total_time, 0.02) + assert_in_delta(0, methods[0].wait_time, 0.02) assert_in_delta(0, methods[0].self_time, 0.01) - assert_in_delta(0.3, methods[1].total_time, 0.01) + assert_in_delta(0.3, methods[1].total_time, 0.02) assert_in_delta(0, methods[1].wait_time, 0.01) assert_in_delta(0, methods[1].self_time, 0.01) - assert_in_delta(0.3, methods[2].total_time, 0.01) + assert_in_delta(0.3, methods[2].total_time, 0.02) assert_in_delta(0, methods[2].wait_time, 0.01) - assert_in_delta(0.3, methods[2].self_time, 0.01) + assert_in_delta(0.3, methods[2].self_time, 0.02) assert_in_delta(0, methods[3].total_time, 0.01) assert_in_delta(0, methods[3].wait_time, 0.01) assert_in_delta(0, methods[3].self_time, 0.01) \ No newline at end of file