Upgrade to Test::Simple 0.54
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / todo.t
1 #!perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = '../lib';
7     }
8 }
9
10 require Test::Harness;
11 use Test::More;
12
13 # Shut up a "used only once" warning in 5.5.4.
14 my $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
18 if( $th_version < 2.03 ) {
19     plan tests => 1;
20     fail "Need Test::Harness 2.03 or up.  You have $th_version.";
21     exit;
22 }
23
24 plan tests => 18;
25
26
27 $Why = 'Just testing the todo interface.';
28
29 my $is_todo;
30 TODO: {
31     local $TODO = $Why;
32
33     fail("Expected failure");
34     fail("Another expected failure");
35
36     $is_todo = Test::More->builder->todo;
37 }
38
39 pass("This is not todo");
40 ok( $is_todo, 'TB->todo' );
41
42
43 TODO: {
44     local $TODO = $Why;
45
46     fail("Yet another failure");
47 }
48
49 pass("This is still not todo");
50
51
52 TODO: {
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 }
66
67
68 TODO: {
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 }
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 }