-
Notifications
You must be signed in to change notification settings - Fork 138
/
copy.t
134 lines (95 loc) · 2.02 KB
/
copy.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
#! parrot
# Copyright (C) 2007-2008, The Perl Foundation.
# $Id$
=head1 NAME
t/op/copy - Testing the copy opcode
=head1 SYNOPSIS
% prove t/op/copy.t
=head1 DESCRIPTION
Tests various PMCs with copy.
=cut
.sub 'main' :main
.include 'include/test_more.pir'
plan(3)
test_basic()
test_rt48467()
.end
.sub 'test_basic'
.local pmc dest
dest = new 'Integer'
dest = 2
.local pmc src
src = new 'Float'
src = 1.28
dest = copy src
isa_ok( dest, 'Float', 'copy should change type of PMC' )
is( dest, 1.28, '... and its value' )
.end
.sub 'test_rt48467'
.local pmc my_float
my_float = subclass 'Float', 'Num'
## my $x = 0;
.local pmc dest
dest = new 'Integer'
dest = 0
## my $y = 3.2;
.local pmc src
src = new 'Num'
src = 3.2
## $x = $y;
dest = copy src
## $y++;
inc src
## say '$x = ', $x;
is( dest, 3.2, 'copy should make independent copies' )
.end
#! parrot
# Copyright (C) 2007, The Perl Foundation.
# $Id$
=head1 NAME
t/op/copy - Testing the copy opcode
=head1 SYNOPSIS
% prove t/op/copy.t
=head1 DESCRIPTION
Tests various PMCs with copy.
=cut
.sub 'main' :main
.include 'include/test_more.pir'
plan(3)
test_basic()
test_rt48467()
.end
.sub 'test_basic'
.local pmc dest
dest = new 'Integer'
dest = 2
.local pmc src
src = new 'Float'
src = 1.28
dest = copy src
isa_ok( dest, 'Float', 'copy should change type of PMC' )
is( dest, 1.28, '... and its value' )
.end
.sub 'test_rt48467'
.local pmc my_float
my_float = subclass 'Float', 'Num'
## my $x = 0;
.local pmc dest
dest = new 'Integer'
dest = 0
## my $y = 3.2;
.local pmc src
src = new 'Num'
src = 3.2
## $x = $y;
dest = copy src
## $y++;
inc src
## say '$x = ', $x;
is( dest, 3.2, 'copy should make independent copies' )
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: