Move Test::Harness from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / Test-Harness / t / object.t
CommitLineData
f7c69158 1#!/usr/bin/perl -wT
2
3use strict;
4use lib 't/lib';
5
6use Test::More tests => 7;
7
8use_ok('TAP::Object');
9
10can_ok( 'TAP::Object', 'new' );
11can_ok( 'TAP::Object', '_initialize' );
12can_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...
30my $obj = TAP::TestObj->new( 'foo', { bar => 'baz' } );
31ok( $obj->{init}, '_initialize' );
32is_deeply( $obj->{args}, [ 'foo', { bar => 'baz' } ], '_initialize: args' );
33
34eval { $obj->_croak('eek') };
35my $err = $@;
36like( $err, qr/^eek/, '_croak' );
37