Commit | Line | Data |
f7c69158 |
1 | #!/usr/bin/perl -wT |
2 | |
3 | use strict; |
4 | use lib 't/lib'; |
5 | |
6 | use Test::More tests => 7; |
7 | |
8 | use_ok('TAP::Object'); |
9 | |
10 | can_ok( 'TAP::Object', 'new' ); |
11 | can_ok( 'TAP::Object', '_initialize' ); |
12 | can_ok( 'TAP::Object', '_croak' ); |
13 | |
14 | { |
15 | |
16 | package TAP::TestObj; |
17 | use vars qw(@ISA); |
18 | @ISA = qw(TAP::Object); |
19 | |
20 | sub _initialize { |
21 | my $self = shift; |
22 | $self->{init} = 1; |
23 | $self->{args} = [@_]; |
24 | return $self; |
25 | } |
26 | } |
27 | |
28 | # I know these tests are simple, but they're documenting the base API, so |
29 | # necessary none-the-less... |
30 | my $obj = TAP::TestObj->new( 'foo', { bar => 'baz' } ); |
31 | ok( $obj->{init}, '_initialize' ); |
32 | is_deeply( $obj->{args}, [ 'foo', { bar => 'baz' } ], '_initialize: args' ); |
33 | |
34 | eval { $obj->_croak('eek') }; |
35 | my $err = $@; |
36 | like( $err, qr/^eek/, '_croak' ); |
37 | |