File: expected_tests.t

package info (click to toggle)
libtest-class-perl 0.47-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 516 kB
  • ctags: 110
  • sloc: perl: 1,984; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /usr/bin/perl -T

use strict;
use warnings FATAL => 'all';

package Tests1; use base qw(Test::Class);

sub start : Test(setup => 1) {};
sub test : Test(1) {};
sub end : Test(teardown => 1) {};

package Tests2; use base qw(Test::Class);

sub start : Test(setup => no_plan) {};
sub test : Test(1) {};
sub end : Test(teardown => 1) {};

package Tests3; use base qw(Test::Class);

sub start : Test(setup => 1) {};
sub test : Test(no_plan) {};
sub end : Test(teardown => 1) {};

package Tests4; use base qw(Test::Class);

sub start : Test(setup => 1) {};
sub test : Test(1) {};
sub end : Test(teardown => no_plan) {};

package Test5; use base qw(Test::Class);

sub startup :Test( startup => no_plan ) {};
sub test : Test(1) {};
sub shutdown :Test( shutdown => 1 ) {};

package Test6; use base qw(Test::Class);

sub startup :Test( startup => 1 ) {};
sub test : Test(1) {};
sub shutdown :Test( shutdown => no_plan ) {};

package main;
use Test::More tests => 10;
use Test::Exception;

is(Tests1->expected_tests, 3, 'all set');
is(Tests2->expected_tests, 'no_plan', 'no_plan setup');
is(Tests3->expected_tests, 'no_plan', 'no_plan test');
is(Tests4->expected_tests, 'no_plan', 'no_plan teardown');
is(Test5->expected_tests, 'no_plan', 'no_plan startup' );
is(Test5->expected_tests, 'no_plan', 'no_plan shutdown' );

my $o1 = Tests1->new;
my $o2 = Tests1->new;
is(Test::Class->expected_tests($o1, $o2, 1), 7, 'expected_test_of');
is(Test::Class->expected_tests($o1, 'Tests3'), 'no_plan', 'no_plan expected_test_of');
dies_ok {Test::Class->expected_tests('foo')} 'bad test class';
dies_ok {Test::Class->expected_tests( undef )} 'undef test class';