Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (39 sloc) 1.279 kb
b4f721c @abw *** empty log message ***
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/except.t
4 #
5 # Test the Template::Exception module.
6 #
7 # Written by Andy Wardley <abw@kfs.org>
8 #
9 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
10 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
11 #
12 # This is free software; you can redistribute it and/or modify it
13 # under the same terms as Perl itself.
14 #
15 # $Id$
16 #
17 #========================================================================
18
19 use strict;
20 use lib qw( ./lib ../lib );
21 use Template::Test;
22 use Template::Exception;
23
24 my $text = 'the current output buffer';
25
26 my $e1 = Template::Exception->new('e1.type', 'e1.info');
27 my $e2 = Template::Exception->new('e2.type', 'e2.info', \$text);
28
29 ok( $e1 );
30 ok( $e2 );
31 ok( $e1->type() eq 'e1.type' );
32 ok( $e2->info() eq 'e2.info' );
33
34 my @ti = $e1->type_info();
35 ok( $ti[0] eq 'e1.type' );
36 ok( $ti[1] eq 'e1.info' );
37
38 ok( $e2->as_string() eq 'e2.type error - e2.info' );
39 ok( $e2->text() eq 'the current output buffer' );
40
41 my $prepend = 'text to prepend ';
42 $e2->text(\$prepend);
43 ok( $e2->text() eq 'text to prepend the current output buffer' );
44
45 my @handlers = ('something', 'e2', 'e1.type');
46 ok( $e1->select_handler(@handlers) eq 'e1.type' );
47 ok( $e2->select_handler(@handlers) eq 'e2' );
Something went wrong with that request. Please try again.