Upgrade to Test-Simple-0.82.
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / skip.t
CommitLineData
33459055 1#!perl -w
ccbd73a4 2# $Id: /mirror/googlecode/test-more/t/skip.t 57943 2008-08-18T02:09:22.275428Z brooklyn.kid51 $
33459055 3
4BEGIN {
a9153838 5 if( $ENV{PERL_CORE} ) {
6 chdir 't';
7 @INC = '../lib';
8 }
33459055 9}
10
1be77ff7 11use Test::More tests => 17;
d020a79a 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.
15my $Why = "Just testing the skip interface.";
16
17SKIP: {
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
29SKIP: {
30 skip "We're not skipping", 2 if 0;
31
32 pass("Inside skip block");
33 pass("Another inside");
34}
35
36
37SKIP: {
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
47SKIP: {
48 skip $Why, 2 if 1;
49
50 die "A horrible death";
51 fail("Deliberate failure");
52 fail("And again");
53}
33459055 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
73SKIP: {
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
1be77ff7 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
b7f9bbeb 98 like $warning, '/^skip\(\) was passed a non-numeric number of tests/';
1be77ff7 99}