1#!perl -w
2
3BEGIN {
4    if( $ENV{PERL_CORE} ) {
5        chdir 't';
6        @INC = '../lib';
7    }
8}
9
10use Test::More;
11
12plan tests => 18;
13
14
15$Why = 'Just testing the todo interface.';
16
17my $is_todo;
18TODO: {
19    local $TODO = $Why;
20
21    fail("Expected failure");
22    fail("Another expected failure");
23
24    $is_todo = Test::More->builder->todo;
25}
26
27pass("This is not todo");
28ok( $is_todo, 'TB->todo' );
29
30
31TODO: {
32    local $TODO = $Why;
33
34    fail("Yet another failure");
35}
36
37pass("This is still not todo");
38
39
40TODO: {
41    local $TODO = "testing that error messages don't leak out of todo";
42
43    ok( 'this' eq 'that',   'ok' );
44
45    like( 'this', '/that/', 'like' );
46    is(   'this', 'that',   'is' );
47    isnt( 'this', 'this',   'isnt' );
48
49    can_ok('Fooble', 'yarble');
50    isa_ok('Fooble', 'yarble');
51    use_ok('Fooble');
52    require_ok('Fooble');
53}
54
55
56TODO: {
57    todo_skip "Just testing todo_skip", 2;
58
59    fail("Just testing todo");
60    die "todo_skip should prevent this";
61    pass("Again");
62}
63
64
65{
66    my $warning;
67    local $SIG{__WARN__} = sub { $warning = join "", @_ };
68    TODO: {
69        # perl gets the line number a little wrong on the first
70        # statement inside a block.
71        1 == 1;
72#line 82
73        todo_skip "Just testing todo_skip";
74        fail("So very failed");
75    }
76    is( $warning, "todo_skip() needs to know \$how_many tests are in the ".
77                  "block at $0 line 82\n",
78        'todo_skip without $how_many warning' );
79}
80