Sha256: 016414c58ca891ff03698d644a34484ab2b3300fcd6747aad2647457eb8f6286

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require 'rubygems'; require 'require_relative'
require 'linecache'
require_relative '../../processor/main' # Have to include before frame!
                                        # FIXME
require_relative '../../processor/location'
require_relative '../../processor/mock'

$errors = []
$msgs   = []

# Test Trepan::CmdProcessor location portion
class TestCmdProcessorLocation < Test::Unit::TestCase

  def setup
    $errors = []
    $msgs   = []
    @dbgr = MockDebugger::MockDebugger.new
    @proc = Trepan::CmdProcessor.new(@dbgr)
    @file = File.basename(__FILE__)
  end

  # Test resolve_file_with_dir() and line_at()
  def test_line_at
    @proc.settings[:directory] = ''
    assert_equal(nil, @proc.resolve_file_with_dir(@file))
    if File.expand_path(Dir.pwd) == File.expand_path(File.dirname(__FILE__))
      line = @proc.line_at(@file, __LINE__)
      assert_match(/line = @proc.line_at/, line)
    else
      assert_equal(nil, @proc.line_at(@file, __LINE__))
    end
    dir = @proc.settings[:directory] = File.dirname(__FILE__)
    assert_equal(File.join(dir, @file), 
                 @proc.resolve_file_with_dir('test-proc-location.rb'))
    test_line = 'test_line'
    line = @proc.line_at(@file, __LINE__-1)
    assert_match(/#{line}/, line)
  end

  def test_loc_and_text
    @proc.frame_index = 0
    @proc.frame_initialize
    @proc.frame_setup
    LineCache::clear_file_cache
    dir = @proc.settings[:directory] = File.dirname(__FILE__)
    loc, line_no, text = @proc.loc_and_text('hi')
    assert loc and line_no.is_a?(Fixnum) and text 
    # FIXME test that filename remapping works.
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rbx-trepanning-0.0.7-universal-rubinius-1.2 test/unit/test-proc-location.rb
rbx-trepanning-0.0.6-universal-rubinius-1.2 test/unit/test-proc-location.rb
rbx-trepanning-0.0.5-universal-rubinius-1.2.1 test/unit/test-proc-location.rb
rbx-trepanning-0.0.4-universal-rubinius-1.2 test/unit/test-proc-location.rb
rbx-trepanning-0.0.3-universal-rubinius-1.2 test/unit/test-proc-location.rb