[svn:parrot] r43976 - in branches/op_pmcs: src/pmc t/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Mon Feb 15 23:55:32 UTC 2010


Author: whiteknight
Date: Mon Feb 15 23:55:32 2010
New Revision: 43976
URL: https://trac.parrot.org/parrot/changeset/43976

Log:
add test files for Opcode and OpLib

Added:
   branches/op_pmcs/t/pmc/opcode.t
   branches/op_pmcs/t/pmc/oplib.t
Modified:
   branches/op_pmcs/src/pmc/oplib.pmc

Modified: branches/op_pmcs/src/pmc/oplib.pmc
==============================================================================
--- branches/op_pmcs/src/pmc/oplib.pmc	Mon Feb 15 22:44:05 2010	(r43975)
+++ branches/op_pmcs/src/pmc/oplib.pmc	Mon Feb 15 23:55:32 2010	(r43976)
@@ -1,5 +1,9 @@
 #include "parrot/parrot.h"
 
+/* TODO: Since Opcode PMCs are essentially read-only after initialization
+         here, we should cache them. A FixedPMCArray would be okay, an
+         INTVAL->PMC HASH might be better, since it's unlike that we will
+         need to cache even a majority of the ~1300 ops. */
 static PMC *OPLIB_PMC_INSTANCE;
 pmclass OpLib {
     void class_init() {

Added: branches/op_pmcs/t/pmc/opcode.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/op_pmcs/t/pmc/opcode.t	Mon Feb 15 23:55:32 2010	(r43976)
@@ -0,0 +1,29 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/opcode.t - Opcode PMC
+
+=head1 SYNOPSIS
+
+    % prove t/pmc/opcode.t
+
+=cut
+
+.sub main :main
+    .include 'test_more.pir'
+    plan(1)
+    cannot_create_directly()
+.end
+
+.sub cannot_create_directly
+    push_eh cannot_create
+    $P0 = new ['Opcode']
+    ok(0, "shouldn't be able to create new opcode")
+    goto create_end
+  cannot_create:
+    ok(1)
+  create_end:
+.end

Added: branches/op_pmcs/t/pmc/oplib.t
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/op_pmcs/t/pmc/oplib.t	Mon Feb 15 23:55:32 2010	(r43976)
@@ -0,0 +1,30 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/oplib.t - OpLib PMC
+
+=head1 SYNOPSIS
+
+    % prove t/pmc/oplib.t
+
+=cut
+
+.sub main :main
+    .include 'test_more.pir'
+    plan(1)
+    get_singleton()
+.end
+
+.sub get_singleton
+    $P0 = new ['OpLib']
+    $I0 = isnull $P0
+    is($I0, 0)
+
+    # TODO: How to test that this is actually a singleton?
+    #$P1 = new ['OpLib']
+    #is($P0, $P1)
+.end
+


More information about the parrot-commits mailing list