[svn:parrot] r45123 - trunk/t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Mar 23 09:18:43 UTC 2010


Author: bacek
Date: Tue Mar 23 09:18:41 2010
New Revision: 45123
URL: https://trac.parrot.org/parrot/changeset/45123

Log:
Add wierd test for Continuation returns handling. Based on test from arnsholt++.

Modified:
   trunk/t/pmc/continuation.t

Modified: trunk/t/pmc/continuation.t
==============================================================================
--- trunk/t/pmc/continuation.t	Tue Mar 23 01:17:24 2010	(r45122)
+++ trunk/t/pmc/continuation.t	Tue Mar 23 09:18:41 2010	(r45123)
@@ -22,6 +22,7 @@
 
     test_new()
     invoke_with_init()
+    returns_tt1511()
 .end
 
 .sub test_new
@@ -41,6 +42,80 @@
 end:
 .end
 
+.sub 'choose'
+    .param pmc options :slurpy
+    .local pmc cc
+    .local pmc chosen
+    .local pmc paths
+
+    if options goto got_options
+    'fail'()
+  got_options:
+    chosen = shift options
+
+    cc = new 'Continuation'
+    set_addr cc, recurse
+    paths = get_global '!paths'
+    push paths, cc
+
+    $P0  = get_global '!results'
+    push $P0, chosen
+    .return (chosen)
+
+  recurse:
+    .tailcall 'choose'(options :flat)
+.end
+
+.sub 'fail'
+    .local pmc cc
+    .local pmc paths
+
+    paths = get_global '!paths'
+
+    if paths goto got_paths
+    cc = get_global '!topcc'
+    goto call_cc
+  got_paths:
+    cc = shift paths
+
+  call_cc:
+    cc()
+.end
+
+.sub 'blob'
+    .local pmc city
+    .local pmc store
+    .local pmc bx
+    .local pmc paths
+
+    paths = new 'ResizablePMCArray'
+    set_global '!paths', paths
+
+    city = 'choose'("la", "ny", "bos")
+    $P0  = get_global '!results'
+    push $P0, city
+    push $P0, ' '
+
+    'fail'()
+.end
+
+.sub 'returns_tt1511'
+    .local pmc cc
+
+    # Install top-level cc in global.
+    cc = new 'Continuation'
+    set_addr cc, final_failure
+    set_global '!topcc', cc
+
+    $P0 = new 'ResizableStringArray'
+    set_global '!results', $P0
+
+    'blob'()
+  final_failure:
+    $S0 = join '', $P0
+    is('lala nyny bosbos ', $S0, 'Results processed correctly')
+.end
+
 # end of tests.
 
 # Local Variables:


More information about the parrot-commits mailing list