diff options
| author | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-12 03:12:14 +0000 |
|---|---|---|
| committer | ntalbott <ntalbott@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-12 03:12:14 +0000 |
| commit | f4fade43ce5d51ab9e35463a0ee093a695286741 (patch) | |
| tree | 4354dc87a540b777a7eb6a2276f44be51ec8bebb /lib/test/unit/failure.rb | |
| parent | 045623d3287ee000a1c7e8275a643e88081132d2 (diff) | |
| download | ruby-f4fade43ce5d51ab9e35463a0ee093a695286741.tar.gz ruby-f4fade43ce5d51ab9e35463a0ee093a695286741.tar.xz ruby-f4fade43ce5d51ab9e35463a0ee093a695286741.zip | |
Initial revision
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test/unit/failure.rb')
| -rw-r--r-- | lib/test/unit/failure.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/test/unit/failure.rb b/lib/test/unit/failure.rb new file mode 100644 index 000000000..6817d8f3b --- /dev/null +++ b/lib/test/unit/failure.rb @@ -0,0 +1,45 @@ +# :nodoc: +# +# Author:: Nathaniel Talbott. +# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved. +# License:: Ruby license. + +module Test + module Unit + + # Encapsulates a test failure. Created by Test::Unit::TestCase + # when an assertion fails. + class Failure + attr_reader(:location, :message) + + SINGLE_CHARACTER = 'F' + + # Creates a new Failure with the given location and + # message. + def initialize(location, message) + @location = location + @message = message + end + + # Returns a single character representation of a failure. + def single_character_display + SINGLE_CHARACTER + end + + # Returns a brief version of the error description. + def short_display + "#{@location}:\n#{@message}" + end + + # Returns a verbose version of the error description. + def long_display + "Failure!!!\n#{short_display}" + end + + # Overridden to return long_display. + def to_s + long_display + end + end + end +end |
