summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/test/testunit/util/test_backtracefilter.rb
blob: d4e40ea6abe00f268985635018d3aa04f7f77fcf (plain)
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
require 'test/unit'

require 'test/unit/util/backtracefilter'

module Test::Unit::Util
  class TestBacktraceFilter < Test::Unit::TestCase
    include BacktraceFilter
    
    def test_filter_backtrace
      backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
        %q{tc_thing.rb:4:in 'a'},
        %q{tc_thing.rb:4:in 'test_stuff'},
        %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
        %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
        %q{C:\some\old\path\test\unit.rb:44:in 'run'},
        %q{tc_thing.rb:3}]
      assert_equal(backtrace[1..2], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")

backtrace = [%q{tc_thing.rb:4:in 'a'},
        %q{tc_thing.rb:4:in 'test_stuff'},
        %q{tc_thing.rb:3}]
      assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Shouldn't filter too much")

      backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
        %q{tc_thing.rb:4:in 'a'},
        %q{tc_thing.rb:4:in 'test_stuff'},
        %q{tc_thing.rb:3}]
      assert_equal(backtrace[1..3], filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
      
      backtrace = [%q{C:\some\old\path/test/unit/assertions.rb:44:in 'assert'},
        %q{C:\some\old\path/test/unit/testcase.rb:44:in 'send'},
        %q{C:\some\old\path\test\unit\testcase.rb:44:in 'run'},
        %q{C:\some\old\path\test\unit.rb:44:in 'run'}]
      assert_equal(backtrace, filter_backtrace(backtrace, %q{C:\some\old\path\test\unit}), "Should filter out all TestUnit-specific lines")
    end

    def test_nil_backtrace
      assert_equal(["No backtrace"], filter_backtrace(nil))
    end
  end
end