[svn:parrot] r41550 - trunk/t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Sep 29 10:33:52 UTC 2009


Author: bacek
Date: Tue Sep 29 10:33:51 2009
New Revision: 41550
URL: https://trac.parrot.org/parrot/changeset/41550

Log:
[t] Add more tests for ParrotInterp

Modified:
   trunk/t/pmc/parrotinterpreter.t

Modified: trunk/t/pmc/parrotinterpreter.t
==============================================================================
--- trunk/t/pmc/parrotinterpreter.t	Tue Sep 29 09:47:21 2009	(r41549)
+++ trunk/t/pmc/parrotinterpreter.t	Tue Sep 29 10:33:51 2009	(r41550)
@@ -17,12 +17,17 @@
 
 =cut
 
+
 .sub main :main
-    .include 'test_more.pir'
+.include 'test_more.pir'
 
-    plan(3)
-    test_new()
-    test_hll_map()
+    plan(10)
+    test_new()      # 1 test
+    test_hll_map()  # 2 tests
+
+# Need for testing
+.annotate 'foo', 'bar'
+    test_inspect()  # 7 tests
 .end
 
 .sub test_new
@@ -33,7 +38,7 @@
 .HLL 'Perl6'
 
 .sub test_hll_map
-    .include 'test_more.pir'
+.include 'test_more.pir'
     $P0 = get_class 'Integer'
     $P1 = subclass $P0, 'MyInt'
 
@@ -50,6 +55,54 @@
     .return (3)
 .end
 
+# Switch back to root namespace
+.HLL 'parrot'
+
+# Test accessors to various Interp fields
+.sub 'test_inspect'
+    .local pmc interp
+    interp = getinterp
+
+    # Enforce creating of lexpad
+    .lex 'foo', interp
+
+    $P0 = interp['sub';0]
+    is($P0, 'test_inspect', 'Got ParrotInterp.sub')
+
+    $P0 = interp['lexpad';0]
+    $I0 = isa $P0, 'LexPad'
+    ok($I0, 'Got ParrotInterp.lexpad')
+
+    $P0 = interp['namespace';0]
+    $I0 = isa $P0, 'NameSpace'
+    ok($I0, 'Got ParrotInterp.namespace')
+    
+    $P0 = interp['continuation';0]
+    $I0 = isa $P0, 'Continuation'
+    ok($I0, 'Got ParrotInterp.continuation')
+    
+    $P0 = interp['annotations';1]
+    $S0 = $P0['foo']
+    is($S0, 'bar', 'Got ParrotInterp.annotations')
+
+    push_eh cought
+    $I0 = 1
+    $P0 = interp['some_field';0]
+    $I0 = 0
+  cought:
+    pop_eh
+    ok($I0, "Access to non-existing field throws exception")
+
+    push_eh wrong_depth
+    $I0 = 1
+    $P0 = interp['sub';1000]
+    $I0 = 0
+  wrong_depth:
+    pop_eh
+    ok($I0, "Access to wrong depth throws exception")
+
+.end
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list