[svn:parrot] r42322 - in trunk: src/pmc t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Sat Nov 7 10:00:22 UTC 2009


Author: bacek
Date: Sat Nov  7 10:00:21 2009
New Revision: 42322
URL: https://trac.parrot.org/parrot/changeset/42322

Log:
[pmc] Implement LexPad.get_iter

Modified:
   trunk/src/pmc/lexpad.pmc
   trunk/t/pmc/lexpad.t

Modified: trunk/src/pmc/lexpad.pmc
==============================================================================
--- trunk/src/pmc/lexpad.pmc	Sat Nov  7 09:25:24 2009	(r42321)
+++ trunk/src/pmc/lexpad.pmc	Sat Nov  7 10:00:21 2009	(r42322)
@@ -159,6 +159,22 @@
         GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
         RETURN(PMC *lexinfo);
     }
+
+/*
+
+=item C<PMC *get_iter()>
+
+Get iterator for declared lexicals.
+
+=cut
+
+*/
+    VTABLE PMC *get_iter() {
+        PMC *lexinfo;
+        GET_ATTR_lexinfo(INTERP, SELF, lexinfo);
+        return VTABLE_get_iter(INTERP, lexinfo);
+    }
+
 }
 
 

Modified: trunk/t/pmc/lexpad.t
==============================================================================
--- trunk/t/pmc/lexpad.t	Sat Nov  7 09:25:24 2009	(r42321)
+++ trunk/t/pmc/lexpad.t	Sat Nov  7 10:00:21 2009	(r42322)
@@ -19,9 +19,10 @@
 
 .sub main :main
     .include 'test_more.pir'
-    plan(1)
+    plan(4)
 
     new_test()
+    test_iter()
 .end
 
 .sub new_test
@@ -35,6 +36,38 @@
 end:
 .end
 
+
+
+.sub 'test_iter'
+
+    .local pmc str1,str2,str3
+    .lex 'a', str1
+    .lex 'b', str2
+    .lex 'c', str3
+
+    str1 = box 'pants'
+    str2 = box 'pants'
+    str3 = box 'pants'
+
+    .local pmc interp
+    interp = getinterp
+
+    .local pmc dlp
+    dlp    = interp['lexpad']
+
+    .local pmc iterator
+    iterator = iter dlp
+iter_loop:
+    unless iterator goto iter_done
+    .local pmc key
+    key = shift iterator
+    .local pmc value
+    value = dlp[key]
+    is(value, 'pants', "Got value from iterator")
+    goto iter_loop
+iter_done:
+.end
+
 # Local Variables:
 #   mode: pir
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list