source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/test/unit/failure.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.3 KB
Line 
1#--
2#
3# Author:: Nathaniel Talbott.
4# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
5# License:: Ruby license.
6
7module Test
8 module Unit
9
10 # Encapsulates a test failure. Created by Test::Unit::TestCase
11 # when an assertion fails.
12 class Failure
13 attr_reader :test_name, :location, :message
14
15 SINGLE_CHARACTER = 'F'
16
17 # Creates a new Failure with the given location and
18 # message.
19 def initialize(test_name, location, message)
20 @test_name = test_name
21 @location = location
22 @message = message
23 end
24
25 # Returns a single character representation of a failure.
26 def single_character_display
27 SINGLE_CHARACTER
28 end
29
30 # Returns a brief version of the error description.
31 def short_display
32 "#@test_name: #{@message.split("\n")[0]}"
33 end
34
35 # Returns a verbose version of the error description.
36 def long_display
37 location_display = if(location.size == 1)
38 location[0].sub(/\A(.+:\d+).*/, ' [\\1]')
39 else
40 "\n [#{location.join("\n ")}]"
41 end
42 "Failure:\n#@test_name#{location_display}:\n#@message"
43 end
44
45 # Overridden to return long_display.
46 def to_s
47 long_display
48 end
49 end
50 end
51end
Note: See TracBrowser for help on using the repository browser.