~ubuntu-branches/ubuntu/trusty/libtest-simple-perl/trusty

« back to all changes in this revision

Viewing changes to t/Builder/is_passing.t

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Yu, Jonathan Yu, Ryan Niebur
  • Date: 2009-09-03 10:43:00 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903104300-getenpmiheofk9ag
Tags: 0.94-1
[ Jonathan Yu ]
* New upstream release
  + Make sure that subtest works with Test:: modules which call
    Test::Builder->new at the top of their code
* Updated copyright with people from changelog
* Small change to top line of description
* Install the supplied examples

[ Ryan Niebur ]
* Update jawnsy's email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
use strict;
 
4
use lib 't/lib';
 
5
 
 
6
# We're going to need to override exit() later
 
7
BEGIN {
 
8
    *CORE::GLOBAL::exit = sub(;$) {
 
9
        my $status = @_ ? 0 : shift;
 
10
        CORE::exit $status;
 
11
    };
 
12
}
 
13
 
 
14
use Test::More;
 
15
use Test::Builder;
 
16
use Test::Builder::NoOutput;
 
17
 
 
18
{
 
19
    my $tb = Test::Builder::NoOutput->create;
 
20
    ok $tb->is_passing, "a fresh TB object is passing";
 
21
 
 
22
    $tb->ok(1);
 
23
    ok $tb->is_passing, "  still passing after a test";
 
24
 
 
25
    $tb->ok(0);
 
26
    ok !$tb->is_passing, "  not passing after a failing test";
 
27
 
 
28
    $tb->ok(1);
 
29
    ok !$tb->is_passing, "  a passing test doesn't resurrect it";
 
30
 
 
31
    $tb->done_testing(3);
 
32
    ok !$tb->is_passing, "  a successful plan doesn't help either";
 
33
}
 
34
 
 
35
 
 
36
# See if is_passing() notices a plan overrun
 
37
{
 
38
    my $tb = Test::Builder::NoOutput->create;
 
39
    $tb->plan( tests => 1 );
 
40
    $tb->ok(1);
 
41
    ok $tb->is_passing, "Passing with a plan";
 
42
 
 
43
    $tb->ok(1);
 
44
    ok !$tb->is_passing, "  passing test, but it overran the plan";
 
45
}
 
46
 
 
47
 
 
48
# is_passing() vs no_plan
 
49
{
 
50
    my $tb = Test::Builder::NoOutput->create;
 
51
    $tb->plan( "no_plan" );
 
52
    ok $tb->is_passing, "Passing with no_plan";
 
53
 
 
54
    $tb->ok(1);
 
55
    ok $tb->is_passing, "  still passing after a test";
 
56
 
 
57
    $tb->ok(1);
 
58
    ok $tb->is_passing, "  and another test";
 
59
 
 
60
    $tb->_ending;
 
61
    ok $tb->is_passing, "  and after the ending";
 
62
}
 
63
 
 
64
 
 
65
# is_passing() vs skip_all
 
66
{
 
67
    my $tb = Test::Builder::NoOutput->create;
 
68
 
 
69
    {
 
70
        no warnings 'redefine';
 
71
        local *CORE::GLOBAL::exit = sub {
 
72
            return 1;
 
73
        };
 
74
        $tb->plan( "skip_all" );
 
75
    }
 
76
    ok $tb->is_passing, "Passing with skip_all";
 
77
}
 
78
 
 
79
 
 
80
# is_passing() vs done_testing(#)
 
81
{
 
82
    my $tb = Test::Builder::NoOutput->create;
 
83
    $tb->ok(1);
 
84
    $tb->done_testing(2);
 
85
    ok !$tb->is_passing, "All tests passed but done_testing() does not match";
 
86
}
 
87
 
 
88
 
 
89
# is_passing() with no tests run vs done_testing()
 
90
{
 
91
    my $tb = Test::Builder::NoOutput->create;
 
92
    $tb->done_testing();
 
93
    ok !$tb->is_passing, "No tests run with done_testing()";
 
94
}
 
95
 
 
96
 
 
97
# is_passing() with no tests run vs done_testing()
 
98
{
 
99
    my $tb = Test::Builder::NoOutput->create;
 
100
    $tb->ok(1);
 
101
    $tb->done_testing();
 
102
    ok $tb->is_passing, "All tests passed with done_testing()";
 
103
}
 
104
 
 
105
 
 
106
done_testing();