Re: Did the assertion patch/feature submission get overlooked?
[p5sagit/p5-mst-13.2.git] / t / comp / assertions.t
1 #!./perl
2
3 my $i=1;
4 print "1..10\n";
5
6 sub callme ($) : assertion {
7     return shift;
8 }
9
10
11 # 1
12 if (callme(1)) {
13     print STDERR "assertions called by default";
14     print "not ";
15 }
16 print "ok ", $i++, "\n";
17
18 # 2
19 use 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 }
31 print "ok ", $i++, "\n";
32
33 # 3
34 use assertions 'foo';
35 if (callme(1)) {
36     print STDERR "assertion deselection doesn't work";
37     print "not ";
38 }
39 print "ok ", $i++, "\n";
40
41 # 4
42 use assertions::activate 'bar', 'doz';
43 use assertions 'bar';
44 unless (callme(1)) {
45     print STDERR "assertion selection doesn't work";
46     print "not ";
47 }
48 print "ok ", $i++, "\n";
49
50 # 5
51 use assertions '&', 'doz';
52 unless (callme(1)) {
53     print STDERR "assertion activation filtering doesn't work";
54     print "not ";
55 }
56 print "ok ", $i++, "\n";
57
58 # 6
59 use assertions '&', 'foo';
60 if (callme(1)) {
61     print STDERR "assertion deactivation filtering doesn't work";
62     print "not ";
63 }
64 print "ok ", $i++, "\n";
65
66 # 7
67 if (1) {
68     use assertions 'bar';
69 }
70 if (callme(1)) {
71     print STDERR "assertion scoping doesn't work";
72     print "not ";
73 }
74 print "ok ", $i++, "\n";
75
76 # 8
77 use assertions::activate 're.*';
78 use assertions 'reassert';
79 unless (callme(1)) {
80     print STDERR "assertion selection with re failed";
81     print "not ";
82 }
83 print "ok ", $i++, "\n";
84
85 # 9
86 my $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 }
95 print "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 }
106 print "ok ", $i++, "\n";