4 if( $ENV{PERL_CORE} ) {
15 $Why = 'Just testing the todo interface.';
21 fail("Expected failure");
22 fail("Another expected failure");
24 $is_todo = Test::More->builder->todo;
27 pass("This is not todo");
28 ok( $is_todo, 'TB->todo' );
34 fail("Yet another failure");
37 pass("This is still not todo");
41 local $TODO = "testing that error messages don't leak out of todo";
43 ok( 'this' eq 'that', 'ok' );
45 like( 'this', qr/that/, 'like' );
46 is( 'this', 'that', 'is' );
47 isnt( 'this', 'this', 'isnt' );
49 can_ok('Fooble', 'yarble');
50 isa_ok('Fooble', 'yarble');
57 todo_skip "Just testing todo_skip", 2;
59 fail("Just testing todo");
60 die "todo_skip should prevent this";
67 local $SIG{__WARN__} = sub { $warning = join "", @_ };
69 # perl gets the line number a little wrong on the first
70 # statement inside a block.
73 todo_skip "Just testing todo_skip";
74 fail("So very failed");
76 is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
77 "block at $0 line 74\n",
78 'todo_skip without $how_many warning' );
81 my $builder = Test::More->builder;
82 my $exported_to = $builder->exported_to;
84 $builder->exported_to("Wibble");
86 local $TODO = "testing \$TODO with an incorrect exported_to()";
88 fail("Just testing todo");
91 $builder->exported_to($exported_to);
93 $builder->todo_start('Expected failures');
94 fail('Testing todo_start()');
95 ok 0, 'Testing todo_start() with more than one failure';
96 $is_todo = $builder->todo;
98 is $is_todo, 'Expected failures',
99 'todo_start should have the correct TODO message';
100 ok 1, 'todo_end() should not leak TODO behavior';
103 my ( $level1, $level2 ) = ( 'failure level 1', 'failure_level 2' );
105 local $TODO = 'Nesting TODO';
108 $builder->todo_start($level1);
111 push @nested_todo => $builder->todo;
112 $builder->todo_start($level2);
115 push @nested_todo => $builder->todo;
119 push @nested_todo => $builder->todo;
121 $is_todo = $builder->todo;
124 is_deeply \@nested_todo, [ $level1, $level2, $level1 ],
125 'Nested TODO message should be correct';
126 is $is_todo, 'Nesting TODO',
127 '... and original TODO message should be correct';
130 $builder->todo_start;
131 fail("testing todo_start() with no message");
132 my $reason = $builder->todo;
133 my $in_todo = $builder->in_todo;
136 is $reason, '', " todo() reports no reason";
137 ok $in_todo, " but we're in_todo()";
143 is $@, sprintf "todo_end() called without todo_start() at %s line %d.\n", $0, __LINE__ - 2;
147 my($reason, $in_todo);
151 $reason = $builder->todo;
152 $in_todo = $builder->in_todo;
156 ok !$in_todo, '$TODO = "" is not considered TODO';