From: Nicholas Clark Date: Wed, 4 Apr 2007 19:55:23 +0000 (+0000) Subject: A test for reset. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f3c5f777b9804575fe61393e45d9c4513b5eacc;p=p5sagit%2Fp5-mst-13.2.git A test for reset. p4raw-id: //depot/perl@30844 --- diff --git a/MANIFEST b/MANIFEST index 6964f8d..ef24ca4 100644 --- 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 index 0000000..d72bfde --- /dev/null +++ b/t/op/reset.t @@ -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");