source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/test/unit/error.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 1.4 KB
Line 
1#--
2#
3# Author:: Nathaniel Talbott.
4# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
5# License:: Ruby license.
6
7require 'test/unit/util/backtracefilter'
8
9module Test
10 module Unit
11
12 # Encapsulates an error in a test. Created by
13 # Test::Unit::TestCase when it rescues an exception thrown
14 # during the processing of a test.
15 class Error
16 include Util::BacktraceFilter
17
18 attr_reader(:test_name, :exception)
19
20 SINGLE_CHARACTER = 'E'
21
22 # Creates a new Error with the given test_name and
23 # exception.
24 def initialize(test_name, exception)
25 @test_name = test_name
26 @exception = exception
27 end
28
29 # Returns a single character representation of an error.
30 def single_character_display
31 SINGLE_CHARACTER
32 end
33
34 # Returns the message associated with the error.
35 def message
36 "#{@exception.class.name}: #{@exception.message}"
37 end
38
39 # Returns a brief version of the error description.
40 def short_display
41 "#@test_name: #{message.split("\n")[0]}"
42 end
43
44 # Returns a verbose version of the error description.
45 def long_display
46 backtrace = filter_backtrace(@exception.backtrace).join("\n ")
47 "Error:\n#@test_name:\n#{message}\n #{backtrace}"
48 end
49
50 # Overridden to return long_display.
51 def to_s
52 long_display
53 end
54 end
55 end
56end
Note: See TracBrowser for help on using the repository browser.