2 # $Id: /mirror/googlecode/test-more-trunk/t/todo.t 62094 2008-09-19T07:21:50.720642Z schwern $
5 if( $ENV{PERL_CORE} ) {
16 $Why = 'Just testing the todo interface.';
22 fail("Expected failure");
23 fail("Another expected failure");
25 $is_todo = Test::More->builder->todo;
28 pass("This is not todo");
29 ok( $is_todo, 'TB->todo' );
35 fail("Yet another failure");
38 pass("This is still not todo");
42 local $TODO = "testing that error messages don't leak out of todo";
44 ok( 'this' eq 'that', 'ok' );
46 like( 'this', '/that/', 'like' );
47 is( 'this', 'that', 'is' );
48 isnt( 'this', 'this', 'isnt' );
50 can_ok('Fooble', 'yarble');
51 isa_ok('Fooble', 'yarble');
58 todo_skip "Just testing todo_skip", 2;
60 fail("Just testing todo");
61 die "todo_skip should prevent this";
68 local $SIG{__WARN__} = sub { $warning = join "", @_ };
70 # perl gets the line number a little wrong on the first
71 # statement inside a block.
74 todo_skip "Just testing todo_skip";
75 fail("So very failed");
77 is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
78 "block at $0 line 74\n",
79 'todo_skip without $how_many warning' );
82 my $builder = Test::More->builder;
83 my $exported_to = $builder->exported_to;
85 $builder->exported_to("Wibble");
87 local $TODO = "testing \$TODO with an incorrect exported_to()";
89 fail("Just testing todo");
92 $builder->exported_to($exported_to);
94 $builder->todo_start('Expected failures');
95 fail('Testing todo_start()');
96 ok 0, 'Testing todo_start() with more than one failure';
97 $is_todo = $builder->todo;
99 is $is_todo, 'Expected failures',
100 'todo_start should have the correct TODO message';
101 ok 1, 'todo_end() should not leak TODO behavior';
104 my ( $level1, $level2 ) = ( 'failure level 1', 'failure_level 2' );
106 local $TODO = 'Nesting TODO';
109 $builder->todo_start($level1);
112 push @nested_todo => $builder->todo;
113 $builder->todo_start($level2);
116 push @nested_todo => $builder->todo;
120 push @nested_todo => $builder->todo;
122 $is_todo = $builder->todo;
125 is_deeply \@nested_todo, [ $level1, $level2, $level1 ],
126 'Nested TODO message should be correct';
127 is $is_todo, 'Nesting TODO',
128 '... and original TODO message should be correct';
131 $builder->todo_start;
132 fail("testing todo_start() with no message");
133 my $reason = $builder->todo;
134 my $in_todo = $builder->in_todo;
137 is $reason, '', " todo() reports no reason";
138 ok $in_todo, " but we're in_todo()";
144 is $@, sprintf "todo_end() called without todo_start() at %s line %d.\n", $0, __LINE__ - 2;
148 my($reason, $in_todo);
152 $reason = $builder->todo;
153 $in_todo = $builder->in_todo;
157 ok !$in_todo, '$TODO = "" is not considered TODO';