Author: bernhard
Date: Tue Dec 23 04:09:52 2008
New Revision: 34271
Added:
trunk/ext/Parrot-Embed/t/pipp.t (contents, props changed)
Modified:
trunk/MANIFEST
Log:
Trac#75: Add file ext/Parrot-Embed/t/pipp.t with most test cases commented out.
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Tue Dec 23 04:09:52 2008
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec 22 12:36:11 2008 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Dec 23 12:08:55 2008 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -871,6 +871,7 @@
ext/Parrot-Embed/t/00-load.t []
ext/Parrot-Embed/t/greet.pir []
ext/Parrot-Embed/t/interp.t []
+ext/Parrot-Embed/t/pipp.t []
ext/Parrot-Embed/tools/check_embed_coverage.pl []
ext/Parrot-Embed/tools/write_typemap.pl []
ext/Parrot-Embed/typemap []
Added: trunk/ext/Parrot-Embed/t/pipp.t
==============================================================================
--- (empty file)
+++ trunk/ext/Parrot-Embed/t/pipp.t Tue Dec 23 04:09:52 2008
@@ -0,0 +1,72 @@
+#!perl
+# Copyright (C) 2008, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+use Test::More;
+use File::Spec;
+
+my $pipp_pbc = File::Spec->catfile( '..', '..', 'languages', 'pipp',
'pipp.pbc' );
+plan skip_all => "Need to first run make in languages/pipp" if not -e
$pipp_pbc;
+
+plan tests => 6;
+
+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($pipp_pbc) };
+my $except = $@;
+ok( $result, '... returning true if it could load the file' );
+is( $except, '', '... throwing no exeption if so' );
+
+# What is 'Pipp' in hll namespace 'parrot' ?
+my $pipp_x = $interp->find_global( 'Pipp' );
+isa_ok( $pipp_x, 'Parrot::PMC' );
+
+# TODO: get hll id of Pipp
+# TODO: set hll namespace root to 'pipp'
+# find sub 'eval' and hll namespace 'pipp'
+my $pipp_eval = $interp->find_global( 'pipp', 'eval' );
+# isa_ok( $pipp_eval, 'Parrot::PMC', todo => '$pipp_eval is not found' );
+# can_ok($pipp, 'invoke');
+
+
+my $code = <<'END_CODE';
+<?php
+function add($a, $b) {
+ return $a+$b;
+}
+?>
+END_CODE
+
+# compile some PHP code
+if (0)
+{
+ my $pmc = $pipp_eval->invoke( 'PS', $code );
+ ok( $pmc, 'invoke() should return a PMC, given that signature' );
+ is( $pmc->get_string(), 1, 'string returned in the PMC should be true?' );
+}
+
+
+# invoke a built-in php function
+if (0)
+{
+ my $pmc = $pipp_eval->invoke( 'PS', 'strlen', 'some string' );
+ ok( $pmc, 'invoke() should return a PMC, given that signature' );
+ is( $pmc->get_string(), 11, 'value returned in the PMC' );
+}
+
+# invoke a php function
+if (0)
+{
+ my $pmc = $pipp_eval->invoke( 'PS', 'add', 23, 19 );
+ ok( $pmc, 'invoke() should return a PMC, given that signature' );
+ is( $pmc->get_string(), 42, 'value returned in the PMC' );
+}