5 use base 'assertions::compat';
7 sub callme ($ ) : assertion {
11 # select STDERR; $|=1;
25 '1 && ((1) && 1)' => 1,
31 '(1 && 1) && 1)' => undef,
40 '(( 1 && 1) && ( 1 || 0)) || _ && one && ( one || three)' => 1 );
42 my $supported = assertions::compat::supported();
44 my $n=@expr/2 + ($supported ? 12 : 0);
48 use assertions::activate 'one', 'two';
53 my $expected=shift @expr;
54 my $result=eval {assertions::_calc_expr($expr)};
55 if (defined $expected) {
56 unless (defined $result and $result == $expected) {
57 print STDERR "assertions::_calc_expr($expr) failed,".
58 " expected '$expected' but '$result' obtained (\$@=$@)\n";
63 if (defined $result) {
64 print STDERR "assertions::_calc_expr($expr) failed,".
65 " expected undef but '$result' obtained\n";
69 print "ok ", $i++, "\n";
76 print STDERR "assertions called by default\n";
79 print "ok ", $i++, "\n";
82 use assertions::activate 'mine';
85 use base 'assertions::compat';
86 sub callme ($) : assertion {
91 print STDERR "'use assertions;' doesn't active assertions based on package name\n";
95 print "ok ", $i++, "\n";
100 print STDERR "assertion deselection doesn't work\n";
103 print "ok ", $i++, "\n";
106 use assertions::activate 'bar', 'doz';
107 use assertions 'bar';
109 print STDERR "assertion selection doesn't work\n";
112 print "ok ", $i++, "\n";
115 use assertions q(_ && doz);
117 print STDERR "assertion activation filtering doesn't work\n";
120 print "ok ", $i++, "\n";
123 use assertions q(_ && foo);
125 print STDERR "assertion deactivation filtering doesn't work\n";
128 print "ok ", $i++, "\n";
132 use assertions 'bar';
135 print STDERR "assertion scoping doesn't work\n";
138 print "ok ", $i++, "\n";
141 use assertions::activate 're.*';
142 use assertions 'reassert';
144 print STDERR "assertion selection with re failed\n";
147 print "ok ", $i++, "\n";
152 use assertions 'bar';
155 print STDERR "this shouldn't fail ever (b=$b)\n";
159 print "ok ", $i++, "\n";
166 print STDERR "lexical declaration in assertion arg ignored (b=$b\n";
170 print "ok ", $i++, "\n";
174 use assertions::activate sub { return 1 if $_[0] eq 'via_sub' };
175 use assertions 'via_sub';
178 print STDERR "this shouldn't fail ever (b=$b)\n";
182 print "ok ", $i++, "\n";
186 use assertions 'not_asserted';
189 print STDERR "this shouldn't fail ever (b=$b)\n";
193 print "ok ", $i++, "\n";