A test for reset.
Nicholas Clark [Wed, 4 Apr 2007 19:55:23 +0000 (19:55 +0000)]
p4raw-id: //depot/perl@30844

MANIFEST
t/op/reset.t [new file with mode: 0644]

index 6964f8d..ef24ca4 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3640,6 +3640,7 @@ t/op/regexp.t                     See if regular expressions work
 t/op/regexp_trielist.t         See if regular expressions work with trie optimisation
 t/op/regmesg.t                 See if one can get regular expression errors
 t/op/repeat.t                  See if x operator works
+t/op/reset.t                   See if reset operator works
 t/op/re_tests                  Regular expressions for regexp.t
 t/op/reverse.t                 See if reverse operator works
 t/op/runlevel.t                        See if die() works from perl_call_*()
diff --git a/t/op/reset.t b/t/op/reset.t
new file mode 100644 (file)
index 0000000..d72bfde
--- /dev/null
@@ -0,0 +1,63 @@
+#!./perl -w
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+}
+use strict;
+
+# Currently only testing the reset of patterns.
+plan tests => 20;
+
+package aiieee;
+
+sub zlopp {
+    (shift =~ ?zlopp?) ? 1 : 0;
+}
+
+sub reset_zlopp {
+    reset;
+}
+
+package CLINK;
+
+sub ZZIP {
+    shift =~ ?ZZIP? ? 1 : 0;
+}
+
+sub reset_ZZIP {
+    reset;
+}
+
+package main;
+
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+is(aiieee::zlopp("zlopp"), 1, "match matches first time");
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+is(aiieee::zlopp("zlopp"), 0, "match doesn't match second time");
+aiieee::reset_zlopp();
+is(aiieee::zlopp("zlopp"), 1, "match matches after reset");
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+
+aiieee::reset_zlopp();
+
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+is(aiieee::zlopp("zlopp"), 1, "match matches first time");
+is(CLINK::ZZIP(""), 0, "mismatch doesn't match");
+is(CLINK::ZZIP("ZZIP"), 1, "match matches first time");
+is(CLINK::ZZIP(""), 0, "mismatch doesn't match");
+is(CLINK::ZZIP("ZZIP"), 0, "match doesn't match second time");
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+is(aiieee::zlopp("zlopp"), 0, "match doesn't match second time");
+
+aiieee::reset_zlopp();
+is(aiieee::zlopp("zlopp"), 1, "match matches after reset");
+is(aiieee::zlopp(""), 0, "mismatch doesn't match");
+
+is(CLINK::ZZIP(""), 0, "mismatch doesn't match");
+is(CLINK::ZZIP("ZZIP"), 0, "match doesn't match third time");
+
+CLINK::reset_ZZIP();
+is(CLINK::ZZIP("ZZIP"), 1, "match matches after reset");
+is(CLINK::ZZIP(""), 0, "mismatch doesn't match");