Make adding notes to patchlevel.h easier
[p5sagit/p5-mst-13.2.git] / t / comp / assertions.t
CommitLineData
cb8340be 1#!./perl
2
3my $i=1;
4print "1..10\n";
5
6sub callme ($) : assertion {
7 return shift;
8}
9
10
11# 1
12if (callme(1)) {
13 print STDERR "assertions called by default";
14 print "not ";
15}
16print "ok ", $i++, "\n";
17
18# 2
19use assertions::activate 'mine';
20{
21 package mine;
22 sub callme ($) : assertion {
23 return shift;
24 }
25 use assertions;
26 unless (callme(1)) {
27 print STDERR "'use assertions;' doesn't active assertions based on package name";
28 print "not ";
29 }
30}
31print "ok ", $i++, "\n";
32
33# 3
34use assertions 'foo';
35if (callme(1)) {
36 print STDERR "assertion deselection doesn't work";
37 print "not ";
38}
39print "ok ", $i++, "\n";
40
41# 4
42use assertions::activate 'bar', 'doz';
43use assertions 'bar';
44unless (callme(1)) {
45 print STDERR "assertion selection doesn't work";
46 print "not ";
47}
48print "ok ", $i++, "\n";
49
50# 5
51use assertions '&', 'doz';
52unless (callme(1)) {
53 print STDERR "assertion activation filtering doesn't work";
54 print "not ";
55}
56print "ok ", $i++, "\n";
57
58# 6
59use assertions '&', 'foo';
60if (callme(1)) {
61 print STDERR "assertion deactivation filtering doesn't work";
62 print "not ";
63}
64print "ok ", $i++, "\n";
65
66# 7
67if (1) {
68 use assertions 'bar';
69}
70if (callme(1)) {
71 print STDERR "assertion scoping doesn't work";
72 print "not ";
73}
74print "ok ", $i++, "\n";
75
76# 8
77use assertions::activate 're.*';
78use assertions 'reassert';
79unless (callme(1)) {
80 print STDERR "assertion selection with re failed";
81 print "not ";
82}
83print "ok ", $i++, "\n";
84
85# 9
86my $b=12;
87{
88 use assertions 'bar';
89 callme(my $b=45);
90 unless ($b == 45) {
91 print STDERR "this shouldn't fail ever (b=$b)";
92 print "not ";
93 }
94}
95print "ok ", $i++, "\n";
96
97# 10
98{
99 no assertions;
100 callme(my $b=46);
101 if (defined $b) {
102 print STDERR "lexical declaration in assertion arg ignored";
103 print "not ";
104 }
105}
106print "ok ", $i++, "\n";