Sha256: 4ae5ef6f9c3cf55e1b7f5243d5c3a40a8ffc1949abe840bd859726cd62c69fb4

Contents?: true

Size: 877 Bytes

Versions: 21

Compression:

Stored size: 877 Bytes

Contents

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

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

# Need to use wall time for this test due to the sleep calls
RubyProf::measure_mode = RubyProf::WALL_TIME

module Foo
  def Foo::hello
    sleep(0.5)
  end
end

module Bar
  def Bar::hello
    sleep(0.5)
    Foo::hello
  end

  def hello
    sleep(0.5)
    Bar::hello
  end
end

include Bar

class ModuleTest < Test::Unit::TestCase
  def test_nested_modules
    result = RubyProf.profile do
      hello
    end

    methods = result.threads.first.methods

    # Length should be 5
    assert_equal(5, methods.length)

    # these methods should be in there... (hard to tell order though).
    for name in ['ModuleTest#test_nested_modules','Bar#hello','Kernel#sleep','<Module::Bar>#hello','<Module::Foo>#hello']
      assert methods.map(&:full_name).include?( name )
    end
  end
end

Version data entries

21 entries across 19 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/ruby-prof-0.15.1/test/module_test.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/ruby-prof-0.15.1/test/module_test.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/ruby-prof-0.15.1/test/module_test.rb
ruby-prof-0.15.2 test/module_test.rb
ruby-prof-0.15.1 test/module_test.rb
ruby-prof-0.15.0 test/module_test.rb
ruby-prof-0.14.2 test/module_test.rb
ruby-prof-0.14.1 test/module_test.rb
ruby-prof-0.14.0 test/module_test.rb
ruby-prof-0.13.1 test/module_test.rb
ruby-prof-0.13.0 test/module_test.rb
ruby-prof-0.12.2 test/module_test.rb
ruby-prof-0.12.1-x86-mingw32 test/module_test.rb
ruby-prof-0.12.1 test/module_test.rb
ruby-prof-0.11.3 test/module_test.rb
ruby-prof-0.11.2-x86-mingw32 test/module_test.rb
ruby-prof-0.11.2 test/module_test.rb
ruby-prof-0.11.0.rc3-x86-mingw32 test/module_test.rb
ruby-prof-0.11.0.rc3 test/module_test.rb
ruby-prof-0.11.0.rc2-x86-mingw32 test/module_test.rb