diff options
author | Steve Peters <steve@fisharerojo.org> | 2006-03-01 16:29:37 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2006-03-01 16:29:37 +0000 |
commit | e76bdc3c3484319196e16aec801f7c3b585858be (patch) | |
tree | 2f2e4401d5c747c290ba1320caaa0c2b2dc6bf4d /t/comp/assertions.t | |
parent | 0f2c5c103faf2416d7eff2b4889590b7f614e7d7 (diff) | |
download | perl-e76bdc3c3484319196e16aec801f7c3b585858be.tar.gz |
Upgrade to assertions-0.03
p4raw-id: //depot/perl@27356
Diffstat (limited to 't/comp/assertions.t')
-rw-r--r-- | t/comp/assertions.t | 189 |
1 files changed, 99 insertions, 90 deletions
diff --git a/t/comp/assertions.t b/t/comp/assertions.t index 9edc13a1da..f5d583df84 100644 --- a/t/comp/assertions.t +++ b/t/comp/assertions.t @@ -1,5 +1,9 @@ #!./perl +BEGIN { $^W=0 } + +use base 'assertions::compat'; + sub callme ($ ) : assertion { return shift; } @@ -35,7 +39,9 @@ my @expr=( '1' => 1, ' ( 1 && 0 ) ' => 0, '(( 1 && 1) && ( 1 || 0)) || _ && one && ( one || three)' => 1 ); -my $n=@expr/2+10; +my $supported = assertions::compat::supported(); + +my $n=@expr/2 + ($supported ? 10 : 0); my $i=1; print "1..$n\n"; @@ -63,100 +69,103 @@ while (@expr) { print "ok ", $i++, "\n"; } +if ($supported) { -# @expr/2+1 -if (callme(1)) { - print STDERR "assertions called by default\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 2 -use assertions::activate 'mine'; -{ - package mine; - sub callme ($) : assertion { - return shift; - } - use assertions; - unless (callme(1)) { - print STDERR "'use assertions;' doesn't active assertions based on package name\n"; - print "not "; - } -} -print "ok ", $i++, "\n"; - -# 3 -use assertions 'foo'; -if (callme(1)) { - print STDERR "assertion deselection doesn't work\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 4 -use assertions::activate 'bar', 'doz'; -use assertions 'bar'; -unless (callme(1)) { - print STDERR "assertion selection doesn't work\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 5 -use assertions q(_ && doz); -unless (callme(1)) { - print STDERR "assertion activation filtering doesn't work\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 6 -use assertions q(_ && foo); -if (callme(1)) { - print STDERR "assertion deactivation filtering doesn't work\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 7 -if (1) { - use assertions 'bar'; -} -if (callme(1)) { - print STDERR "assertion scoping doesn't work\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 8 -use assertions::activate 're.*'; -use assertions 'reassert'; -unless (callme(1)) { - print STDERR "assertion selection with re failed\n"; - print "not "; -} -print "ok ", $i++, "\n"; - -# 9 -my $b=12; -{ + # @expr/2+1 + if (callme(1)) { + print STDERR "assertions called by default\n"; + print "not "; + } + print "ok ", $i++, "\n"; + + # 2 + use assertions::activate 'mine'; + { + package mine; + use base 'assertions::compat'; + sub callme ($) : assertion { + return shift; + } + use assertions; + unless (callme(1)) { + print STDERR "'use assertions;' doesn't active assertions based on package name\n"; + print "not "; + } + } + print "ok ", $i++, "\n"; + + # 3 + use assertions 'foo'; + if (callme(1)) { + print STDERR "assertion deselection doesn't work\n"; + print "not "; + } + print "ok ", $i++, "\n"; + + # 4 + use assertions::activate 'bar', 'doz'; use assertions 'bar'; - callme(my $b=45); - unless ($b == 45) { - print STDERR "this shouldn't fail ever (b=$b)\n"; + unless (callme(1)) { + print STDERR "assertion selection doesn't work\n"; print "not "; } -} -print "ok ", $i++, "\n"; + print "ok ", $i++, "\n"; + + # 5 + use assertions q(_ && doz); + unless (callme(1)) { + print STDERR "assertion activation filtering doesn't work\n"; + print "not "; + } + print "ok ", $i++, "\n"; + + # 6 + use assertions q(_ && foo); + if (callme(1)) { + print STDERR "assertion deactivation filtering doesn't work\n"; + print "not "; + } + print "ok ", $i++, "\n"; + + # 7 + if (1) { + use assertions 'bar'; + } + if (callme(1)) { + print STDERR "assertion scoping doesn't work\n"; + print "not "; + } + print "ok ", $i++, "\n"; -# 10 -{ - no assertions; - callme(my $b=46); - if (defined $b) { - print STDERR "lexical declaration in assertion arg ignored (b=$b\n"; + # 8 + use assertions::activate 're.*'; + use assertions 'reassert'; + unless (callme(1)) { + print STDERR "assertion selection with re failed\n"; print "not "; } + print "ok ", $i++, "\n"; + + # 9 + my $b=12; + { + use assertions 'bar'; + callme(my $b=45); + unless ($b == 45) { + print STDERR "this shouldn't fail ever (b=$b)\n"; + print "not "; + } + } + print "ok ", $i++, "\n"; + + # 10 + { + no assertions; + callme(my $b=46); + if (defined $b) { + print STDERR "lexical declaration in assertion arg ignored (b=$b\n"; + print "not "; + } + } + print "ok ", $i++, "\n"; } -print "ok ", $i++, "\n"; |