Sha256: 0d31844daa1aa9dc331638d66c85d1298ab1cebf6cf795f5c1f125254e4424c6

Contents?: true

Size: 850 Bytes

Versions: 3

Compression:

Stored size: 850 Bytes

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

require File.expand_path('../test_helper', __FILE__)

class CallInfoVisitorTest < TestCase
  def setup
    # Need to use wall time for this test due to the sleep calls
    RubyProf::measure_mode = RubyProf::WALL_TIME
  end

  def test_visit
    result = RubyProf.profile do
      RubyProf::C1.sleep_wait
    end

    visitor = RubyProf::CallInfoVisitor.new(result.threads.first.root_methods)

    method_names = Array.new

    visitor.visit do |call_info, event|
      method_names << call_info.target.full_name if event == :enter
    end

    assert_equal(3, method_names.length)
    assert_equal("CallInfoVisitorTest#test_visit", method_names[0])
    assert_equal("<Class::RubyProf::C1>#sleep_wait", method_names[1])
    assert_equal("Kernel#sleep", method_names[2])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-prof-1.1.0-x64-mingw32 test/call_info_visitor_test.rb
ruby-prof-1.1.0 test/call_info_visitor_test.rb
ruby-prof-1.0.0 test/call_info_visitor_test.rb