2 # Copyright (C) 2001-2010, Parrot Foundation.
7 t/library/protoobject.t - testing Protoobject.pir
11 % prove t/library/protoobject.t
15 This test exercises the protoobject/Protomaker implementations.
20 load_bytecode 'Protoobject.pbc'
22 .include 'test_more.pir'
26 test_type_of_protoobject()
27 test_type_of_ns_based_protoobject()
28 test_protoobject_symbol_1()
29 test_protoobject_symbol_2()
30 test_protoobject_symbol_for_classes()
31 test_new_subclass_for_classes()
32 test_new_subclass_with_attrs()
33 test_method_new_on_protoobject()
38 $P0 = get_hll_global 'Protomaker'
40 is($S0, 'Protomaker', 'basic load')
44 .sub test_type_of_protoobject
45 $P0 = get_hll_global 'Protomaker'
47 $P2 = $P0.'new_proto'($P1)
50 is($S0, 'XYZ', 'type of protoobject')
54 .sub test_type_of_ns_based_protoobject
55 $P0 = get_hll_global 'Protomaker'
56 $P1 = newclass ['Foo';'Bar1']
57 $P2 = $P0.'new_proto'($P1)
60 is($S0, 'Foo;Bar1', 'type of ns-based protoobject')
64 .sub test_protoobject_symbol_1
65 $P0 = get_hll_global 'Protomaker'
66 $P1 = newclass ['Foo';'Bar2']
67 $P2 = $P0.'new_proto'($P1)
69 $P2 = get_hll_global ['Foo'], 'Bar2'
71 is($S0, 'Foo;Bar2', 'protoobject symbol 1')
75 .sub test_protoobject_symbol_2
76 $P0 = get_hll_global 'Protomaker'
78 $P2 = $P0.'new_proto'($P1)
80 $P2 = get_hll_global 'Foo'
82 is($S0, 'Foo', 'protoobject symbol 2')
86 .sub test_protoobject_symbol_for_classes
87 $P0 = get_hll_global 'Protomaker'
88 $P1 = newclass 'Foo::Bar3'
89 $P2 = $P0.'new_proto'($P1)
91 $P2 = get_hll_global ['Foo'], 'Bar3'
93 is($S0, 'Foo::Bar3', 'protoobject symbol for :: classes')
97 .sub test_new_subclass_for_classes
98 $P0 = get_hll_global 'Protomaker'
99 $P1 = get_class 'Hash'
100 $P0.'new_subclass'($P1, 'Foo::Bar4')
102 $P2 = new 'Foo::Bar4'
104 is($S0, 'Foo::Bar4', 'new_subclass for :: classes')
106 $P2 = get_hll_global ['Foo'], 'Bar4'
108 is($S0, 'Foo::Bar4', 'new_subclass for :: classes')
112 .sub test_new_subclass_with_attrs
113 .local pmc protomaker, hashclass, attrs
114 protomaker = get_hll_global 'Protomaker'
115 hashclass = get_class 'Hash'
116 attrs = split ' ', '$a $b $c $d'
117 protomaker.'new_subclass'(hashclass, 'Foo::Bar', attrs :flat)
119 .local pmc object, it
120 object = new 'Foo::Bar'
123 unless it goto iter_end
126 setattribute object, $S0, $P0
127 $P1 = getattribute object, $S0
128 is($P1, $P0,'new_subclass with attrs')
134 .sub test_method_new_on_protoobject
135 $P0 = newclass 'Foo1'
137 .local pmc protomaker
138 protomaker = get_hll_global 'Protomaker'
139 protomaker.'new_proto'('Foo1')
141 $P0 = get_hll_global 'Foo1'
144 is($S0, 'Foo1', 'method "new" on protoobject')
152 # vim: expandtab shiftwidth=4 ft=pir: