Ticket #1312: library_protoobject_t.patch

File library_protoobject_t.patch, 5.3 KB (added by bubaflub, 12 years ago)

patch to convert t/library/protoobject.t to PIR

  • t/library/protoobject.t

    diff --git t/library/protoobject.t t/library/protoobject.t
    index c9c6315..05e8c53 100644
     
    1 #!perl 
     1#!parrot 
    22# Copyright (C) 2001-2005, Parrot Foundation. 
    33# $Id$ 
    44 
    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  
    115=head1 NAME 
    126 
    137t/library/protoobject.t - testing Protoobject.pir 
     
    2216 
    2317=cut 
    2418 
    25 pir_output_is( << 'END_CODE', << 'END_OUT', 'basic load' ); 
    2619.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 
    2735    load_bytecode 'Protoobject.pbc' 
    2836 
    2937    $P0 = get_hll_global 'Protomaker' 
    3038    $S0 = typeof $P0 
    31     say $S0 
     39    is($S0, 'Protomaker', 'basic load') 
    3240.end 
    33 END_CODE 
    34 Protomaker 
    35 END_OUT 
    3641 
    37 pir_output_is( << 'END_CODE', << 'END_OUT', 'type of protoobject' ); 
    38 .sub main :main 
     42.sub test_type_of_protoobject 
    3943    load_bytecode 'Protoobject.pbc' 
    4044 
    4145    $P0 = get_hll_global 'Protomaker' 
     
    4347    $P2 = $P0.'new_proto'($P1) 
    4448 
    4549    $S0 = typeof $P2 
    46     say $S0 
     50    is($S0, 'XYZ', 'type of protoobject') 
    4751.end 
    48 END_CODE 
    49 XYZ 
    50 END_OUT 
    5152 
    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 
    5454    load_bytecode 'Protoobject.pbc' 
    5555 
    5656    $P0 = get_hll_global 'Protomaker' 
    57     $P1 = newclass ['Foo';'Bar'] 
     57    $P1 = newclass ['Foo';'Bar1'] 
    5858    $P2 = $P0.'new_proto'($P1) 
    5959 
    6060    $S0 = typeof $P2 
    61     say $S0 
     61    is($S0, 'Foo;Bar1', 'type of ns-based protoobject') 
    6262.end 
    63 END_CODE 
    64 Foo;Bar 
    65 END_OUT 
    6663 
    67 pir_output_is( << 'END_CODE', << 'END_OUT', 'Protoobject symbol' ); 
    68 .sub main :main 
     64.sub test_protoobject_symbol_1 
    6965    load_bytecode 'Protoobject.pbc' 
    7066 
    7167    $P0 = get_hll_global 'Protomaker' 
    72     $P1 = newclass ['Foo';'Bar'] 
     68    $P1 = newclass ['Foo';'Bar2'] 
    7369    $P2 = $P0.'new_proto'($P1) 
    7470 
    75     $P2 = get_hll_global ['Foo'], 'Bar' 
     71    $P2 = get_hll_global ['Foo'], 'Bar2' 
    7672    $S0 = typeof $P2 
    77     say $S0 
     73    is($S0, 'Foo;Bar2', 'protoobject symbol 1') 
    7874.end 
    79 END_CODE 
    80 Foo;Bar 
    81 END_OUT 
    8275 
    83 pir_output_is( << 'END_CODE', << 'END_OUT', 'Protoobject symbol' ); 
    84 .sub main :main 
     76.sub test_protoobject_symbol_2 
    8577    load_bytecode 'Protoobject.pbc' 
    8678 
    8779    $P0 = get_hll_global 'Protomaker' 
     
    9082 
    9183    $P2 = get_hll_global 'Foo' 
    9284    $S0 = typeof $P2 
    93     say $S0 
     85    is($S0, 'Foo', 'protoobject symbol 2') 
    9486.end 
    95 END_CODE 
    96 Foo 
    97 END_OUT 
    9887 
    99 pir_output_is( <<'END_CODE', <<'END_OUT', 'Protoobject symbol for :: classes' ); 
    100 .sub main :main 
     88.sub test_protoobject_symbol_for_classes 
    10189    load_bytecode 'Protoobject.pbc' 
    10290 
    10391    $P0 = get_hll_global 'Protomaker' 
    104     $P1 = newclass 'Foo::Bar' 
     92    $P1 = newclass 'Foo::Bar3' 
    10593    $P2 = $P0.'new_proto'($P1) 
    10694 
    107     $P2 = get_hll_global ['Foo'], 'Bar' 
     95    $P2 = get_hll_global ['Foo'], 'Bar3' 
    10896    $S0 = typeof $P2 
    109     say $S0 
     97    is($S0, 'Foo::Bar3', 'protoobject symbol for :: classes') 
    11098.end 
    111 END_CODE 
    112 Foo::Bar 
    113 END_OUT 
    11499 
    115 pir_output_is( <<'END_CODE', <<'END_OUT', 'new_subclass for :: classes' ); 
    116 .sub main :main 
     100.sub test_new_subclass_for_classes 
    117101    load_bytecode 'Protoobject.pbc' 
    118102 
    119103    $P0 = get_hll_global 'Protomaker' 
    120104    $P1 = get_class 'Hash' 
    121     $P0.'new_subclass'($P1, 'Foo::Bar') 
     105    $P0.'new_subclass'($P1, 'Foo::Bar4') 
    122106 
    123     $P2 = new 'Foo::Bar' 
     107    $P2 = new 'Foo::Bar4' 
    124108    $S0 = typeof $P2 
    125     say $S0 
     109    is($S0, 'Foo::Bar4', 'new_subclass for :: classes') 
    126110 
    127     $P2 = get_hll_global ['Foo'], 'Bar' 
     111    $P2 = get_hll_global ['Foo'], 'Bar4' 
    128112    $S0 = typeof $P2 
    129     say $S0 
     113    is($S0, 'Foo::Bar4', 'new_subclass for :: classes') 
    130114.end 
    131 END_CODE 
    132 Foo::Bar 
    133 Foo::Bar 
    134 END_OUT 
    135115 
    136 pir_output_is( <<'END_CODE', <<'END_OUT', 'new_subclass with attrs' ); 
    137 .sub main :main 
     116.sub test_new_subclass_with_attrs 
    138117    load_bytecode 'Protoobject.pbc' 
    139118 
    140119    .local pmc protomaker, hashclass, attrs 
     
    152131    $S0 = $P0 
    153132    setattribute object, $S0, $P0 
    154133    $P1 = getattribute object, $S0 
    155     say $P1 
     134    is($P1, $P0,'new_subclass with attrs') 
    156135    goto iter_loop 
    157136  iter_end: 
    158137.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 
    168140    load_bytecode 'Protoobject.pbc' 
    169141 
    170     $P0 = newclass 'Foo' 
     142    $P0 = newclass 'Foo1' 
    171143 
    172144    .local pmc protomaker 
    173145    protomaker = get_hll_global 'Protomaker' 
    174     protomaker.'new_proto'('Foo') 
     146    protomaker.'new_proto'('Foo1') 
    175147 
    176     $P0 = get_hll_global 'Foo' 
     148    $P0 = get_hll_global 'Foo1' 
    177149    $P1 = $P0.'new'() 
    178150    $S0 = typeof $P1 
    179     say $S0 
     151    is($S0, 'Foo1', 'method "new" on protoobject') 
    180152.end 
    181 END_CODE 
    182 Foo 
    183 END_OUT 
    184153 
    185154# Local Variables: 
    186155#   mode: cperl 
    187156#   cperl-indent-level: 4 
    188157#   fill-column: 100 
    189158# End: 
    190 # vim: expandtab shiftwidth=4: 
    191  
     159# vim: expandtab shiftwidth=4 filetype=pir: