8 # Can't use Test.pm, that's a 5.005 thing.
14 # Utility testing functions.
16 my($test, $name) = @_;
18 $ok .= "not " unless $test;
19 $ok .= "ok $test_num";
20 $ok .= " - $name" if defined $name;
33 push @INC, '../t/lib';
34 require Test::Simple::Catch::More;
35 my($out, $err) = Test::Simple::Catch::More::caught();
37 Test::More->import(tests => 10);
39 # Preserve the line numbers.
42 is( "foo", "bar", 'foo is bar?');
43 isnt("foo", "foo", 'foo isnt foo?' );
44 isn't("foo", "foo",'foo isn\'t foo?' );
46 like( "foo", '/that/', 'is foo like that' );
50 can_ok('Mooble::Hooble::Yooble', qw(this that));
51 isa_ok(bless([], "Foo"), "Wibble");
53 use_ok('Hooble::mooble::yooble');
54 require_ok('ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble');
57 My::Test::ok($$out eq <<OUT, 'failing output');
60 not ok 2 - foo is bar?
61 not ok 3 - foo isnt foo?
62 not ok 4 - foo isn't foo?
63 not ok 5 - is foo like that
65 not ok 7 - Mooble::Hooble::Yooble->can(...)
66 not ok 8 - object->isa('Wibble')
67 not ok 9 - use Hooble::mooble::yooble;
68 not ok 10 - require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble;
72 # Failed test ($0 at line 31)
73 # Failed test ($0 at line 32)
76 # Failed test ($0 at line 33)
77 # it should not be 'foo'
79 # Failed test ($0 at line 34)
80 # it should not be 'foo'
82 # Failed test ($0 at line 36)
84 # doesn't match '/that/'
85 # Failed test ($0 at line 38)
86 # Failed test ($0 at line 40)
87 # Mooble::Hooble::Yooble->can('this') failed
88 # Mooble::Hooble::Yooble->can('that') failed
89 # Failed test ($0 at line 41)
90 # The object isn't a 'Wibble'
93 my $filename = quotemeta $0;
94 my $more_err_re = <<ERR;
95 # Failed test \\($filename at line 43\\)
96 # Tried to use 'Hooble::mooble::yooble'.
97 # Error: Can't locate Hooble.* in \\\@INC .*
98 # Failed test \\($filename at line 44\\)
99 # Tried to require 'ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble'.
100 # Error: Can't locate ALL.* in \\\@INC .*
101 # Looks like you failed 10 tests of 10.
104 unless( My::Test::ok($$err =~ /^\Q$err_re\E$more_err_re$/,
105 'failing errors') ) {
106 print map "# $_", $$err;