Sha256: 45882f0cd82a34595f1fb3f7660507960dbe8c8b82955b3339a0ca992579b865

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env ruby
require 'test/unit'
require 'rubygems'; require 'require_relative'
require_relative '../../app/util'

class TestAppUtil < Test::Unit::TestCase
  include Trepan::Util
  def test_safe_repr
    string = 'The time has come to talk of many things.'
    assert_equal(string, safe_repr(string, 50))
    assert_equal('The time...  things.', safe_repr(string, 17))
    assert_equal('"The tim... things."', safe_repr(string.inspect, 17))
    string = "'The time has come to talk of many things.'"
    assert_equal("'The tim... things.'", safe_repr(string, 17))
  end

  # def test_find_main_script
  #   locs = Rubinius::VM.backtrace(0, true)
  #   i = find_main_script(locs)
  #   assert_equal(true, !!i)
  #   assert_equal(false, !!find_main_script(locs[0..i]))
  # end

  def test_abbrev
    list = %w(disassemble disable distance up)
    [['dis', 'dis'],
     ['disas', 'disassemble'],
     ['u', 'up'],
     ['upper', 'upper'],
     ['foo', 'foo']].each do |name, expect|
      assert_equal expect, uniq_abbrev(list, name)
    end
  end

  def test_extract_expression
    [['if condition("if")',        'condition("if")'],
     ['until until_termination',   'until_termination'],
     ['return return_value',       'return_value'],
     ['nothing_to_be.done',         'nothing_to_be.done'],
    ].each do |stmt, expect|
      assert_equal expect, extract_expression(stmt)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rb8-trepanning-0.1.6 test/unit/test-app-util.rb
rb8-trepanning-0.1.5 test/unit/test-app-util.rb
rb8-trepanning-0.1.4 test/unit/test-app-util.rb
rb8-trepanning-0.1.3 test/unit/test-app-util.rb
rb8-trepanning-0.1.3-universal-ruby-1.9.2 test/unit/test-app-util.rb
rb8-trepanning-0.1.3-universal-ruby-1.8.7 test/unit/test-app-util.rb