diff --git a/test/Makefile b/test/Makefile index 8d7f0b1c..31a3a8f2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -15,6 +15,7 @@ CXX_SRC = \ test0003.cpp \ test0004.cpp \ test0005.cpp \ + test0006.cpp \ issue114.cpp \ issue229.cpp \ issue234.cpp \ diff --git a/test/main.cpp b/test/main.cpp index d5ae82c8..cb4dff35 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -4,6 +4,7 @@ #include "test0003.h" #include "test0004.h" #include "test0005.h" +#include "test0006.h" #include "issue114.h" #include "issue229.h" #include "issue234.h" @@ -27,6 +28,7 @@ extern "C" init_Test0003(extension); init_Test0004(extension); init_Test0005(extension); + init_Test0006(extension); init_Issue114(extension); init_Issue229(extension); diff --git a/test/test0006.cpp b/test/test0006.cpp new file mode 100644 index 00000000..1de11f7f --- /dev/null +++ b/test/test0006.cpp @@ -0,0 +1,41 @@ +#include
+#include +#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"); +} diff --git a/test/test0006.h b/test/test0006.h new file mode 100644 index 00000000..fdcae7f0 --- /dev/null +++ b/test/test0006.h @@ -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 */ diff --git a/test/tests/0006.phpt b/test/tests/0006.phpt new file mode 100644 index 00000000..043984a7 --- /dev/null +++ b/test/tests/0006.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test references +--SKIPIF-- + +--FILE-- + +--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 +