-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.pl
50 lines (40 loc) · 1.14 KB
/
test.pl
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
# DIFFERENT PERL VERSIONS HEAD HURTY GAH
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
# in perls without UNITCHECK we'll run last
my $plan;
BEGIN {
$plan = 4;
if ($] < 5.009005) {
eval 'sub UNITCHECK (&) {&{$_[0]}}';
$plan = 1;
}
}
use Test;
BEGIN { plan tests => $plan };
my @order;
sub add {
push @order, $_[0];
}
UNITCHECK {add("UC1")};
CHECK {add("c1")}
use Check::UnitCheck sub {add("uc1")};
use Check::UnitCheck sub {add("uc2")};
UNITCHECK {add("UC2")};
CHECK {add("c2")}
if ($] < 5.009005) {
ok(join(":", @order), "c2:uc2:uc1:c1:UC1:UC2", "pre UNITCHECK ok");
}
else {
ok(join(":", @order), "UC2:uc2:uc1:UC1:c2:c1", "has UNITCHECK ok");
my $foo;
eval 'use Check::UnitCheck sub {$foo = "haddock"};';
ok($foo, "haddock");
my($b4, $af);
eval 'sub bar {return "z"};BEGIN {$b4 = bar(); Check::UnitCheck::unitcheckify(sub {*bar = sub {return "brunt"}})}; $af = bar()';
die $@ if $@;
ok($b4, "z");
ok($af, "brunt");
}