2 # Copyright (C) 2009-2010, Parrot Foundation.
7 t/pmc/packfilerawsegment.t - test the PackfileRawSegment PMC
13 % prove t/pmc/packfilerawsegment.t
17 Tests the PackfileRawSegment PMC.
21 # Having some known data would be helpful, here. For now, just make sure
22 # the value returned by elements() is greater than zero, and that
23 # get_integer_keyed_int doesn't return all zeroes either.
25 .include 't/pmc/testlib/packfile_common.pir'
26 .include 'packfile_segments.pasm'
28 .include 'test_more.pir'
36 # PackfileRawSegment.elements
38 .local pmc pf, pfdir, pfseg
42 pfdir = pf.'get_directory'()
43 pfseg = '_find_segment_by_prefix'(pf, 'BYTECODE')
45 ok($I0, 'PackfileRawSegment contains some data')
50 report_load_error($P0, 'PackfileRawSegment contains some data')
54 # PackfileRawSegment.get_integer_keyed_int
55 .sub 'test_get_integer'
56 .local pmc pf, pfdir, pfseg
60 pfdir = pf.'get_directory'()
61 pfseg = '_find_segment_by_prefix'(pf, 'BYTECODE')
74 ok($I0, "PackfileRawSegment.get_integer_keyed_int returns some data")
79 report_load_error($P0, "PackfileRawSegment.get_integer_keyed_int returns some data")
83 # PackfileRawSegment.push_integer
84 .sub 'test_push_integer'
86 pfseg = new ['PackfileRawSegment']
91 is($I0, 0x1d1, "PackfileRawSegment.push_integer (1)")
93 is($I0, 0x002, "PackfileRawSegment.push_integer (2)")
96 # PackfileRawSegment.type
98 .local pmc pf, pfdir, pfseg, hash, it
102 pfdir = pf.'get_directory'()
104 # annotations.pbc contains all available segments. -1 for directory and unknown.
105 # So, in hash we should have 5 elements.
117 is($I0, 4, "Got all types of Packfile segments")
119 # Now create RawSegment and set type.
120 $P0 = new ['PackfileRawSegment']
122 is($I0, .PF_BYTEC_SEG, "Default type is PF_BYTEC_SEG")
124 $P0.'type'(.PF_DEBUG_SEG)
126 is($I0, .PF_DEBUG_SEG, "Type successfully changed")
131 report_load_error($P0, "can't run test_type tests")
132 skip(2, "can't run test_type tests")
141 # vim: expandtab shiftwidth=4 ft=pir: