[cage] Update release manager guide about committing to trunk near a release, based...
[parrot.git] / t / oo / proxy.t
blob315d09266bce1927182d51f13bb772b10a07e253
1 #! parrot
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
5 =head1 NAME
7 t/oo/proxy.t - Test OO class proxies.
9 =head1 SYNOPSIS
11     % prove t/oo/proxy.t
13 =head1 DESCRIPTION
15 Tests OO features related to creating and using class proxies.
17 =cut
19 .sub main :main
20     .include 'test_more.pir'
22     plan(11)
24     typeof_a_low_level_object()
25     typeof_a_high_level_object()
26     typeof_a_class_object()
27     proxy_as_parent_of_class()
28     proxy_as_parent_of_class_with_new()
29     proxy_no_method_conflict()
30     .local pmc proxy_no_invade
31     proxy_no_invade = get_root_global ['foo'], 'proxy_no_invade'
32     proxy_no_invade()
33 .end
35 .sub typeof_a_low_level_object
36     $P0 = new 'String'
37     $S1 = typeof $P0
38     $P1 = typeof $P0
39     $I3 = isa $P1, "PMCProxy"
41     is ($S1, 'String', 'object is typeof string')
42     ok ($I3, 'object isa PMCProxy')
43 .end
45 .sub typeof_a_high_level_object
46     $P0 = newclass "Foo"
47     $P0 = new "Foo"
49     $S1 = typeof $P0
50     is ($S1, 'Foo', 'object is typeof Foo')
52     $P1 = typeof $P0
53     $I3 = isa $P1, "PMCProxy"
54     nok ($I3, 'object not isa PMCProxy')
56     $I3 = isa $P1, "Foo"
57     ok ($I3, 'object isa Foo')
58 .end
60 .sub typeof_a_class_object
61     $P0 = newclass "Bar"
62     $S1 = typeof $P0
63     is ($S1, 'Class', 'object is typeof Class')
64     $P1 = typeof $P0
66     $I3 = isa $P1, "PMCProxy"
67     ok ($I3, "object isa PMCProxy")
68 .end
70 .sub proxy_as_parent_of_class
71     $P0 = get_class 'Hash'
72     $P1 = subclass $P0, [ 'MyClass' ]
73     $P2 = new [ 'MyClass' ]
74     $P2['xyz'] = 'abc'
75     $S1 = $P2['xyz']
76     is ($S1, 'abc', "retrieve value from subclassed hash")
77 .end
79 .sub proxy_as_parent_of_class_with_new
80     $P0 = get_class 'Hash'
81     $P1 = subclass $P0, ['Foo';'Bar']
82     $P2 = new ['Foo';'Bar']
83     $S0 = typeof $P2
84     is ($S0, 'Foo;Bar', 'object is typeof Foo;Bar')
85 .end
87 .sub proxy_no_method_conflict
88     $P0 = new 'Complex'
89     $P0['real'] = 1
90     $P1 = $P0.'Complex'()
91     $S0 = $P1
92     is($S0, "1+0i", 'Complex method survived')
93 .end
95 .namespace ['Complex']
96 .sub 'Complex' :method
97     .return (self)
98 .end
100 .HLL 'foo'
102 .sub proxy_no_invade
103     .local pmc is
104     is = get_root_global ['parrot'], 'is'
106     $P0 = new 'Class'
107     $I0 = isa $P0, 'Sub'
108     $P1 = get_root_global ['foo'], 'Sub'
109     $I1 = 0
110     if null $P1 goto do_test
111     inc $I1
112 do_test:
113     is($I1, 0, 'No proxy in current HLL namespace, TT #715')
114 .end
117 # Local Variables:
118 #   mode: pir
119 #   fill-column: 100
120 # End:
121 # vim: expandtab shiftwidth=4 ft=pir: