Sha256: 356307b8f136a1c715222a268bac019f5ade78287ba452e5c8dac357303bec3d

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/env ruby
# $Id: test-tracelines.rb 235 2010-12-25 14:22:47Z rockyb $
require 'test/unit'
require 'fileutils'
require 'tempfile'

# Test TestLineNumbers module
class TestLineNumbers1 < Test::Unit::TestCase

  @@TEST_DIR = File.expand_path(File.dirname(__FILE__))
  @@TOP_SRC_DIR = File.join(@@TEST_DIR, '..', 'lib')
  require File.join(@@TOP_SRC_DIR, 'tracelines.rb')

  @@rcov_file = File.join(@@TEST_DIR, 'rcov-bug.rb')
  # File.open(@@rcov_file, 'r') {|fp|
  #   first_line = fp.readline[1..-2]
  #   @@rcov_lnums = eval(first_line, binding, __FILE__, __LINE__)
  # }
  @@rcov_lnums = [3, 7, 8]

  def test_for_file
    rcov_lines = TraceLineNumbers.lnums_for_file(@@rcov_file)
    assert_equal(@@rcov_lnums, rcov_lines)
  end

  def test_for_string
    string = "# Some rcov bugs.\nz = \"\nNow is the time\n\"\n\nz =~ \n     /\n      5\n     /ix\n"
    rcov_lines = TraceLineNumbers.lnums_for_str(string)
    check = [2, 6, 7]
    # check = [2, 9]
    assert_equal(check, rcov_lines)
  end

  def test_for_string_array
    lines = File.open(@@rcov_file).readlines
    rcov_lines = 
      TraceLineNumbers.lnums_for_str_array(lines)
    assert_equal(@@rcov_lnums, rcov_lines)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rbx-linecache-1.3-universal-rubinius-2.0 test/test-tracelines.rb
rbx-linecache-1.2-universal-rubinius-1.2 test/test-tracelines.rb
rbx-linecache-1.1-universal-rubinius-1.2 test/test-tracelines.rb
rbx-linecache-1.0-universal-rubinius-1.2 test/test-tracelines.rb
rbx-linecache-0.44-universal-rubinius-1.2 test/test-tracelines.rb
rbx-linecache-0.44-universal-rubinius test/test-tracelines.rb