2 # Copyright (C) 2006-2010, Parrot Foundation.
7 t/pmc/parrotinterpreter.t - test the ParrotInterpreter PMC
12 % prove t/pmc/parrotinterpreter.t
16 Tests the ParrotInterpreter PMC.
20 .include 'except_types.pasm'
23 .include 'test_more.pir'
27 test_hll_map() # 3 tests
28 test_hll_map_invalid() # 1 tests
31 .annotate 'foo', 'bar'
32 test_inspect() # 8 tests
36 new $P0, ['ParrotInterpreter']
43 .include 'test_more.pir'
44 $P0 = get_class 'Integer'
45 $P1 = subclass $P0, 'MyInt'
48 $P2.'hll_map'($P0, $P1)
67 # Switch back to root namespace
70 .sub test_hll_map_invalid
73 $P0 = get_class 'Integer'
74 $P1 = subclass $P0, 'MyInt'
76 eh = new ['ExceptionHandler']
78 eh.'handle_types'(.EXCEPTION_INVALID_OPERATION)
81 $P2.'hll_map'($P0, $P1)
87 is(result, 1, 'hll_map outside an HLL throws')
90 # Test accessors to various Interp fields
95 # Enforce creating of lexpad
99 is($P0, 'test_inspect', 'Got ParrotInterp.sub')
101 $P0 = interp['lexpad';0]
102 $I0 = isa $P0, 'LexPad'
103 ok($I0, 'Got ParrotInterp.lexpad')
105 $P0 = interp['namespace';0]
106 $I0 = isa $P0, 'NameSpace'
107 ok($I0, 'Got ParrotInterp.namespace')
109 $P0 = interp['continuation';0]
110 $I0 = isa $P0, 'Continuation'
111 ok($I0, 'Got ParrotInterp.continuation')
113 $P0 = interp['annotations';1]
115 is($S0, 'bar', 'Got ParrotInterp.annotations')
117 $P0 = interp['context';0]
118 $I0 = isa $P0, 'CallContext'
119 ok($I0, 'Got ParrotInterp.context')
120 # Add more tests for Context. E.g. it is correct Context by inspecting it.
124 $P0 = interp['some_field';0]
128 ok($I0, "Access to non-existent field throws exception")
132 $P0 = interp['sub';1000]
136 ok($I0, "Access to wrong depth throws exception")
144 # vim: expandtab shiftwidth=4 ft=pir: