| 1 | #!perl |
|---|
| 2 | |
|---|
| 3 | # Copyright (C) 2006-2009, Parrot Foundation. |
|---|
| 4 | # $Id: interp.t 36833 2009-02-17 20:09:26Z allison $ |
|---|
| 5 | |
|---|
| 6 | use strict; |
|---|
| 7 | use warnings; |
|---|
| 8 | |
|---|
| 9 | use Test::More tests => 6; |
|---|
| 10 | use File::Spec; |
|---|
| 11 | |
|---|
| 12 | my $hello_pbc = File::Spec->catfile( 't', 'greet.pbc' ); |
|---|
| 13 | |
|---|
| 14 | my $module = 'Parrot::Interpreter'; |
|---|
| 15 | use_ok('Parrot::Embed') or exit; |
|---|
| 16 | |
|---|
| 17 | can_ok( $module, 'new' ); |
|---|
| 18 | my $interp = $module->new(); |
|---|
| 19 | ok( $interp, 'new() should return a valid interpreter' ); |
|---|
| 20 | isa_ok( $interp, $module ); |
|---|
| 21 | |
|---|
| 22 | my $pir =<<"END_PIR"; |
|---|
| 23 | .sub mypct |
|---|
| 24 | load_bytecode '../../runtime/parrot/library/PCT.pbc' |
|---|
| 25 | .return(42) |
|---|
| 26 | .end |
|---|
| 27 | END_PIR |
|---|
| 28 | |
|---|
| 29 | my $eval = $interp->compile( $pir ); |
|---|
| 30 | my $mypct = $interp->find_global('mypct'); |
|---|
| 31 | my $res = $mypct->invoke( 'PS', '' ); |
|---|
| 32 | isa_ok $res, 'Parrot::PMC'; |
|---|
| 33 | is $res->get_string, 42, 'mypct returns value correctly'; |
|---|
| 34 | |
|---|
| 35 | |
|---|