Sha256: de1153f211d5496142e0af10a533c115b40679d3199bccf3c75eaa385bce4a83

Contents?: true

Size: 691 Bytes

Versions: 10

Compression:

Stored size: 691 Bytes

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'ruby-prof'

class DuplicateNames < Test::Unit::TestCase
  def test_names
    result = RubyProf::profile do
      str = %{module Foo; class Bar; def foo; end end end}

      eval str
      Foo::Bar.new.foo
      DuplicateNames.class_eval {remove_const :Foo}

      eval str
      Foo::Bar.new.foo
      DuplicateNames.class_eval {remove_const :Foo}

      eval str
      Foo::Bar.new.foo
    end

    # There should be 3 foo methods
    methods = result.threads.values.first.sort.reverse

    methods = methods.select do |method|
      method.full_name == 'DuplicateNames::Foo::Bar#foo'
    end

    assert_equal(3, methods.length)
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ruby-prof-0.10.8 test/duplicate_names_test.rb
ruby-prof-0.10.7 test/duplicate_names_test.rb
ruby-prof-0.10.6 test/duplicate_names_test.rb
ruby-prof-0.10.5 test/duplicate_names_test.rb
ruby-prof-0.10.4 test/duplicate_names_test.rb
ruby-prof-0.10.2 test/duplicate_names_test.rb
acunote-ruby-prof-0.9.2 test/duplicate_names_test.rb
ruby-prof-0.9.2 test/duplicate_names_test.rb
ruby-prof-0.9.1 test/duplicate_names_test.rb
ruby-prof-0.9.0 test/duplicate_names_test.rb