Permalink
Browse files

add test files for Opcode and OpLib

git-svn-id: https://svn.parrot.org/parrot/branches/op_pmcs@43976 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent abc47b3 commit db6205ab2804fa120f3c09fdc3191e39ab2fbebe whiteknight committed Feb 15, 2010
Showing with 63 additions and 0 deletions.
  1. +4 −0 src/pmc/oplib.pmc
  2. +29 −0 t/pmc/opcode.t
  3. +30 −0 t/pmc/oplib.t
View
@@ -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() {
View
@@ -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
View
@@ -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
+

0 comments on commit db6205a

Please sign in to comment.