[svn:parrot] r49727 - branches/opmap_aware_pmcs/t/pmc

cotto at svn.parrot.org cotto at svn.parrot.org
Fri Oct 29 08:29:22 UTC 2010


Author: cotto
Date: Fri Oct 29 08:29:22 2010
New Revision: 49727
URL: https://trac.parrot.org/parrot/changeset/49727

Log:
[t] add tests for PackfileOpMap

Added:
   branches/opmap_aware_pmcs/t/pmc/packfileopmap.t

Added: branches/opmap_aware_pmcs/t/pmc/packfileopmap.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/opmap_aware_pmcs/t/pmc/packfileopmap.t	Fri Oct 29 08:29:22 2010	(r49727)
@@ -0,0 +1,101 @@
+#!./parrot
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+t/pmc/packfileopmap.t - test the PackfileOpMap PMC
+
+=head1 SYNOPSIS
+
+    % make test_prep
+    % prove t/pmc/packfileopmap.t
+
+=head1 DESCRIPTION
+
+Tests the PackfileOpMap PMC.
+
+=cut
+
+# Having some known data would be helpful, here.  For now, just make sure
+# the values returned from get_type look right, and that the corresponding
+# fetches for the found types don't crash.
+
+
+.include 't/pmc/testlib/packfile_common.pir'
+
+.sub 'main' :main
+    .include 'test_more.pir'
+    'plan'(7)
+
+    'sanity'()
+    'basic'()
+    'load_lib'()
+.end
+
+
+# sanity check we have a PackfilOpMap
+.sub 'sanity'
+    .local pmc opmap
+    opmap = new ['PackfileOpMap']
+    isa_ok(opmap, "PackfileOpMap", "PackfileOpMap is a PackfileOpMap")
+.end
+
+.sub 'basic'
+    .local pmc opmap
+    opmap = new ['PackfileOpMap']
+
+    push_eh fake_op_eh
+    $I0 = opmap['THIS IS NOT A REAL OP']
+    ok(0, "opmap throws an exception for invalid op names")
+    goto done_with_fake_op
+
+  fake_op_eh:
+    ok(1, "opmap throws an exception for invalid op names")
+  done_with_fake_op:
+    pop_eh
+
+    push_eh short_op_eh
+    $I0 = opmap['say']
+    ok(0, "opmap does not attempt to map short op names")
+    goto done_with_short_op
+
+
+  short_op_eh:
+    ok(1, "opmap does not attempt to map short op names")
+  done_with_short_op:
+    pop_eh
+
+    $I0 = opmap['say_sc']
+    $I1 = opmap['say_sc']
+    is($I0, $I1, "opmap always return same value for a given op")
+
+    $I0 = opmap['returncc']
+    $I0 = opmap['issame_i_p_p']
+    $I0 = opmap['cmp_i_i_i']
+
+    $I0 = opmap
+    is($I0, 4, "opmap correctly reports the number of mapped ops")
+.end
+
+.sub 'load_lib'
+    .local pmc opmap
+    opmap = new ['PackfileOpMap']
+
+    ($I0) = opmap.'load_lib'('core_ops')
+    ok(1, "load_lib works with 'core_ops'")
+
+    ($I0) = opmap.'load_lib'('core_ops')
+    ok(1, "load_lib works with 'core_ops' a second time")
+
+    #not sure how to make this work
+    #($I0) = opmap.'load_lib'('math_ops')
+    #ok(1, "load_lib works with 'math_ops'")
+.end
+
+
+# Local Variables:
+#   mode: pir
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:


More information about the parrot-commits mailing list