File: module_test.rb

package info (click to toggle)
ruby-prof 0.4.1-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 348 kB
  • ctags: 275
  • sloc: ruby: 990; ansic: 939; makefile: 20
file content (45 lines) | stat: -rwxr-xr-x 671 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby

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


module Foo
  def Foo::hello
  end
end

module Bar
  def Bar::hello
    Foo::hello
  end
  
  def hello
    Bar::hello
  end
end

include Bar

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

		methods = result.threads.values.first
	    
  	# Length should be 4s
  	assert_equal(4, methods.length)
    
  	method1 = methods['Bar#hello']
  	assert_not_nil(method1)
  	
  	method1 = methods['<Module::Bar>#hello']
  	assert_not_nil(method1)
  	
  	method1 = methods['<Module::Foo>#hello']
  	assert_not_nil(method1)
	end	
end