2 # Copyright (C) 2009-2010, Parrot Foundation.
7 t/pmc/packfiledirectory.t - test the PackfileDirectory PMC
13 % prove t/pmc/packfiledirectory.t
17 Tests the PackfileDirectory PMC.
21 .include 't/pmc/testlib/packfile_common.pir'
24 .include 'test_more.pir'
31 'test_set_pmc_keyed_str'()
35 # Test creation of fresh directory
38 dir = new 'PackfileDirectory'
39 isa_ok(dir, 'PackfileDirectory')
41 seg = new 'PackfileRawSegment'
43 $P0 = seg.'get_directory'()
46 ok($I0, "Owner of fresh segment unknown")
48 dir['RAWSEGMENT'] = seg
51 $P0 = seg.'get_directory'()
53 ok($I0, "Owner of segment set correctly")
56 # PackfileDirectory.typeof
60 $P1 = pf.'get_directory'()
61 isa_ok($P1, 'PackfileDirectory', 'PackfileDirectory.get_directory')
64 # PackfileDirectory.elements
70 pfdir = pf.'get_directory'()
72 is($I0, 4, 'PackfileDirectory.elements')
77 report_load_error($P0, 'PackfileDirectory.elements')
82 # PackfileDirectory.get_iter
84 .local pmc pf, pfdir, it, expected
87 # expected contains all expected segment "prefixes" with count
89 expected["BYTECODE"] = 2
91 expected["CONSTANT"] = 1
96 pfdir = pf.'get_directory'()
104 $P0 = split '_', name
108 # Decrease expectation count
113 isa_ok($P1, 'PackfileSegment')
114 $P2 = $P1.'get_directory'()
116 ok($I0, "Loaded Segment has proper directory")
123 report_load_error($P0, "can't run get_iter tests")
124 skip(11, "can't run get_iter tests")
128 ## PackfileDirectory.set_pmc_keyed_str
129 .sub 'test_set_pmc_keyed_str'
130 .local pmc pf, pfdir, seg
134 pfdir = pf.'get_directory'()
135 seg = new [ 'PackfileRawSegment' ]
137 # Adding segment with same name replaces old one
143 is($I0, $I1, "Segment with old name was added")
145 # Add segment with new name
147 seg = new [ 'PackfileRawSegment' ]
152 is($I0, $I1, "New segment added")
154 # Remove that segment again
159 is($I0, $I1, "segment deleted")
166 report_load_error($P0, "Segment with old name was added")
167 report_load_error($P0, "New segment added")
168 report_load_error($P0, "segment deleted")
176 # vim: expandtab shiftwidth=4 ft=pir: