#!perl

# Copyright (C) 2006-2008, The Perl Foundation.
# $Id: $

use strict;
use warnings;

use Test::More;
use File::Spec;

my $pynie_pbc = File::Spec->catfile( '..', '..', 'languages', 'pynie', 'pynie.pbc' );
plan skip_all => "Need to first run make in languages/pynie" if not -e $pynie_pbc;

plan tests => 9;

use_ok('Parrot::Embed') or exit;

my $module = 'Parrot::Interpreter';
my $interp = $module->new();
ok( $interp, 'new() should return a valid interpreter' );
isa_ok( $interp, $module );

my $result = eval { $interp->load_file($pynie_pbc) };
my $except = $@;
ok( $result, '... returning true if it could load the file' );
is( $except, '', '... throwing no exeption if so' );

my $pynie = $interp->find_global( 'main' );
isa_ok( $pynie, 'Parrot::PMC' );
can_ok($pynie, 'invoke');


# compile some Python code
{
	my $pmc = $pynie->invoke( 'PS', '2+3' );
	ok( $pmc, 'invoke() should return a PMC, given that signature' );
	is( $pmc->get_string(), 5, 'string returned in the PMC should be true?' );
}
