4 if( $ENV{PERL_CORE} ) {
14 if( eval "warnings->can('carp')" ) {
15 plan skip_all => 'Modern::Open is installed, which breaks this test';
22 $Why = 'Just testing the todo interface.';
28 fail("Expected failure");
29 fail("Another expected failure");
31 $is_todo = Test::More->builder->todo;
34 pass("This is not todo");
35 ok( $is_todo, 'TB->todo' );
41 fail("Yet another failure");
44 pass("This is still not todo");
48 local $TODO = "testing that error messages don't leak out of todo";
50 ok( 'this' eq 'that', 'ok' );
52 like( 'this', qr/that/, 'like' );
53 is( 'this', 'that', 'is' );
54 isnt( 'this', 'this', 'isnt' );
56 can_ok('Fooble', 'yarble');
57 isa_ok('Fooble', 'yarble');
64 todo_skip "Just testing todo_skip", 2;
66 fail("Just testing todo");
67 die "todo_skip should prevent this";
74 local $SIG{__WARN__} = sub { $warning = join "", @_ };
76 # perl gets the line number a little wrong on the first
77 # statement inside a block.
80 todo_skip "Just testing todo_skip";
81 fail("So very failed");
83 is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
84 "block at $0 line 74\n",
85 'todo_skip without $how_many warning' );
88 my $builder = Test::More->builder;
89 my $exported_to = $builder->exported_to;
91 $builder->exported_to("Wibble");
93 local $TODO = "testing \$TODO with an incorrect exported_to()";
95 fail("Just testing todo");
98 $builder->exported_to($exported_to);
100 $builder->todo_start('Expected failures');
101 fail('Testing todo_start()');
102 ok 0, 'Testing todo_start() with more than one failure';
103 $is_todo = $builder->todo;
105 is $is_todo, 'Expected failures',
106 'todo_start should have the correct TODO message';
107 ok 1, 'todo_end() should not leak TODO behavior';
110 my ( $level1, $level2 ) = ( 'failure level 1', 'failure_level 2' );
112 local $TODO = 'Nesting TODO';
115 $builder->todo_start($level1);
118 push @nested_todo => $builder->todo;
119 $builder->todo_start($level2);
122 push @nested_todo => $builder->todo;
126 push @nested_todo => $builder->todo;
128 $is_todo = $builder->todo;
131 is_deeply \@nested_todo, [ $level1, $level2, $level1 ],
132 'Nested TODO message should be correct';
133 is $is_todo, 'Nesting TODO',
134 '... and original TODO message should be correct';
137 $builder->todo_start;
138 fail("testing todo_start() with no message");
139 my $reason = $builder->todo;
140 my $in_todo = $builder->in_todo;
143 is $reason, '', " todo() reports no reason";
144 ok $in_todo, " but we're in_todo()";
151 is $@, sprintf "todo_end() called without todo_start() at %s line %d.\n", $0, __LINE__ - 2;
155 my($reason, $in_todo);
159 $reason = $builder->todo;
160 $in_todo = $builder->in_todo;
164 ok !$in_todo, '$TODO = "" is not considered TODO';