File: startup.t

package info (click to toggle)
libtest-class-perl 0.35-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 476 kB
  • ctags: 102
  • sloc: perl: 1,668; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (6)
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
#! /usr/bin/perl -T

use strict;
use warnings;

my @ORDER = qw (
	start1
	start2
	setup1
	setup2
	test1
	tear1
	tear2
	setup1
	setup2
	test2
	tear1
	tear2
	end1
	end2
);


package Foo::Test;
use base qw(Test::Class);
use Test::More;

sub trace_ok {
	my $caller = (caller(1))[3];
	$caller =~ s/^.*://s;
	my $expected = shift @ORDER;
	is($caller, $expected, "called $expected");
};

sub start1	: Test(startup=>1)	{ trace_ok() };
sub start2	: Test(startup=>1)	{ trace_ok() };

sub setup1	: Test(setup=>1)	{ trace_ok() };
sub setup2	: Test(setup=>1)	{ trace_ok() };

sub test1	: Test(1)			{ trace_ok() };
sub test2	: Test(1)			{ trace_ok() };

sub tear1	: Test(teardown=>1)	{ trace_ok() };
sub tear2	: Test(teardown=>1)	{ trace_ok() };

sub end1	: Test(shutdown=>1)	{ trace_ok() };
sub end2	: Test(shutdown=>1)	{ trace_ok() };


package main;
use Test::More;

Foo::Test->runtests(+1);
ok(@ORDER==0, 'all expected methods ran');