Ticket #75: interpreter.diff

File interpreter.diff, 1.5 KB (added by szabgab, 13 years ago)
  • ext/Parrot-Embed/t/interp.t

     
    66use strict; 
    77use warnings; 
    88 
    9 use Test::More tests => 26; 
     9use Test::More tests => 31; 
    1010use File::Spec; 
    1111 
    1212my $hello_pbc = File::Spec->catfile( 't', 'greet.pbc' ); 
     
    4646 
    4747can_ok( $global_greet, 'invoke' ); 
    4848my $pmc = $global_greet->invoke( 'PS', 'Bob' ); 
     49isa_ok( $pmc, 'Parrot::PMC' ); 
    4950ok( $pmc, 'invoke() should return a PMC, given that signature' ); 
    5051 
    5152is( $pmc->get_string(), 'Hello, Bob!', '... containing a string returned in the PMC' ); 
     
    9394    '... even if interpreter object has gone out of scope' 
    9495); 
    9596 
     97{ 
     98    my $add = $interp->compile( <<'END_CODE' ); 
     99.sub my_add 
     100    .param string a 
     101    .param string b 
     102 
     103    .return( a ) 
     104.end 
     105END_CODE 
     106 
     107    ok( $add, 'compile() should compile PIR code and return a PMC' ); 
     108    isa_ok( $add, 'Parrot::PMC' );   
     109    my $pmc_add; 
     110    eval { 
     111        $pmc_add = $add->invoke( 'PS', 23, 19 ); 
     112    }; 
     113    #Usage: Parrot::PMC::invoke(pmc, signature, argument) 
     114    TODO: { 
     115        local $TODO = 'invoke() can only get 2 parameters'; 
     116        isa_ok( $pmc_add, 'Parrot::PMC' ); 
     117    } 
     118    SKIP: { 
     119        skip "Previous TODO returns undef", 1; 
     120        is($pmc_add->get_string(), 42, 'two param call works well'); 
     121    } 
     122} 
     123 
     124 
    96125# Local Variables: 
    97126#   mode: cperl 
    98127#   cperl-indent-level: 4