class LineNumbersTest

  1. test/line_number_test.rb

-- Tests ----

Methods

Public Instance

  1. test_c_function
  2. test_function_line_no

Public Instance methods

test_c_function ()
[show source]
# File test/line_number_test.rb, line 45
def test_c_function
  numbers = LineNumbers.new

  result = RubyProf.profile do
    numbers.method3
  end

  methods = result.threads.values.first.sort_by {|method| method.full_name}
  assert_equal(3, methods.length)

  # Methods:
  #   LineNumbers#method3
  #   LineNumbersTest#test_c_function
  #   Kernel#sleep

  method = methods[0]
  assert_equal('Kernel#sleep', method.full_name)
  assert_equal(0, method.line)

  method = methods[1]
  assert_equal('LineNumbers#method3', method.full_name)
  assert_equal(17, method.line)

  method = methods[2]
  assert_equal('LineNumbersTest#test_c_function', method.full_name)
  assert_equal(51, method.line)
end
test_function_line_no ()
[show source]
# File test/line_number_test.rb, line 22
def test_function_line_no
  numbers = LineNumbers.new

  result = RubyProf.profile do
    numbers.method2
  end

  methods = result.threads.values.first.sort.reverse
  assert_equal(3, methods.length)

  method = methods[0]
  assert_equal('LineNumbersTest#test_function_line_no', method.full_name)
  assert_equal(28, method.line)

  method = methods[1]
  assert_equal('LineNumbers#method2', method.full_name)
  assert_equal(12, method.line)

  method = methods[2]
  assert_equal('LineNumbers#method1', method.full_name)
  assert_equal(8, method.line)
end