11#![ cfg_attr( windows, feature( abi_vectorcall) ) ]
2+ #![ cfg( feature = "embed" ) ]
23extern crate ext_php_rs;
34
4- #[ cfg( feature = "embed" ) ]
5- use std:: ffi:: c_char;
6- #[ cfg( feature = "embed" ) ]
75use ext_php_rs:: builders:: SapiBuilder ;
8- #[ cfg( feature = "embed" ) ]
96use ext_php_rs:: embed:: { ext_php_rs_sapi_startup, Embed } ;
10- #[ cfg( feature = "embed" ) ]
117use ext_php_rs:: ffi:: {
128 php_module_shutdown, php_module_startup, php_request_shutdown, php_request_startup,
139 sapi_shutdown, sapi_startup, ZEND_RESULT_CODE_SUCCESS ,
1410} ;
1511use ext_php_rs:: prelude:: * ;
16- # [ cfg ( feature = "embed" ) ]
17- use ext_php_rs :: zend :: try_catch ;
12+ use ext_php_rs :: zend :: try_catch_first ;
13+ use std :: ffi :: c_char ;
1814
19- #[ cfg( feature = "embed" ) ]
2015static mut LAST_OUTPUT : String = String :: new ( ) ;
2116
22- #[ cfg( feature = "embed" ) ]
2317extern "C" fn output_tester ( str : * const c_char , str_length : usize ) -> usize {
2418 let char = unsafe { std:: slice:: from_raw_parts ( str as * const u8 , str_length) } ;
2519 let string = String :: from_utf8_lossy ( char) ;
@@ -34,7 +28,6 @@ extern "C" fn output_tester(str: *const c_char, str_length: usize) -> usize {
3428}
3529
3630#[ test]
37- #[ cfg( feature = "embed" ) ]
3831fn test_sapi ( ) {
3932 let mut builder = SapiBuilder :: new ( "test" , "Test" ) ;
4033 builder = builder. ub_write_function ( output_tester) ;
@@ -58,26 +51,23 @@ fn test_sapi() {
5851
5952 assert_eq ! ( result, ZEND_RESULT_CODE_SUCCESS ) ;
6053
61- let _ = try_catch (
62- || {
63- let result = Embed :: eval ( "$foo = hello_world('foo');" ) ;
54+ let _ = try_catch_first ( || {
55+ let result = Embed :: eval ( "$foo = hello_world('foo');" ) ;
6456
65- assert ! ( result. is_ok( ) ) ;
57+ assert ! ( result. is_ok( ) ) ;
6658
67- let zval = result. unwrap ( ) ;
59+ let zval = result. unwrap ( ) ;
6860
69- assert ! ( zval. is_string( ) ) ;
61+ assert ! ( zval. is_string( ) ) ;
7062
71- let string = zval. string ( ) . unwrap ( ) ;
63+ let string = zval. string ( ) . unwrap ( ) ;
7264
73- assert_eq ! ( string. to_string( ) , "Hello, foo!" ) ;
65+ assert_eq ! ( string. to_string( ) , "Hello, foo!" ) ;
7466
75- let result = Embed :: eval ( "var_dump($foo);" ) ;
67+ let result = Embed :: eval ( "var_dump($foo);" ) ;
7668
77- assert ! ( result. is_ok( ) ) ;
78- } ,
79- true ,
80- ) ;
69+ assert ! ( result. is_ok( ) ) ;
70+ } ) ;
8171
8272 unsafe {
8373 php_request_shutdown ( std:: ptr:: null_mut ( ) ) ;
0 commit comments