forked from CopernicaMarketingSoftware/PHP-CPP
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test case for CopernicaMarketingSoftware#300
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <main/php.h> | ||
#include <ostream> | ||
#include "test0006.h" | ||
|
||
static void test0006_1(Php::Parameters& p) | ||
{ | ||
{ | ||
Php::Value a = 5; | ||
a.setReferenceFlag(true); | ||
Php::out << a.debugZval() << std::endl; | ||
|
||
Php::Value b = Php::Value::makeReference(Php::call("returnByReference", a)); | ||
|
||
Php::out << a << " " << b << std::endl; | ||
b = b + 1.0; | ||
Php::out << a << " " << b << std::endl; | ||
b = b + 1.0; | ||
Php::out << a << " " << b << std::endl; | ||
} | ||
|
||
Php::out << std::endl; | ||
|
||
{ | ||
Php::Value a = 5; | ||
a.setReferenceFlag(true); | ||
Php::out << a.debugZval() << std::endl; | ||
|
||
Php::Value func("returnByReference"); | ||
Php::Value b = Php::Value::makeReference(func.operator ()(a)); | ||
Php::out << a << " " << b << std::endl; | ||
b = b + 1.0; | ||
Php::out << a << " " << b << std::endl; | ||
b = b + 1.0; | ||
Php::out << a << " " << b << std::endl; | ||
} | ||
} | ||
|
||
void init_Test0006(Php::Extension& e) | ||
{ | ||
e.add<test0006_1>("test0006_1"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef TEST_TEST0006_H | ||
#define TEST_TEST0006_H | ||
|
||
#include "phpcpp.h" | ||
|
||
void init_Test0006(Php::Extension& e); | ||
|
||
#endif /* TEST_TEST0006_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
Test references | ||
--SKIPIF-- | ||
<?php include 'skipif.inc'; ?> | ||
--FILE-- | ||
<?php | ||
function& returnByReference(&$a) | ||
{ | ||
return $a; | ||
} | ||
|
||
$a = 5; | ||
$b = returnByReference($a); | ||
echo $b, PHP_EOL; | ||
++$b; | ||
echo $a, ' ', $b, PHP_EOL; | ||
|
||
unset($a, $b); | ||
echo PHP_EOL; | ||
|
||
$a = 5; | ||
$b = &returnByReference($a); | ||
echo $b, PHP_EOL; | ||
++$b; | ||
echo $a, ' ', $b, PHP_EOL; | ||
echo PHP_EOL; | ||
|
||
test0006_1(); | ||
?> | ||
--EXPECT-- | ||
5 | ||
5 6 | ||
|
||
5 | ||
6 6 | ||
|
||
[type=10 refcounted=1 isref=1 refcount=1] 5 | ||
5 5 | ||
6 6 | ||
7 7 | ||
|
||
[type=10 refcounted=1 isref=1 refcount=1] 5 | ||
5 5 | ||
6 6 | ||
7 7 | ||
|