summaryrefslogtreecommitdiff
path: root/t/comp/assertions.t
diff options
context:
space:
mode:
authorSalvador FandiƱo <sfandino@yahoo.com>2003-02-17 23:38:05 +0000
committerhv <hv@crypt.org>2003-02-18 01:04:01 +0000
commitcb8340be3384a90a55aad4280e799b656e1fa8af (patch)
tree3cc50797ea1da074a1070436a510f6fde3968b24 /t/comp/assertions.t
parent9a26048b591176092513e1e0db064d5315c21465 (diff)
downloadperl-cb8340be3384a90a55aad4280e799b656e1fa8af.tar.gz
Re: Did the assertion patch/feature submission get overlooked?
Message-ID: <3E51725D.5060303@yahoo.com> p4raw-id: //depot/perl@18739
Diffstat (limited to 't/comp/assertions.t')
-rw-r--r--t/comp/assertions.t106
1 files changed, 106 insertions, 0 deletions
diff --git a/t/comp/assertions.t b/t/comp/assertions.t
new file mode 100644
index 0000000000..d3d9783fd5
--- /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";