diff --git a/tests/dummyext/CMakeLists.txt b/tests/dummyext/CMakeLists.txt index 0faab34..21f8498 100644 --- a/tests/dummyext/CMakeLists.txt +++ b/tests/dummyext/CMakeLists.txt @@ -11,7 +11,9 @@ set(DUMMYEXT_SRCS InterfaceTestcases.h InterfaceTestcases.cpp NamespaceTestcases.h - NamespaceTestcases.cpp) + NamespaceTestcases.cpp + ConstantTestcases.h + ConstantTestcases.cpp) add_library(dummyext MODULE ${DUMMYEXT_SRCS}) diff --git a/tests/dummyext/ConstantTestcases.cpp b/tests/dummyext/ConstantTestcases.cpp new file mode 100644 index 0000000..e50db3f --- /dev/null +++ b/tests/dummyext/ConstantTestcases.cpp @@ -0,0 +1,40 @@ +// @copyright 2017-2018 zzu_softboy +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Created by softboy on 2017/11/02. + +#include "ConstantTestcases.h" + +namespace dummyext +{ + +using zapi::lang::Constant; +using zapi::lang::Namespace; + +void register_constant_testcases(Extension &extension) +{ + extension.registerConstant(Constant("MY_CONST", 12333)); + extension.registerConstant(Constant("PI", 3.14)); + Constant nameConst("ZAPI_NAME", "zapi"); + extension.registerConstant(nameConst); + extension.registerConstant(Constant("ZAPI_VERSION", "v0.0.1")); + extension.registerConstant(Constant("QIHOO", "beijing qihoo")); + // register constant in namespace + Namespace *zapi = extension.findNamespace("zapi"); + Namespace *io = zapi->findNamespace("io"); + io->registerConstant(Constant("IO_TYPE", "ASYNC")); + io->registerConstant(Constant("NATIVE_STREAM", true)); + zapi->registerConstant(Constant("SYS_VERSION", "0.1.1-alpha")); +} + +} // dummyext diff --git a/tests/dummyext/ConstantTestcases.h b/tests/dummyext/ConstantTestcases.h new file mode 100644 index 0000000..3124f58 --- /dev/null +++ b/tests/dummyext/ConstantTestcases.h @@ -0,0 +1,30 @@ +// @copyright 2017-2018 zzu_softboy +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Created by softboy on 2017/11/02. + +#ifndef ZAPI_TEST_DUMMYEXT_CONSTANT_TESTCASES_H +#define ZAPI_TEST_DUMMYEXT_CONSTANT_TESTCASES_H + +#include "zapi/ZendApi.h" + +namespace dummyext +{ + +using zapi::lang::Extension; + +ZAPI_DECL_EXPORT void register_constant_testcases(Extension &extension); + +} // dummyext + +#endif // ZAPI_TEST_DUMMYEXT_CONSTANT_TESTCASES_H diff --git a/tests/dummyext/Entry.cpp b/tests/dummyext/Entry.cpp index 0561081..16241d8 100644 --- a/tests/dummyext/Entry.cpp +++ b/tests/dummyext/Entry.cpp @@ -20,6 +20,7 @@ #include "FunctionTestcases.h" #include "ClassTestcases.h" #include "InterfaceTestcases.h" +#include "ConstantTestcases.h" using zapi::lang::Extension; @@ -31,6 +32,7 @@ ZAPI_DECL_EXPORT void *get_module() dummyext::register_ini_testcases(extension); dummyext::register_cyclehandler_testcases(extension); dummyext::register_namespace_testcases(extension); + dummyext::register_constant_testcases(extension); dummyext::register_interface_testcases(extension); dummyext::register_function_testcases(extension); dummyext::register_class_testcases(extension); diff --git a/tests/dummyext/NamespaceTestcases.cpp b/tests/dummyext/NamespaceTestcases.cpp index 0e2e941..f98a14a 100644 --- a/tests/dummyext/NamespaceTestcases.cpp +++ b/tests/dummyext/NamespaceTestcases.cpp @@ -18,9 +18,14 @@ namespace dummyext { +using zapi::lang::Namespace; + void register_namespace_testcases(Extension &extension) { - + Namespace zapi("zapi"); + Namespace io("io"); + zapi.registerNamespace(io); + extension.registerNamespace(zapi); } } // dummyext diff --git a/tests/lang/const/ConstantExistTest.phpt b/tests/lang/const/ConstantExistTest.phpt index c2dccd3..78021a7 100644 --- a/tests/lang/const/ConstantExistTest.phpt +++ b/tests/lang/const/ConstantExistTest.phpt @@ -1,37 +1,31 @@ ---TEST-- -Contant register test ---FILE-- ---EXPECT-- -MY_CONST defined -PI defined -ZAPI_NAME defined -ZAPI_NAME defined -QIHOO defined +success: +exit(0); +error: +exit(1); diff --git a/tests/lang/const/ConstantNsTest.phpt b/tests/lang/const/ConstantNsTest.phpt index 877f000..e030a7c 100644 --- a/tests/lang/const/ConstantNsTest.phpt +++ b/tests/lang/const/ConstantNsTest.phpt @@ -1,25 +1,21 @@ ---TEST-- -Contant namespace exist test ---FILE-- ---EXPECT-- -\zapi\SYS_VERSION defined -\zapi\io\IO_TYPE defined -\zapi\io\NATIVE_STREAM defined +success: +exit(0); +error: +exit(1); diff --git a/tests/lang/const/ConstantTypeTest.phpt b/tests/lang/const/ConstantTypeTest.phpt index 52b0a4b..64f7bd1 100644 --- a/tests/lang/const/ConstantTypeTest.phpt +++ b/tests/lang/const/ConstantTypeTest.phpt @@ -1,71 +1,46 @@ ---TEST-- -Contant type test ---FILE-- ---EXPECT-- -MY_CONST is int -PI is double -ZAPI_NAME is string -ZAPI_VERSION is string -QIHOO is string -\zapi\SYS_VERSION is string -\zapi\io\IO_TYPE is string -\zapi\io\NATIVE_STREAM is bool +success: +exit(0); +error: +exit(1);