Sha256: 18f483ccc8c84ace1093bf351f45f7bf38a628eb968987396a70566335f56079

Contents?: true

Size: 865 Bytes

Versions: 13

Compression:

Stored size: 865 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 < 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

13 entries across 13 versions & 3 rubygems

Version Path
ruby-prof-0.17.0 test/module_test.rb
airbnb-ruby-prof-0.0.1 test/module_test.rb
ruby-prof-0.16.2 test/module_test.rb
ruby-prof-0.16.1 test/module_test.rb
ruby-prof-0.16.0 test/module_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/ruby-prof-0.15.9/test/module_test.rb
ruby-prof-0.15.9 test/module_test.rb
ruby-prof-0.15.8 test/module_test.rb
ruby-prof-0.15.7 test/module_test.rb
ruby-prof-0.15.6 test/module_test.rb
ruby-prof-0.15.5 test/module_test.rb
ruby-prof-0.15.4 test/module_test.rb
ruby-prof-0.15.3 test/module_test.rb