2 # Copyright (C) 2009, Parrot Foundation.
7 t/pmc/packfiledirectory.t - test the PackfileDirectory PMC
12 % prove t/pmc/packfiledirectory.t
16 Tests the PackfileDirectory PMC.
20 .include 't/pmc/testlib/packfile_common.pir'
23 .include 'test_more.pir'
30 'test_set_pmc_keyed_str'()
33 # Test creation of fresh directory
36 dir = new 'PackfileDirectory'
37 isa_ok(dir, 'PackfileDirectory')
39 seg = new 'PackfileRawSegment'
41 $P0 = seg.'get_directory'()
44 ok($I0, "Owner of fresh segment unknown")
46 dir['RAWSEGMENT'] = seg
49 $P0 = seg.'get_directory'()
51 ok($I0, "Owner of segment set correctly")
54 # PackfileDirectory.typeof
58 $P1 = pf.'get_directory'()
59 isa_ok($P1, 'PackfileDirectory', 'PackfileDirectory.get_directory')
62 # PackfileDirectory.elements
66 pfdir = pf.'get_directory'()
68 is($I0, 4, 'PackfileDirectory.elements')
72 # PackfileDirectory.get_iter
74 .local pmc pf, pfdir, it, expected
77 # expected contains all expected segment "prefixes" with count
79 expected["BYTECODE"] = 2
81 expected["CONSTANT"] = 1
84 pfdir = pf.'get_directory'()
96 # Decrease expectation count
101 isa_ok($P1, 'PackfileSegment')
102 $P2 = $P1.'get_directory'()
104 ok($I0, "Loaded Segment has proper directory")
110 ## PackfileDirectory.set_pmc_keyed_str
111 .sub 'test_set_pmc_keyed_str'
112 .local pmc pf, pfdir, seg
114 pfdir = pf.'get_directory'()
115 seg = new [ 'PackfileRawSegment' ]
117 # Adding segment with same name replaces old one
123 is($I0, $I1, "Segment with old name was added")
125 # Add segment with new name
127 seg = new [ 'PackfileRawSegment' ]
132 is($I0, $I1, "New segment added")
134 # Remove that segment again
139 is($I0, $I1, "segment deleted")
147 # cperl-indent-level: 4
150 # vim: expandtab shiftwidth=4: