[svn:parrot] r39927 - branches/ops_pct/compilers/opsc/t

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jul 7 12:21:52 UTC 2009


Author: bacek
Date: Tue Jul  7 12:21:51 2009
New Revision: 39927
URL: https://trac.parrot.org/parrot/changeset/39927

Log:
[t] Steal more stuff from pmc_pct - 02-parse-all-files.t

Added:
   branches/ops_pct/compilers/opsc/t/02-parse-all-ops.t
Modified:
   branches/ops_pct/compilers/opsc/t/common.pir
   branches/ops_pct/compilers/opsc/t/harness

Added: branches/ops_pct/compilers/opsc/t/02-parse-all-ops.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/ops_pct/compilers/opsc/t/02-parse-all-ops.t	Tue Jul  7 12:21:51 2009	(r39927)
@@ -0,0 +1,87 @@
+#! ../../parrot
+
+.include 't/common.pir'
+
+.sub 'main' :main
+    .include 'test_more.pir'
+    load_bytecode 'opsc.pbc'
+
+    .local int total
+    .local pmc os, all_files, ops_files, dynops_files
+
+    all_files    = new ['ResizablePMCArray']
+    ops_files    = get_ops_from_dir('../../src/ops/')
+    dynops_files = get_ops_from_dir('../../src/dynoplibs/')
+
+    #prepend the arrays to all_files
+    splice all_files, ops_files, 0, 0
+    splice all_files, dynops_files, 0, 0
+
+    total = elements all_files
+    all_files.'sort'()
+
+    plan(total)
+    test_parse(all_files)
+.end
+
+.sub get_ops_from_dir
+    .param string dir
+    .local pmc files, filtered_files, os, it
+
+    os             = new ['OS']
+    files          = os.'readdir'(dir)
+    filtered_files = new ['ResizablePMCArray']
+
+    .local int len, is_pmc, total
+    .local string filename, filename_end
+
+    #filter out anything that doesn't end in .ops
+    it = iter files
+  iter_start:
+    unless it goto iter_done
+    filename = shift it
+
+    len = length filename
+    unless len > 4 goto iter_start
+
+    filename_end = substr filename, -4
+    is_pmc = iseq filename_end, ".ops"
+    unless is_pmc goto iter_start
+
+    filename = dir . filename
+    push filtered_files, filename
+    goto iter_start
+
+  iter_done:
+    .return (filtered_files)
+.end
+
+.sub 'test_parse'
+    .param pmc list
+    .local int i
+    .local pmc it
+
+    it = iter list
+  iter_start:
+    unless it goto iter_done
+    $S0 = shift it
+    push_eh fail
+    _parse_one_file($S0)
+    pop_eh
+    ok(1, $S0)
+    goto iter_start
+  fail:
+    ok(0, $S0)
+    goto iter_start
+
+  iter_done:
+
+.end
+
+# Don't forget to update plan!
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:

Modified: branches/ops_pct/compilers/opsc/t/common.pir
==============================================================================
--- branches/ops_pct/compilers/opsc/t/common.pir	Tue Jul  7 12:16:20 2009	(r39926)
+++ branches/ops_pct/compilers/opsc/t/common.pir	Tue Jul  7 12:21:51 2009	(r39927)
@@ -10,6 +10,14 @@
     .tailcall compiler.'parse'(buffer, 'target'=>'parse')
 .end
 
+.sub '_parse_one_file'
+    .param string filename
+    .local string buf
+
+    buf = '_slurp'(filename)
+    .tailcall '_parse_buffer'(buf)
+.end
+
 
 .sub '_slurp'
     .param string file

Modified: branches/ops_pct/compilers/opsc/t/harness
==============================================================================
--- branches/ops_pct/compilers/opsc/t/harness	Tue Jul  7 12:16:20 2009	(r39926)
+++ branches/ops_pct/compilers/opsc/t/harness	Tue Jul  7 12:21:51 2009	(r39927)
@@ -4,5 +4,5 @@
 
 use FindBin;
 use lib qw( . lib ../lib ../../lib ../../lib );
-use Parrot::Test::Harness language => 'ops', verbosity => 0;
+use Parrot::Test::Harness language => 'ops', verbosity => 1;
 


More information about the parrot-commits mailing list