Ticket #488: load_pct.t

File load_pct.t, 0.8 KB (added by szabgab, 6 years ago)

ext/Parrot-Embed/t/load_pct.t

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