Upgrade to Test::Simple 0.54
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / todo.t
CommitLineData
33459055 1#!perl -w
2
d020a79a 3BEGIN {
a9153838 4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = '../lib';
7 }
33459055 8}
9
30e302f8 10require Test::Harness;
11use Test::More;
12
0257f296 13# Shut up a "used only once" warning in 5.5.4.
14my $th_version = $Test::Harness::VERSION = $Test::Harness::VERSION;
15$th_version =~ s/_//; # for X.Y_Z alpha versions
16
17# TODO requires a fairly new version of Test::Harness
30e302f8 18if( $th_version < 2.03 ) {
19 plan tests => 1;
20 fail "Need Test::Harness 2.03 or up. You have $th_version.";
21 exit;
d020a79a 22}
23
0257f296 24plan tests => 18;
30e302f8 25
26
d020a79a 27$Why = 'Just testing the todo interface.';
28
7483b81c 29my $is_todo;
d020a79a 30TODO: {
31 local $TODO = $Why;
32
33 fail("Expected failure");
34 fail("Another expected failure");
d020a79a 35
7483b81c 36 $is_todo = Test::More->builder->todo;
37}
d020a79a 38
39pass("This is not todo");
7483b81c 40ok( $is_todo, 'TB->todo' );
d020a79a 41
42
43TODO: {
44 local $TODO = $Why;
45
46 fail("Yet another failure");
47}
48
49pass("This is still not todo");
0cd946aa 50
51
52TODO: {
53 local $TODO = "testing that error messages don't leak out of todo";
54
55 ok( 'this' eq 'that', 'ok' );
56
57 like( 'this', '/that/', 'like' );
58 is( 'this', 'that', 'is' );
59 isnt( 'this', 'this', 'isnt' );
60
61 can_ok('Fooble', 'yarble');
62 isa_ok('Fooble', 'yarble');
63 use_ok('Fooble');
64 require_ok('Fooble');
65}
a9153838 66
67
68TODO: {
69 todo_skip "Just testing todo_skip", 2;
70
71 fail("Just testing todo");
72 die "todo_skip should prevent this";
73 pass("Again");
74}
0257f296 75
76
77{
78 my $warning;
79 local $SIG{__WARN__} = sub { $warning = join "", @_ };
80 TODO: {
81 # perl gets the line number a little wrong on the first
82 # statement inside a block.
83 1 == 1;
84#line 82
85 todo_skip "Just testing todo_skip";
86 fail("So very failed");
87 }
88 is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
89 "block at $0 line 82\n",
90 'todo_skip without $how_many warning' );
91}