Author: particle
Date: Thu Oct 27 13:31:26 2005
New Revision: 9600

Modified:
   trunk/compilers/pge/README
   trunk/t/p6rules/escape.t
   trunk/t/p6rules/metachars.t
Log:
added PGE metachars tests
fixed PGE README misspelling
refactored some metachars tests

Modified: trunk/compilers/pge/README
==============================================================================
--- trunk/compilers/pge/README  (original)
+++ trunk/compilers/pge/README  Thu Oct 27 13:31:26 2005
@@ -34,7 +34,7 @@ C<parrot demo.pir>.  The demo understand
     rule pattern      - compile a Perl 6 rule from "pattern"
     save name         - save the current rule as "name"
     text              - a text string to match against previously entered rule
-    pir               - display the PIR cod generated for current rule
+    pir               - display the PIR code generated for current rule
     exp               - display the expression tree for the current rule
     trace             - toggle pattern execution tracing
     next              - repeat last match on target string

Modified: trunk/t/p6rules/escape.t
==============================================================================
--- trunk/t/p6rules/escape.t    (original)
+++ trunk/t/p6rules/escape.t    Thu Oct 27 13:31:26 2005
@@ -1,14 +1,9 @@
 use strict;
 use warnings;
-use Parrot::Test tests => 19;
+use Parrot::Test tests => 8;
 use Parrot::Test::PGE;
 
 
-p6rule_isnt('abcdef', 'a\s+f', 'whitespace');
-p6rule_is  ("ab  cdef", 'ab\s+cdef', 'whitespace');
-p6rule_is  ('abcdef', 'a\S+f', 'not whitespace');
-p6rule_isnt("ab cdef", 'a\S+f', 'not whitespace');
-
 p6rule_isnt('a=[ *f', 'a\w+f', 'word character');
 p6rule_is  ("abcdef", 'a\w+f', 'word character');
 p6rule_is  ('a&%- f', 'a\W+f', 'not word character');
