Upgrade to Test-Simple-0.82.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / skip.t
1 #!perl -w
2 # $Id: /mirror/googlecode/test-more/t/skip.t 57943 2008-08-18T02:09:22.275428Z brooklyn.kid51  $
3
4 BEGIN {
5     if( $ENV{PERL_CORE} ) {
6         chdir 't';
7         @INC = '../lib';
8     }
9 }
10
11 use Test::More tests => 17;
12
13 # If we skip with the same name, Test::Harness will report it back and
14 # we won't get lots of false bug reports.
15 my $Why = "Just testing the skip interface.";
16
17 SKIP: {
18     skip $Why, 2 
19       unless Pigs->can('fly');
20
21     my $pig = Pigs->new;
22     $pig->takeoff;
23
24     ok( $pig->altitude > 0,         'Pig is airborne' );
25     ok( $pig->airspeed > 0,         '  and moving'    );
26 }
27
28
29 SKIP: {
30     skip "We're not skipping", 2 if 0;
31
32     pass("Inside skip block");
33     pass("Another inside");
34 }
35
36
37 SKIP: {
38     skip "Again, not skipping", 2 if 0;
39
40     my($pack, $file, $line) = caller;
41     is( $pack || '', '',      'calling package not interfered with' );
42     is( $file || '', '',      '  or file' );
43     is( $line || '', '',      '  or line' );
44 }
45
46
47 SKIP: {
48     skip $Why, 2 if 1;
49
50     die "A horrible death";
51     fail("Deliberate failure");
52     fail("And again");
53 }
54
55
56 {
57     my $warning;
58     local $SIG{__WARN__} = sub { $warning = join "", @_ };
59     SKIP: {
60         # perl gets the line number a little wrong on the first
61         # statement inside a block.
62         1 == 1;
63 #line 56
64         skip $Why;
65         fail("So very failed");
66     }
67     is( $warning, "skip() needs to know \$how_many tests are in the ".
68                   "block at $0 line 56\n",
69         'skip without $how_many warning' );
70 }
71
72
73 SKIP: {
74     skip "Not skipping here.", 4 if 0;
75
76     pass("This is supposed to run");
77
78     # Testing out nested skips.
79     SKIP: {
80         skip $Why, 2;
81         fail("AHHH!");
82         fail("You're a failure");
83     }
84
85     pass("This is supposed to run, too");
86 }
87
88 {
89     my $warning = '';
90     local $SIG{__WARN__} = sub { $warning .= join "", @_ };
91
92     SKIP: {
93         skip 1, "This is backwards" if 1;
94
95         pass "This does not run";
96     }
97
98     like $warning, '/^skip\(\) was passed a non-numeric number of tests/';
99 }