From: Salvador FandiƱo Date: Mon, 17 Feb 2003 23:38:05 +0000 (+0000) Subject: Re: Did the assertion patch/feature submission get overlooked? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb8340be3384a90a55aad4280e799b656e1fa8af;p=p5sagit%2Fp5-mst-13.2.git Re: Did the assertion patch/feature submission get overlooked? Message-ID: <3E51725D.5060303@yahoo.com> p4raw-id: //depot/perl@18739 --- diff --git a/MANIFEST b/MANIFEST index ed78573..db7cba2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2387,6 +2387,7 @@ t/cmd/mod.t See if statement modifiers work t/cmd/subval.t See if subroutine values work t/cmd/switch.t See if switch optimizations work t/cmd/while.t See if while loops work +t/comp/assertions.t See if assertions work t/comp/bproto.t See if builtins conform to their prototypes t/comp/cmdopt.t See if command optimization works t/comp/colon.t See if colons are parsed correctly @@ -2695,6 +2696,7 @@ t/run/noswitch.t Test aliasing ARGV for other switch tests t/run/runenv.t Test if perl honors its environment variables. t/run/switcha.t Test the -a switch t/run/switches.t Tests for the other switches +t/run/switchA.t Test the -A switch t/run/switchF.t Test the -F switch t/run/switchI.t Test the -I switch t/run/switchn.t Test the -n switch diff --git a/t/comp/assertions.t b/t/comp/assertions.t new file mode 100644 index 0000000..d3d9783 --- /dev/null +++ b/t/comp/assertions.t @@ -0,0 +1,106 @@ +#!./perl + +my $i=1; +print "1..10\n"; + +sub callme ($) : assertion { + return shift; +} + + +# 1 +if (callme(1)) { + print STDERR "assertions called by default"; + 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"; + print "not "; + } +} +print "ok ", $i++, "\n"; + +# 3 +use assertions 'foo'; +if (callme(1)) { + print STDERR "assertion deselection doesn't work"; + 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"; + print "not "; +} +print "ok ", $i++, "\n"; + +# 5 +use assertions '&', 'doz'; +unless (callme(1)) { + print STDERR "assertion activation filtering doesn't work"; + print "not "; +} +print "ok ", $i++, "\n"; + +# 6 +use assertions '&', 'foo'; +if (callme(1)) { + print STDERR "assertion deactivation filtering doesn't work"; + print "not "; +} +print "ok ", $i++, "\n"; + +# 7 +if (1) { + use assertions 'bar'; +} +if (callme(1)) { + print STDERR "assertion scoping doesn't work"; + print "not "; +} +print "ok ", $i++, "\n"; + +# 8 +use assertions::activate 're.*'; +use assertions 'reassert'; +unless (callme(1)) { + print STDERR "assertion selection with re failed"; + 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)"; + print "not "; + } +} +print "ok ", $i++, "\n"; + +# 10 +{ + no assertions; + callme(my $b=46); + if (defined $b) { + print STDERR "lexical declaration in assertion arg ignored"; + print "not "; + } +} +print "ok ", $i++, "\n"; diff --git a/t/run/switchA.t b/t/run/switchA.t new file mode 100755 index 0000000..e042c1d --- /dev/null +++ b/t/run/switchA.t @@ -0,0 +1,31 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + unshift @INC, '../lib'; + require './test.pl'; # for which_perl() etc +} + +BEGIN { + plan(4); +} + +#1 +fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()', + 'ok', + { switches => ['-AHello'] }, '-A'); + +#2 +fresh_perl_is('sub cm : assertion { "ok" }; use assertions SDFJKS; print cm()', + 'ok', + { switches => ['-A.*'] }, '-A.*'); + +#3 +fresh_perl_is('sub cm : assertion { "ok" }; use assertions Bye; print cm()', + 'ok', + { switches => ['-AB.e'] }, '-AB.e'); + +#4 +fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()', + '0', + { switches => ['-ANoH..o'] }, '-ANoH..o');