tagged release 0.6.4
[parrot.git] / languages / perl6 / t / pmc / mutable.t
blob4852b9b820d34da8453958a0474ea83d39823665
1 #! ../../parrot
2 # Copyright (C) 2007-2008, The Perl Foundation.
3 # $Id:$
5 =head1 NAME
7 t/pmc/mutable.t - Test the Mutable PMC
9 =head1 SYNOPSIS
11     % prove t/pmc/mutable.t
13 =head1 DESCRIPTION
15 Tests the Mutable PMC.
17 =cut
19 .loadlib 'perl6_group'
21 .sub main :main
22     .include 'include/test_more.pir'
23     load_bytecode "perl6.pbc"
25     plan(4)
27     init()
28     assign_val()
29     meth_call()
30     multi_call()
31 .end    
34 .sub init
35     # Mutable is initialized to contain an undef.
36     $P1 = new "Mutable"
37     $S1 = typeof $P1
38     is($S1, 'Undef', 'typeof newclass retval')
39 .end
42 .sub assign_val
43     # Assigning a value.
44     $P1 = new 'Mutable'
45     $P2 = get_hll_global 'Int'
46     $P2 = $P2.'new'()
47     $P2 = 42
48     assign $P1, $P2
50     # Get integer value; see what we have stored.
51     $I0 = $P1
52     is($I0, 42, 'stored value')
53 .end
56 .sub meth_call
57     # Check we can call methods.
58     $P1 = new 'Mutable'
59     $P2 = 'list'(1,2,3)
60     assign $P1, $P2
61     $I0 = $P1.'elems'()
62     is($I0, 3, 'method calls on value work')
63 .end
66 .sub multi_call
67     # Try and do a multi-dispatch call with two items.
68     .local pmc x, y
69     x = new 'Mutable'
70     y = new 'Mutable'
71     $P2 = get_hll_global 'Int'
72     $P3 = $P2.'new'()
73     $P3 = 35
74     x = $P3
75     $P4 = $P2.'new'()
76     $P4 = 7
77     y = $P4
78     $P5 = 'infix:+'(x, y)
79     $I0 = $P5
80     is($I0, 42, 'multi call worked')
81 .end
84 # Local Variables:
85 #   mode: pir
86 #   fill-column: 100
87 # End:
88 # vim: expandtab shiftwidth=4 ft=pir: