[svn:PHP-Sandwich] rev 1029 - in PHP-Sandwich/trunk: . t

[email protected] 28 Apr 2005 20:25:01 -0000
Newsgroups perl.php.sandwich.dev
Message-ID <[email protected]>
Author: gschlossnagle
Date: Thu Apr 28 13:25:01 2005
New Revision: 1029

Modified:
   PHP-Sandwich/trunk/PHP.xs
   PHP-Sandwich/trunk/phpinterp.c
   PHP-Sandwich/trunk/t/13.t
Log:
fix test case 13


Modified: PHP-Sandwich/trunk/PHP.xs
==============================================================================
--- PHP-Sandwich/trunk/PHP.xs	(original)
+++ PHP-Sandwich/trunk/PHP.xs	Thu Apr 28 13:25:01 2005
@@ -326,6 +326,7 @@
       int param_count = 0;
       zval *retval;
       void *old_ctx;
+      char *croakstr = NULL;
 
       old_ctx = tsrm_set_interpreter_context(interp->ctx);
       
@@ -340,8 +341,8 @@
       }
       retval = sandwich_call_function(interp, &method, params, param_count);
       if(retval == NULL) {
-        fprintf(stderr, "an error occured calling %s\n", method_name);
-        RETVAL = &PL_sv_undef;
+        croakstr = "A PHP error occured";
+        goto cleanup;
       } else {
         switch(retval->type) {
           case IS_NULL:
@@ -407,9 +408,10 @@
             break;
         }
       }
+cleanup:
       zval_dtor(&method);
-
       tsrm_set_interpreter_context(old_ctx);
+      if(croakstr) croak(croakstr);
     }
   OUTPUT:
     RETVAL

Modified: PHP-Sandwich/trunk/phpinterp.c
==============================================================================
--- PHP-Sandwich/trunk/phpinterp.c	(original)
+++ PHP-Sandwich/trunk/phpinterp.c	Thu Apr 28 13:25:01 2005
@@ -212,7 +212,7 @@
     }
     return retval;
   } zend_catch {
-    Perl_croak("Failed to eval your PHP code\n");
+    return NULL;
   } zend_end_try() {
     return NULL;
   }

Modified: PHP-Sandwich/trunk/t/13.t
==============================================================================
--- PHP-Sandwich/trunk/t/13.t	(original)
+++ PHP-Sandwich/trunk/t/13.t	Thu Apr 28 13:25:01 2005
@@ -1,6 +1,6 @@
 #!/opt/ecelerity/3rdParty/bin/perl
 use strict;
-use Test::More tests => 5;
+use Test::More tests => 4;
 
 BEGIN {
     use_ok 'PHP' or die;
@@ -10,5 +10,7 @@
 diag "Testing basic function autoloadind";
 ok my $p = PHP::Interpreter->new, "Create new PHP interpreter";
 $p->eval('function callme() { foo(); }');
-is $p->callme(),  'hello george',
-  'We should get the proper return value of the "hello" function"';
+eval {
+  $p->callme();
+};
+like $@, qr/A PHP error occured/, "Fatal PHP errors can be caught";