forked from parrot/parrot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packfile.t
164 lines (132 loc) · 2.69 KB
/
packfile.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!perl
# Copyright (C) 2006-2008, Parrot Foundation.
# $Id$
use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 6;
use Parrot::Config;
=head1 NAME
t/pmc/packfile.t - test the Packfile PMC
=head1 SYNOPSIS
% prove t/pmc/packfile.t
=head1 DESCRIPTION
Tests the Packfile PMC.
=cut
# Packfile constructor
pir_output_is( <<'CODE', <<'OUT', 'new' );
.sub 'test' :main
.local pmc pf
pf = new ['Packfile']
$I0 = defined pf
say $I0
.end
CODE
1
OUT
# Packfile.get_integer_keyed_str
pir_output_is( <<'CODE', <<'OUT', 'get_integer_keyed_str' );
.sub 'test' :main
.local pmc pf
pf = new ['Packfile']
$S0 = 'version_major'
$I0 = pf[$S0]
say $I0
.end
CODE
1
OUT
# Packfile.get_directory
pir_output_is( <<'CODE', <<'OUT', 'get_directory' );
.sub 'test' :main
.local pmc pf
pf = new ['Packfile']
$P1 = pf.'get_directory'()
$S0 = typeof $P1
say $S0
.end
CODE
PackfileDirectory
OUT
# common setup code for later tests
my $get_uuid_pbc = <<'EOF';
.sub _pbc
.include "stat.pasm"
.include "interpinfo.pasm"
.local pmc pf, pio
pf = new ['Packfile']
$S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
$S0 .= "/runtime/parrot/library/uuid.pbc"
$I0 = stat $S0, .STAT_FILESIZE
pio = open $S0, 'r'
$S0 = read pio, $I0
close pio
pf = $S0
.return(pf)
.end
EOF
# Packfile.set_string_native, Packfile.get_integer_keyed_str
pir_output_is( <<'CODE' . $get_uuid_pbc, $PConfig{VERSION}, 'set_string_native' );
.sub 'test' :main
.local pmc pf
pf = _pbc()
$S0 = "version_major"
$I0 = pf[$S0]
$S0 = "version_minor"
$I1 = pf[$S0]
$S0 = "version_patch"
$I2 = pf[$S0]
print $I0
print "."
print $I1
print "."
print $I2
.end
CODE
# Packfile.set_integer_keyed_str
pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
.sub 'test' :main
.local pmc pf
pf = _pbc()
$S1 = 'version_major'
$I0 = pf[$S1]
$I1 = $I0
inc $I1
pf[$S1] = $I1
$I2 = pf[$S1]
eq $I0, $I1, OUT1
print "not "
OUT1:
say "equal"
eq $I1, $I2, OUT2
print "not "
OUT2:
say "equal"
.end
CODE
not equal
equal
OUT
# PackfileSegment.pack (via subclass PackfileDirectory)
pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
.sub 'test' :main
.local pmc pf, pfdir
pf = _pbc()
pfdir = pf.'get_directory'()
$S0 = pfdir.'pack'()
$I0 = length $S0
eq $I0, 0, OUT1
print "not "
OUT1:
say "equal"
.end
CODE
not equal
OUT
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: