[svn:parrot] r38436 - branches/pmc_pct/compilers/pmc/t

cotto at svn.parrot.org cotto at svn.parrot.org
Sat May 2 05:17:14 UTC 2009


Author: cotto
Date: Sat May  2 05:17:12 2009
New Revision: 38436
URL: https://trac.parrot.org/parrot/changeset/38436

Log:
[t] factor out some common code between a couple tests

Modified:
   branches/pmc_pct/compilers/pmc/t/05-header.t
   branches/pmc_pct/compilers/pmc/t/06-body.t
   branches/pmc_pct/compilers/pmc/t/common.pir

Modified: branches/pmc_pct/compilers/pmc/t/05-header.t
==============================================================================
--- branches/pmc_pct/compilers/pmc/t/05-header.t	Sat May  2 03:59:12 2009	(r38435)
+++ branches/pmc_pct/compilers/pmc/t/05-header.t	Sat May  2 05:17:12 2009	(r38436)
@@ -31,15 +31,9 @@
     .param string pattern
     .param string message
 
-    .local pmc compiler
-    compiler = compreg 'PMC'
-    $P0 = compiler.'compile'(source, 'target'=>'past')
-
-    .local pmc emitter
-    $P1 = split '::', 'PMC::Emitter'
-    emitter = new $P1
-    emitter.'set_filename'(name)
-    $S0 = emitter.'generate_h_file'($P0)
+    .local pmc emitter, capture
+    (emitter, capture) = get_emitter_and_capture(name, source, 'past')
+    $S0 = emitter.'generate_h_file'(capture)
     say $S0
     like($S0, pattern, message)
 .end

Modified: branches/pmc_pct/compilers/pmc/t/06-body.t
==============================================================================
--- branches/pmc_pct/compilers/pmc/t/06-body.t	Sat May  2 03:59:12 2009	(r38435)
+++ branches/pmc_pct/compilers/pmc/t/06-body.t	Sat May  2 05:17:12 2009	(r38436)
@@ -31,15 +31,9 @@
     .param string pattern
     .param string message
 
-    .local pmc compiler
-    compiler = compreg 'PMC'
-    $P0 = compiler.'compile'(source, 'target'=>'past')
-
-    .local pmc emitter
-    $P1 = split '::', 'PMC::Emitter'
-    emitter = new $P1
-    emitter.'set_filename'(name)
-    $S0 = emitter.'generate_c_file'($P0)
+    .local pmc emitter, capture
+    (emitter, capture) = get_emitter_and_capture(name, source, 'past')
+    $S0 = emitter.'generate_c_file'(capture)
     say $S0
     like($S0, pattern, message)
 .end

Modified: branches/pmc_pct/compilers/pmc/t/common.pir
==============================================================================
--- branches/pmc_pct/compilers/pmc/t/common.pir	Sat May  2 03:59:12 2009	(r38435)
+++ branches/pmc_pct/compilers/pmc/t/common.pir	Sat May  2 05:17:12 2009	(r38436)
@@ -24,6 +24,22 @@
     .return (ret_val)
 .end
 
+
+.sub get_emitter_and_capture
+    .param string name
+    .param string source
+    .param string target
+
+    .local pmc compiler, emitter, capture
+    compiler = compreg 'PMC'
+    capture = compiler.'compile'(source, 'target'=> target)
+
+    emitter = new ['PMC'; 'Emitter']
+    emitter.'set_filename'(name)
+    .return (emitter, capture)
+.end
+
+
 .sub '_slurp'
     .param string file
     .local pmc pio


More information about the parrot-commits mailing list