add svn:ignore (*.str)
[parrot.git] / t / op / copy.t
blob6bbd4cfcc3caa69f258b44fbb0d15a519bbfa6da
1 #!./parrot
2 # Copyright (C) 2007-2008, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/op/copy - Testing the copy opcode
9 =head1 SYNOPSIS
11     % prove t/op/copy.t
13 =head1 DESCRIPTION
15 Tests various PMCs with copy.
17 =cut
19 .sub 'main' :main
20     .include 'test_more.pir'
22     plan(4)
24     test_basic()
25     test_rt48467()
26     test_tonull()
27 .end
29 .sub 'test_basic'
30     .local pmc dest
31     dest = new 'Integer'
32     dest = 2
34     .local pmc src
35     src = new 'Float'
36     src = 1.28
38     dest = copy src
39     isa_ok( dest, 'Float', 'copy should change type of PMC' )
40     is( dest, 1.28, '... and its value' )
41 .end
43 .sub 'test_rt48467'
44     .local pmc my_float
45     my_float = subclass 'Float', 'Num'
47     ##   my $x = 0;
48     .local pmc dest
49     dest = new 'Integer'
50     dest = 0
52     ##   my $y = 3.2;
53     .local pmc src
54     src = new 'Num'
55     src = 3.2
57     ##   $x = $y;
58     dest = copy src
60     ##   $y++;
61     inc src
63     ##   say '$x = ', $x;
64     is( dest, 3.2, 'copy should make independent copies' )
65 .end
67 .sub 'test_tonull'
68     null $P1
69     $P2 = new 'Undef'
70     .local string msg
71     msg = 'failed'
72     push_eh catch
73     copy $P1, $P2
74     goto check
75 catch:
76     .get_results($P3)
77     msg = $P3 ['message']
78 check:
79     pop_eh
80     is( msg, 'Null PMC in copy', 'copy to null throws' )
81 .end
83 # Local Variables:
84 #   mode: pir
85 #   fill-column: 100
86 # End:
87 # vim: expandtab shiftwidth=4 ft=pir: