-
Notifications
You must be signed in to change notification settings - Fork 138
/
undef.t
252 lines (214 loc) · 4.3 KB
/
undef.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#! perl
# Copyright (C) 2001-2005, The Perl Foundation.
# $Id$
use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Test tests => 11;
=head1 NAME
t/pmc/undef.t - Undef PMC
=head1 SYNOPSIS
% prove t/pmc/undef.t
=head1 DESCRIPTION
Tests mainly morphing undef to other types.
=cut
pasm_output_is( <<'CODE', <<'OUTPUT', "morph to string" );
new P0, .String
new P1, .Undef
set P0, "foo"
concat P1, P0, P0
print P1
print "\n"
end
CODE
foofoo
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "get_bool" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
print "A PMC Undef created by new is"
if pmc1 goto PMC1_IS
print " not"
PMC1_IS:
print "\n"
end
.end
CODE
A PMC Undef created by new is not
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "defined" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int is_defined
is_defined = defined pmc1
print "A PMC Undef is"
if is_defined goto PMC1_IS_DEFINED
print " not"
PMC1_IS_DEFINED:
print " defined.\n"
end
.end
CODE
A PMC Undef is not defined.
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "get_string" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
print "before"
print pmc1
print "after\n"
end
.end
CODE
beforeafter
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "morph to integer" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int int1
int1 = pmc1
.local int int2
int2 = -7777777
int2 += int1
print int2
print "\n"
end
.end
CODE
-7777777
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "morph to float" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int int1
int1 = pmc1
.local num float1
float1 = -7777777e-3
float1 += int1
print float1
print "\n"
end
.end
CODE
-7777.777000
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "morph to float" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int int1
int1 = pmc1
.local num float1
float1 = -7777777e-3
float1 += int1
print float1
print "\n"
end
.end
CODE
-7777.777000
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "set_integer_native" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
pmc1 = -88888888
print pmc1
print "\n"
.local int pmc1_is_a
pmc1_is_a = isa pmc1, "Integer"
print "After assignment pmc1 is "
if pmc1_is_a goto PMC1_IS_A_INTEGER
print "not "
PMC1_IS_A_INTEGER:
print "an Integer.\n"
end
.end
CODE
-88888888
After assignment pmc1 is an Integer.
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "isa" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int pmc1_is_a
pmc1_is_a = isa pmc1, "Undef"
print "A Undef PMC is "
if pmc1_is_a goto PMC1_IS_A_Undef
print "not "
PMC1_IS_A_Undef:
print "a Undef.\n"
pmc1_is_a = isa pmc1, "default"
print "A Undef PMC is "
if pmc1_is_a goto PMC1_IS_A_default
print "not "
PMC1_IS_A_default:
print "a default.\n"
pmc1_is_a = isa pmc1, "Default"
print "A Undef PMC is "
if pmc1_is_a goto PMC1_IS_A_Default
print "not "
PMC1_IS_A_Default:
print "a Default.\n"
pmc1_is_a = isa pmc1, "scalar"
print "A Undef PMC is "
if pmc1_is_a goto PMC1_IS_A_scalar
print "not "
PMC1_IS_A_scalar:
print "a scalar.\n"
pmc1_is_a = isa pmc1, "Scalar"
print "A Undef PMC is "
if pmc1_is_a goto PMC1_IS_A_Scalar
print "not "
PMC1_IS_A_Scalar:
print "a Scalar.\n"
end
.end
CODE
A Undef PMC is a Undef.
A Undef PMC is not a default.
A Undef PMC is not a Default.
A Undef PMC is not a scalar.
A Undef PMC is not a Scalar.
OUTPUT
pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
.sub _main
.local pmc pmc1
pmc1 = new Undef
.local int bool1
does bool1, pmc1, "scalar"
print bool1
print "\n"
does bool1, pmc1, "no_interface"
print bool1
print "\n"
end
.end
CODE
1
0
OUTPUT
pir_output_is( << 'CODE', << 'OUTPUT', "verify clone works." );
.sub _main
$P1 = new Undef
$P2 = clone $P1
$S0 = typeof $P2
print $S0
print "\n"
.end
CODE
Undef
OUTPUT
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: