diff --git t/library/protoobject.t t/library/protoobject.t
index c9c6315..05e8c53 100644
|
|
|
1 | | #!perl |
| 1 | #!parrot |
2 | 2 | # Copyright (C) 2001-2005, Parrot Foundation. |
3 | 3 | # $Id$ |
4 | 4 | |
5 | | use strict; |
6 | | use warnings; |
7 | | use lib qw( t . lib ../lib ../../lib ); |
8 | | use Test::More; |
9 | | use Parrot::Test tests => 9; |
10 | | |
11 | 5 | =head1 NAME |
12 | 6 | |
13 | 7 | t/library/protoobject.t - testing Protoobject.pir |
… |
… |
|
22 | 16 | |
23 | 17 | =cut |
24 | 18 | |
25 | | pir_output_is( << 'END_CODE', << 'END_OUT', 'basic load' ); |
26 | 19 | .sub main :main |
| 20 | .include 'test_more.pir' |
| 21 | plan(13) |
| 22 | |
| 23 | test_basic_load() |
| 24 | test_type_of_protoobject() |
| 25 | test_type_of_ns_based_protoobject() |
| 26 | test_protoobject_symbol_1() |
| 27 | test_protoobject_symbol_2() |
| 28 | test_protoobject_symbol_for_classes() |
| 29 | test_new_subclass_for_classes() |
| 30 | test_new_subclass_with_attrs() |
| 31 | test_method_new_on_protoobject() |
| 32 | .end |
| 33 | |
| 34 | .sub test_basic_load |
27 | 35 | load_bytecode 'Protoobject.pbc' |
28 | 36 | |
29 | 37 | $P0 = get_hll_global 'Protomaker' |
30 | 38 | $S0 = typeof $P0 |
31 | | say $S0 |
| 39 | is($S0, 'Protomaker', 'basic load') |
32 | 40 | .end |
33 | | END_CODE |
34 | | Protomaker |
35 | | END_OUT |
36 | 41 | |
37 | | pir_output_is( << 'END_CODE', << 'END_OUT', 'type of protoobject' ); |
38 | | .sub main :main |
| 42 | .sub test_type_of_protoobject |
39 | 43 | load_bytecode 'Protoobject.pbc' |
40 | 44 | |
41 | 45 | $P0 = get_hll_global 'Protomaker' |
… |
… |
|
43 | 47 | $P2 = $P0.'new_proto'($P1) |
44 | 48 | |
45 | 49 | $S0 = typeof $P2 |
46 | | say $S0 |
| 50 | is($S0, 'XYZ', 'type of protoobject') |
47 | 51 | .end |
48 | | END_CODE |
49 | | XYZ |
50 | | END_OUT |
51 | 52 | |
52 | | pir_output_is( << 'END_CODE', << 'END_OUT', 'type of ns-based protoobject' ); |
53 | | .sub main :main |
| 53 | .sub test_type_of_ns_based_protoobject |
54 | 54 | load_bytecode 'Protoobject.pbc' |
55 | 55 | |
56 | 56 | $P0 = get_hll_global 'Protomaker' |
57 | | $P1 = newclass ['Foo';'Bar'] |
| 57 | $P1 = newclass ['Foo';'Bar1'] |
58 | 58 | $P2 = $P0.'new_proto'($P1) |
59 | 59 | |
60 | 60 | $S0 = typeof $P2 |
61 | | say $S0 |
| 61 | is($S0, 'Foo;Bar1', 'type of ns-based protoobject') |
62 | 62 | .end |
63 | | END_CODE |
64 | | Foo;Bar |
65 | | END_OUT |
66 | 63 | |
67 | | pir_output_is( << 'END_CODE', << 'END_OUT', 'Protoobject symbol' ); |
68 | | .sub main :main |
| 64 | .sub test_protoobject_symbol_1 |
69 | 65 | load_bytecode 'Protoobject.pbc' |
70 | 66 | |
71 | 67 | $P0 = get_hll_global 'Protomaker' |
72 | | $P1 = newclass ['Foo';'Bar'] |
| 68 | $P1 = newclass ['Foo';'Bar2'] |
73 | 69 | $P2 = $P0.'new_proto'($P1) |
74 | 70 | |
75 | | $P2 = get_hll_global ['Foo'], 'Bar' |
| 71 | $P2 = get_hll_global ['Foo'], 'Bar2' |
76 | 72 | $S0 = typeof $P2 |
77 | | say $S0 |
| 73 | is($S0, 'Foo;Bar2', 'protoobject symbol 1') |
78 | 74 | .end |
79 | | END_CODE |
80 | | Foo;Bar |
81 | | END_OUT |
82 | 75 | |
83 | | pir_output_is( << 'END_CODE', << 'END_OUT', 'Protoobject symbol' ); |
84 | | .sub main :main |
| 76 | .sub test_protoobject_symbol_2 |
85 | 77 | load_bytecode 'Protoobject.pbc' |
86 | 78 | |
87 | 79 | $P0 = get_hll_global 'Protomaker' |
… |
… |
|
90 | 82 | |
91 | 83 | $P2 = get_hll_global 'Foo' |
92 | 84 | $S0 = typeof $P2 |
93 | | say $S0 |
| 85 | is($S0, 'Foo', 'protoobject symbol 2') |
94 | 86 | .end |
95 | | END_CODE |
96 | | Foo |
97 | | END_OUT |
98 | 87 | |
99 | | pir_output_is( <<'END_CODE', <<'END_OUT', 'Protoobject symbol for :: classes' ); |
100 | | .sub main :main |
| 88 | .sub test_protoobject_symbol_for_classes |
101 | 89 | load_bytecode 'Protoobject.pbc' |
102 | 90 | |
103 | 91 | $P0 = get_hll_global 'Protomaker' |
104 | | $P1 = newclass 'Foo::Bar' |
| 92 | $P1 = newclass 'Foo::Bar3' |
105 | 93 | $P2 = $P0.'new_proto'($P1) |
106 | 94 | |
107 | | $P2 = get_hll_global ['Foo'], 'Bar' |
| 95 | $P2 = get_hll_global ['Foo'], 'Bar3' |
108 | 96 | $S0 = typeof $P2 |
109 | | say $S0 |
| 97 | is($S0, 'Foo::Bar3', 'protoobject symbol for :: classes') |
110 | 98 | .end |
111 | | END_CODE |
112 | | Foo::Bar |
113 | | END_OUT |
114 | 99 | |
115 | | pir_output_is( <<'END_CODE', <<'END_OUT', 'new_subclass for :: classes' ); |
116 | | .sub main :main |
| 100 | .sub test_new_subclass_for_classes |
117 | 101 | load_bytecode 'Protoobject.pbc' |
118 | 102 | |
119 | 103 | $P0 = get_hll_global 'Protomaker' |
120 | 104 | $P1 = get_class 'Hash' |
121 | | $P0.'new_subclass'($P1, 'Foo::Bar') |
| 105 | $P0.'new_subclass'($P1, 'Foo::Bar4') |
122 | 106 | |
123 | | $P2 = new 'Foo::Bar' |
| 107 | $P2 = new 'Foo::Bar4' |
124 | 108 | $S0 = typeof $P2 |
125 | | say $S0 |
| 109 | is($S0, 'Foo::Bar4', 'new_subclass for :: classes') |
126 | 110 | |
127 | | $P2 = get_hll_global ['Foo'], 'Bar' |
| 111 | $P2 = get_hll_global ['Foo'], 'Bar4' |
128 | 112 | $S0 = typeof $P2 |
129 | | say $S0 |
| 113 | is($S0, 'Foo::Bar4', 'new_subclass for :: classes') |
130 | 114 | .end |
131 | | END_CODE |
132 | | Foo::Bar |
133 | | Foo::Bar |
134 | | END_OUT |
135 | 115 | |
136 | | pir_output_is( <<'END_CODE', <<'END_OUT', 'new_subclass with attrs' ); |
137 | | .sub main :main |
| 116 | .sub test_new_subclass_with_attrs |
138 | 117 | load_bytecode 'Protoobject.pbc' |
139 | 118 | |
140 | 119 | .local pmc protomaker, hashclass, attrs |
… |
… |
|
152 | 131 | $S0 = $P0 |
153 | 132 | setattribute object, $S0, $P0 |
154 | 133 | $P1 = getattribute object, $S0 |
155 | | say $P1 |
| 134 | is($P1, $P0,'new_subclass with attrs') |
156 | 135 | goto iter_loop |
157 | 136 | iter_end: |
158 | 137 | .end |
159 | | END_CODE |
160 | | $a |
161 | | $b |
162 | | $c |
163 | | $d |
164 | | END_OUT |
165 | | |
166 | | pir_output_is( <<'END_CODE', <<'END_OUT', 'method "new" on protoobject' ); |
167 | | .sub main :main |
| 138 | |
| 139 | .sub test_method_new_on_protoobject |
168 | 140 | load_bytecode 'Protoobject.pbc' |
169 | 141 | |
170 | | $P0 = newclass 'Foo' |
| 142 | $P0 = newclass 'Foo1' |
171 | 143 | |
172 | 144 | .local pmc protomaker |
173 | 145 | protomaker = get_hll_global 'Protomaker' |
174 | | protomaker.'new_proto'('Foo') |
| 146 | protomaker.'new_proto'('Foo1') |
175 | 147 | |
176 | | $P0 = get_hll_global 'Foo' |
| 148 | $P0 = get_hll_global 'Foo1' |
177 | 149 | $P1 = $P0.'new'() |
178 | 150 | $S0 = typeof $P1 |
179 | | say $S0 |
| 151 | is($S0, 'Foo1', 'method "new" on protoobject') |
180 | 152 | .end |
181 | | END_CODE |
182 | | Foo |
183 | | END_OUT |
184 | 153 | |
185 | 154 | # Local Variables: |
186 | 155 | # mode: cperl |
187 | 156 | # cperl-indent-level: 4 |
188 | 157 | # fill-column: 100 |
189 | 158 | # End: |
190 | | # vim: expandtab shiftwidth=4: |
191 | | |
| 159 | # vim: expandtab shiftwidth=4 filetype=pir: |