/usr/share/perl5/Test/Unit/Assertion/Exception.pm is in libtest-unit-perl 0.25-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | package Test::Unit::Assertion::Exception;
use strict;
use base qw/Test::Unit::Assertion/;
use Carp;
use Error qw/:try/;
use Test::Unit::Debug qw(debug);
my $deparser;
sub new {
my $class = shift;
my $exception_class = shift;
croak "$class\::new needs an exception class" unless $exception_class;
bless \$exception_class => $class;
}
sub do_assertion {
my $self = shift;
my $coderef = shift;
my $exception_class = $$self;
my $exception;
try {
&$coderef();
}
catch $exception_class with {
$exception = shift;
};
if (! $exception || ! $exception->isa($$self)) {
$self->fail(@_ ? $_[0] : "No $exception_class was raised");
}
return $exception; # so that it can be stored in the test for the
# user to get at.
}
sub to_string {
my $self = shift;
return "$$self exception assertion";
}
1;
__END__
=head1 NAME
Test::Unit::Assertion::Exception - A assertion for raised exceptions
=head1 SYNOPSIS
require Test::Unit::Assertion::Exception;
my $assert_raised =
Test::Unit::Assertion::Exception->new('MyException');
# This should succeed
$assert_eq->do_assertion(sub { MyException->throw() });
# This should fail
$assert_eq->do_assertion(sub { });
=head1 DESCRIPTION
Although the SYNOPSIS shows how you'd use
Test::Unit::Assertion::Exception directly, it is more sensibly used
indirectly via C<Test::Unit::Test::assert_raises()>, which
instantiates a C<Test::Unit::Assertion::Exception>.
=head1 AUTHOR
Copyright (c) 2001 Piers Cawley E<lt>pdcawley@iterative-software.comE<gt>.
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
=head1 SEE ALSO
=over 4
=item *
L<Test::Unit::TestCase>
=item *
L<Test::Unit::Assertion>
=back
|