@@ -19,12 +14,4 @@ p6rule_is  ("ab42cdef", 'ab\d+cdef', 'di
 p6rule_is  ('abcdef', 'a\D+f', 'not digit');
 p6rule_isnt("ab0cdef", 'a\D+f', 'not digit');
 
-p6rule_isnt('abcdef', 'a\n+f', 'logical newline');
-p6rule_is  ("ab\n\ncdef", 'ab\n+cdef', 'logical newline');
-p6rule_is  ('abcdef', 'a\N+f', 'not logical newline');
-p6rule_isnt("ab\ncdef", 'a\N+f', 'not logical newline');
-p6rule_is("a#b", 'a#c', '# introduces comment');
-p6rule_isnt("a#b", 'a\#c', 'escaped # does not introduce comment');
-p6rule_is("a#b", 'a\#b', 'escaped # is part of match');
-
 # dont forget to change the number of tests :-)

Modified: trunk/t/p6rules/metachars.t
==============================================================================
--- trunk/t/p6rules/metachars.t (original)
+++ trunk/t/p6rules/metachars.t Thu Oct 27 13:31:26 2005
@@ -16,32 +16,87 @@ p6rule_is  ("\n", '.', 'dot (.)');
 p6rule_isnt('', '.', 'dot (.)');
 
 
-## ^ and $
-p6rule_is  ('abcdef', '^abc', '^ and $ (^)');
-p6rule_is  ("abc\ndef", '^abc', '^ and $ (^)');
-p6rule_isnt("def\nabc", '^abc', '^ and $ (^)');
-p6rule_is  ('abcdef', 'def$', '^ and $ ($)');
-p6rule_is  ("abc\ndef", 'def$', '^ and $ ($)');
-p6rule_isnt("def\nabc", 'def$', '^ and $ ($)');
-
-
-## \n and \N
-
-
-## \A, \Z, \z
-
-
-## #
-
-
-## whitespace
-
-
-## ^^ and $$
+## \s and \S -- whitespace
+p6rule_isnt('abcdef', 'a\s+f', 'whitespace (\s)');
+p6rule_is  ("ab  cdef", 'ab\s+cdef', 'whitespace (\s)');
+p6rule_is  ('abcdef', 'a\S+f', 'not whitespace (\S)');
+p6rule_isnt("ab cdef", 'a\S+f', 'not whitespace (\S)');
+
+
+## ^ and $ -- always matches start and end of string
+p6rule_is  ("abcdef", '^ abc', 'start and end of string (^)');
+p6rule_is  ("abc\ndef", '^ abc', 'start and end of string (^)');
+p6rule_isnt("def\nabc", '^ abc', 'start and end of string (^)');
+p6rule_isnt("def\nabc", 'def \n ^ abc', 'start and end of string (^)');
+p6rule_is  ("abcdef", 'def $', 'start and end of string ($)');
+p6rule_is  ("abc\ndef", 'def $', 'start and end of string ($)');
+p6rule_isnt("def\nabc", 'def $', 'start and end of string ($)');
+p6rule_isnt("def\nabc", 'def $ \n abc', 'start and end of string (^)');
+
+
+## $ -- no longer matches optional preceding \n
+p6rule_is  ("abc\n", 'abc \n $', 'end of string ($)');
+p6rule_isnt("abc\n", 'abc $', 'end of string ($)');
+
+
+
+## (\n and \N -- matches platform independent newline (or everything but)
+p6rule_is  ("abc\ndef", 'c \n d', 'logical newline (\n)');
+p6rule_is  ("abc\012def", 'c \n d', 'logical newline (\n)');
+p6rule_is  ("abc\015def", 'c \n d', 'logical newline (\n)');
+p6rule_is  ("abc\n\ndef", 'c \n+ d', 'logical newline (\n)');
+p6rule_isnt('abcdef', 'a\n+f', 'logical newline (\n)');
+p6rule_is  ("abc\012\015def", 'c \n d', 'logical newline (\n)', todo => 
'specification unclear');
+p6rule_is  ("abc\015\012def", 'c \n d', 'logical newline (\n)', todo => 
'specification unclear');
+p6rule_isnt("abc\ndef", 'b \n c', 'logical newline (\n)');
+p6rule_is  ("a", '\N', 'not logical newline (\N)');
+p6rule_is  ("abc", 'a \N c', 'not logical newline (\N)');
+p6rule_isnt("", '\N', 'not logical newline (\N)');
+p6rule_isnt("abc\ndef", 'c \N d', 'not logical newline (\N)');
+p6rule_isnt("abc\012def", 'c \N d', 'not logical newline (\N)');
+p6rule_isnt("abc\015def", 'c \N d', 'not logical newline (\N)');
+p6rule_isnt("abc\n\ndef", 'c \N+ d', 'not logical newline (\N)');
+p6rule_is  ('abcdef', 'a\N+f', 'not logical newline (\N)');
+p6rule_is  ("abc\012\015def", 'c \N d', 'not logical newline (\N)', todo => 
'specification unclear');
+p6rule_is  ("abc\015\012def", 'c \N d', 'not logical newline (\N)', todo => 
'specification unclear');
+p6rule_is  ("abc\ndef", 'b \N \n', 'not logical newline (\N)');
+
+
+## \A, \Z, and \z -- not metacharacters anymore
+p6rule_is  ("Aabc", '\Aabc', 'retired metachars (\A)');
+p6rule_isnt("abc\ndef", '\Aabc', 'retired metachars (\A)');
+p6rule_is  ("abcZ", 'abc\Z', 'retired metachars (\Z)');
+p6rule_isnt("abc\ndef", 'abc\Z', 'retired metachars (\Z)');
+p6rule_is  ("abcz", 'abc\z', 'retired metachars (\z)');
+p6rule_isnt("abc\ndef", 'def\z', 'retired metachars (\z)');
+
+
+## # -- always introduces comment
+p6rule_is  ("abc#def", 'abc # def', 'comments (#)');
+p6rule_is  ("abc#def", 'abc # xyz', 'comments (#)');
+p6rule_isnt("abc#def", <<"RULE", 'comments (#)');
+abc # def
+\$
+RULE
+p6rule_is  ("abc#def", 'abc \# def', 'comments (#)');
+p6rule_isnt("abc#def", 'abc \# xyz', 'comments (#)');
+p6rule_is  ("abc#def", '^ abc \# def $', 'comments (#)');
+
+
+## ^^ and $$ -- line beginnings and endings
+p6rule_is  ("abc\ndef", '^^ abc \n ^^ def', 'line beginnings and endings 
(^^)');
+p6rule_is  ("abc\ndef\n", '^^ abc \n ^^ def \n ^^', 'line beginnings and 
endings (^^)');
+p6rule_is  ("\n", '^^ \n', 'line beginnings and endings (^^)');
+p6rule_isnt("\n", '\n ^^', 'line beginnings and endings (^^)');
+p6rule_is  ("abc\ndef", 'abc $$ \n def $$', 'line beginnings and endings 
($$)');
+p6rule_is  ("abc\ndef\n", 'abc $$ \n def $$ \n $$', 'line beginnings and 
endings ($$)');
+p6rule_is  ("\n", '$$ \n', 'line beginnings and endings ($$)');
+p6rule_isnt("\n", '\n $$', 'line beginnings and endings ($$)');
 
 
 ## &
+## TODO add tests here
 
 
 ## remember to change the number of tests :-)
-BEGIN { plan tests => 9; }
+BEGIN { plan tests => 56; }

Reply via email to