# New Ticket Created by  Nuno Carvalho 
# Please include the string:  [perl #40319]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40319 >


Hi parrot people,

Have done some cleannig in the file t/compilers/pge/06-grammar.t, also
haded one PMC to have an array of reasons to todo tests. Also haded a
new test grammar.

Attached to this message you can find a patch to
't/compilers/pge/06-grammar.t'.

Best regards,
./smash
Index: t/compilers/pge/06-grammar.t
===================================================================
--- t/compilers/pge/06-grammar.t	(revision 14552)
+++ t/compilers/pge/06-grammar.t	(working copy)
@@ -47,21 +47,25 @@
     load_bytecode 'compilers/pge/pgc.pir'
     .include "iglobals.pasm"
 
-    .local pmc test
+    .local pmc test, todo_tests, todo_desc, grammar, expr, description
+    
+    # the test builder
     test = new 'Test::Builder'
-    .local pmc todo_tests # Keys indicate tests ID; values reasons.
+
+    # PMCs to store TODO tests and reasons/descriptions
     todo_tests = new .Hash
-    .local pmc grammar
+    todo_desc = new .Hash
+
+    # PMCs to store grammars and expressions to test for each grammar
+    # also set description for that grammar
     grammar = new .ResizableStringArray
-    .local pmc expr 
     expr = new .ResizablePMCArray
-    .local pmc description 
     description = new .ResizableStringArray
 
     .local int ok,n_grammars,n_tests
 
     # plan tests to run 
-    test.'plan'(13)
+    test.'plan'(16)
 
     # define descriptions / grammars / expressions to run
 
@@ -72,8 +76,8 @@
 token number { \d+ }
 EOF_SIMPLE_GRAMMAR
     $P0 = new .ResizableStringArray
-    push $P0, "1313"
-    push $P0, " 1414 "
+    push $P0, '1313' # n1
+    push $P0, ' 1414 ' #n2
     expr[0] = $P0
 
     description[1] = 'simple token/rule match with constant chars'
@@ -83,9 +87,9 @@
 token number { \d+ }
 EOF_SIMPLE_GRAMMAR
     $P0 = new .ResizableStringArray
-    push $P0, "[1313]"
-    push $P0, "[ 1313 ]"
-    push $P0, "[    1313  ]"
+    push $P0, '[1313]' # n3
+    push $P0, '[ 1313 ]' # n4
+    push $P0, '[    1313  ]' # n5
     expr[1] = $P0
 
    description[2] = 'simple token/rule match with repetition using *'
@@ -95,10 +99,10 @@
 token number { \d+ }
 EOF_SIMPLE_GRAMMAR
     $P0 = new .ResizableStringArray
-    push $P0, ""
-    push $P0, "11"
-    push $P0, "11 12 13"
-    push $P0, " 11     12  13   14"
+    push $P0, '' # n6
+    push $P0, '11' # n7
+    push $P0, '11 12 13' # n8
+    push $P0, ' 11     12  13   14' # n9
     expr[2] = $P0
 
    description[3] = 'another simple token/rule match with repetition using *'
@@ -108,7 +112,7 @@
 token number { \d+ }
 EOF_SIMPLE_GRAMMAR
     $P0 = new .ResizableStringArray
-    push $P0, "11 12 13"
+    push $P0, '11 12 13' # n10
     expr[3] = $P0
 
    description[4] = 'simple token/rule match with repetition using +'
@@ -118,18 +122,33 @@
 token number { \d+ }
 EOF_SIMPLE_GRAMMAR
     $P0 = new .ResizableStringArray
-    push $P0, "11"
-    push $P0, "11 12 13"
-    push $P0, " 11     12  13   14"
+    push $P0, '11' # n11
+    push $P0, '11 12 13' # n12
+    push $P0, ' 11     12  13   14' # n13
     expr[4] = $P0
 
+    description[5] = 'simple token/rule match with repetition using *'
+    grammar[5] = <<'EOF_SIMPLE_GRAMMAR'
+grammar Simple::Test;
+rule main { [ <number>]* }
+token number { \d+ }
+EOF_SIMPLE_GRAMMAR
+    $P0 = new .ResizableStringArray
+    push $P0, '11' # n14
+    push $P0, '11 12 13' # n15
+    push $P0, '  11     12  13  ' # n16
+    expr[5] = $P0
+
     # define todo tests
-    # XXX need to add reasons for todo tests
+    # if test is to be tagged TODO set todo_test[test_number] = 1
+    # also add why with todo_desc[test_number] = <reason>
     todo_tests[10] = 1
+    todo_desc[10] = 'bug in PGE'
 
+    # set the number of grammars to run
     n_grammars = elements grammar
 
-    # run the tests
+    # for each grammar run the tests
     $I0 = 0
     n_tests = 0
   main_loop:
@@ -152,7 +171,8 @@
     goto the_end
   skip_test:
     inc $I0
-    test.'todo'(1,$S1)
+    $S2 = todo_desc[n_tests]
+    test.'todo'(1,$S2)
     goto main_loop
   the_end:
 

Reply via email to