summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-04-05 22:00:55 +0600
committervalmat <ufabiz@gmail.com>2014-04-05 22:00:55 +0600
commit61374e5ddd285f9a125a52005ad7eaefd3585f02 (patch)
tree6e4388f8a2ee419d14fb21e25777844db5805bde /tests
parentffdccb83d460791202bdb258dbb9106da877da3b (diff)
add tests for HashMember
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp/h/variables.h8
-rw-r--r--tests/cpp/include/variables/019-HashMember-1.h33
-rw-r--r--tests/cpp/include/variables/020-HashMember-2.h41
-rw-r--r--tests/cpp/include/variables/021-HashMember-3.h41
-rw-r--r--tests/cpp/include/variables/022-HashMember-4.h65
-rw-r--r--tests/cpp/main.cpp7
-rw-r--r--tests/include/.gitignore1
-rw-r--r--tests/php/phpt/variables/019-HashMember-1.phpt27
-rw-r--r--tests/php/phpt/variables/020-HashMember-2.phpt76
-rw-r--r--tests/php/phpt/variables/021-HashMember-3.phpt27
-rw-r--r--tests/php/phpt/variables/022-HashMember-4.phpt37
11 files changed, 362 insertions, 1 deletions
diff --git a/tests/cpp/h/variables.h b/tests/cpp/h/variables.h
index 3ff77e9..bdf0fca 100644
--- a/tests/cpp/h/variables.h
+++ b/tests/cpp/h/variables.h
@@ -18,6 +18,14 @@
#include "../include/variables/009-010-value-object.h"
#include "../include/variables/011-012-value-casting-operators.h"
#include "../include/variables/013-018-calling-php-functions.h"
+#include "../include/variables/019-HashMember-1.h"
+#include "../include/variables/020-HashMember-2.h"
+#include "../include/variables/021-HashMember-3.h"
+#include "../include/variables/022-HashMember-4.h"
+//#include "../include/variables/.h"
+//#include "../include/variables/.h"
+//#include "../include/variables/.h"
+//#include "../include/variables/.h"
//#include "../include/variables/.h"
//#include "../include/variables/.h"
diff --git a/tests/cpp/include/variables/019-HashMember-1.h b/tests/cpp/include/variables/019-HashMember-1.h
new file mode 100644
index 0000000..28003f0
--- /dev/null
+++ b/tests/cpp/include/variables/019-HashMember-1.h
@@ -0,0 +1,33 @@
+/**
+ *
+ * Test variables
+ * 019-HashMember-1.phpt
+ * Test HashMember
+ *
+ */
+
+
+
+
+/**
+ * Set up namespace
+ */
+namespace TestVariables {
+
+ /**
+ * This function returns complex array
+ */
+ Php::Value test_HashMember_1()
+ {
+ Php::Value r, tmp(Php::Type::Array);
+ r["key1"] = tmp;
+ r["key1"]["key2"] = "val2";
+ r["key1"]["key3"] = "val3";
+ return r;
+ }
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/tests/cpp/include/variables/020-HashMember-2.h b/tests/cpp/include/variables/020-HashMember-2.h
new file mode 100644
index 0000000..dfa95c2
--- /dev/null
+++ b/tests/cpp/include/variables/020-HashMember-2.h
@@ -0,0 +1,41 @@
+/**
+ *
+ * Test variables
+ * 019-HashMember-2.phpt
+ * Test HashMember
+ *
+ */
+
+
+
+
+/**
+ * Set up namespace
+ */
+namespace TestVariables {
+
+ /**
+ * This function returns complex array
+ */
+ Php::Value test_HashMember_2()
+ {
+ Php::Value r, empty_array(Php::Type::Array);
+ r["k1"]["k3"] = "v1";
+ r["k1"]["k2"]["k4"] = "v2";
+ r["k5"][1] = "v3";
+ r[2]["k6"][1] = "v4";
+ r[3][4][1] = "v5";
+ r[3][4][2][5][7][11] = "v5";
+ r[3][4][2][5][7]["k"] = "v5";
+ r["c"][0] = "nested value";
+ r["c"][1] = nullptr;
+ r["c"][2] = empty_array;
+ r["c"][3] = "example";
+ return r;
+ }
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/tests/cpp/include/variables/021-HashMember-3.h b/tests/cpp/include/variables/021-HashMember-3.h
new file mode 100644
index 0000000..f7c0914
--- /dev/null
+++ b/tests/cpp/include/variables/021-HashMember-3.h
@@ -0,0 +1,41 @@
+/**
+ *
+ * Test variables
+ * 019-HashMember-3.phpt
+ * Test HashMember
+ *
+ */
+
+
+
+
+/**
+ * Set up namespace
+ */
+namespace TestVariables {
+
+ /**
+ * This function returns complex array
+ */
+ Php::Value test_HashMember_3()
+ {
+
+ Php::Value r, tmp(Php::Type::Array);
+ //Php::Value tmp;
+
+ tmp.set("key2", "val1-2");
+ r.set("key1", tmp);
+ r.get("key1").set("key3", "val1-3");
+
+ // expect to receive the same as when recording:
+ //r["key1"]["key2"] = "val1-2";
+ //r["key1"]["key3"] = "val1-3";
+
+ return r;
+ }
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/tests/cpp/include/variables/022-HashMember-4.h b/tests/cpp/include/variables/022-HashMember-4.h
new file mode 100644
index 0000000..e51eb3a
--- /dev/null
+++ b/tests/cpp/include/variables/022-HashMember-4.h
@@ -0,0 +1,65 @@
+/**
+ *
+ * Test variables
+ * 019-HashMember-4.phpt
+ * Test HashMember
+ *
+ */
+
+
+
+
+/**
+ * Set up namespace
+ */
+namespace TestVariables {
+
+ /**
+ * This function returns complex array
+ */
+ Php::Value test_HashMember_4()
+ {
+
+
+ Php::Value r1;
+ Php::Value tmp1,tmp2;
+ tmp2.set("key3", "val");
+ tmp1.set("key2", tmp2);
+ r1.set("key1", tmp1);
+ // this should be equivalent to:
+ // r1["key1"]["key2"]["key3"] = "val";
+
+ Php::Value r2;
+ r2.set("str1", "example");
+ r2.set("str2", r2.get("str1"));
+ // this should be equivalent to:
+ // r2["str1"] = "example";
+ // r2["str2"] = r2["str1"];
+ // i.e.
+ // r2["str1"] = "example";
+ // r2["str2"] = "example";
+
+ Php::Value r3;
+ Php::Value tmp;
+ tmp.set("str2", "val1-2");
+ tmp.set("str3", "val1-3");
+ r3.set("str1", tmp);
+ // this should be equivalent to:
+ // r3["str1"]["str2"] = "val1-2";
+ // r3["str1"]["str3"] = "val1-3";
+
+
+ Php::Value r;
+ r[0] = r1;
+ r[1] = r2;
+ r[2] = r3;
+
+
+ return r;
+ }
+
+/**
+ * End of namespace
+ */
+}
+
diff --git a/tests/cpp/main.cpp b/tests/cpp/main.cpp
index db2416d..6d1eab3 100644
--- a/tests/cpp/main.cpp
+++ b/tests/cpp/main.cpp
@@ -108,8 +108,13 @@ extern "C"
extension.add("TestVariables\\value_object1", TestVariables::value_object1);
extension.add("TestVariables\\value_object2", TestVariables::value_object2);
extension.add("TestVariables\\fnFromUserSpace", TestVariables::fnFromUserSpace);
- extension.add("TestVariables\\fnFromUserSpace2", TestVariables::fnFromUserSpace2);
+ extension.add("TestVariables\\fnFromUserSpace2", TestVariables::fnFromUserSpace2);
extension.add("TestVariables\\fnCallback", TestVariables::fnCallback);
+ extension.add("TestVariables\\test_HashMember_1", TestVariables::test_HashMember_1);
+ extension.add("TestVariables\\test_HashMember_2", TestVariables::test_HashMember_2);
+ extension.add("TestVariables\\test_HashMember_3", TestVariables::test_HashMember_3);
+ extension.add("TestVariables\\test_HashMember_4", TestVariables::test_HashMember_4);
+
diff --git a/tests/include/.gitignore b/tests/include/.gitignore
index 492755a..3a442ce 100644
--- a/tests/include/.gitignore
+++ b/tests/include/.gitignore
@@ -1,2 +1,3 @@
*.h
/lib/*
+/zts/*
diff --git a/tests/php/phpt/variables/019-HashMember-1.phpt b/tests/php/phpt/variables/019-HashMember-1.phpt
new file mode 100644
index 0000000..ebc126f
--- /dev/null
+++ b/tests/php/phpt/variables/019-HashMember-1.phpt
@@ -0,0 +1,27 @@
+--TEST--
+get_complex_array (test HashMember #1)
+--SKIPIF--
+<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
+--FILEEOF--
+<?php
+
+/*
+$r = array();
+$r["key1"] = array();
+$r["key1"]["key2"] = "val2";
+$r["key1"]["key3"] = "val3";
+var_export($r);echo "\n";
+*/
+
+var_export(TestVariables\test_HashMember_1());
+
+
+echo PHP_EOL;
+--EXPECT--
+array (
+ 'key1' =>
+ array (
+ 'key2' => 'val2',
+ 'key3' => 'val3',
+ ),
+) \ No newline at end of file
diff --git a/tests/php/phpt/variables/020-HashMember-2.phpt b/tests/php/phpt/variables/020-HashMember-2.phpt
new file mode 100644
index 0000000..bb48d06
--- /dev/null
+++ b/tests/php/phpt/variables/020-HashMember-2.phpt
@@ -0,0 +1,76 @@
+--TEST--
+get_complex_array (test HashMember #2)
+--SKIPIF--
+<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
+--FILEEOF--
+<?php
+
+/*
+$r = array();
+$r["k1"]["k3"] = "v1";
+$r["k1"]["k2"]["k4"] = "v2";
+$r["k5"][1] = "v3";
+$r[2]["k6"][1] = "v4";
+$r[3][4][1] = "v5";
+$r[3][4][2][5][7][11] = "v5";
+$r[3][4][2][5][7]["k"] = "v5";
+$r["c"][0] = "nested value";
+$r["c"][1] = NULL;
+$r["c"][2] = array();
+$r["c"][3] = "example";
+var_export($r);echo "\n";
+*/
+
+var_export(TestVariables\test_HashMember_2());
+
+
+echo PHP_EOL;
+--EXPECT--
+array (
+ 'k1' =>
+ array (
+ 'k3' => 'v1',
+ 'k2' =>
+ array (
+ 'k4' => 'v2',
+ ),
+ ),
+ 'k5' =>
+ array (
+ 1 => 'v3',
+ ),
+ 2 =>
+ array (
+ 'k6' =>
+ array (
+ 1 => 'v4',
+ ),
+ ),
+ 3 =>
+ array (
+ 4 =>
+ array (
+ 1 => 'v5',
+ 2 =>
+ array (
+ 5 =>
+ array (
+ 7 =>
+ array (
+ 11 => 'v5',
+ 'k' => 'v5',
+ ),
+ ),
+ ),
+ ),
+ ),
+ 'c' =>
+ array (
+ 0 => 'nested value',
+ 1 => NULL,
+ 2 =>
+ array (
+ ),
+ 3 => 'example',
+ ),
+) \ No newline at end of file
diff --git a/tests/php/phpt/variables/021-HashMember-3.phpt b/tests/php/phpt/variables/021-HashMember-3.phpt
new file mode 100644
index 0000000..c6c517f
--- /dev/null
+++ b/tests/php/phpt/variables/021-HashMember-3.phpt
@@ -0,0 +1,27 @@
+--TEST--
+get_complex_array (test HashMember #3)
+--SKIPIF--
+<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
+--FILEEOF--
+<?php
+
+/*
+$r = array();
+$r["key1"] = array();
+$r["key1"]["key2"] = "val1-2";
+$r["key1"]["key3"] = "val1-3";
+var_export($r);echo "\n";
+*/
+
+var_export(TestVariables\test_HashMember_3());
+
+
+echo PHP_EOL;
+--EXPECT--
+array (
+ 'key1' =>
+ array (
+ 'key2' => 'val1-2',
+ 'key3' => 'val1-3',
+ ),
+) \ No newline at end of file
diff --git a/tests/php/phpt/variables/022-HashMember-4.phpt b/tests/php/phpt/variables/022-HashMember-4.phpt
new file mode 100644
index 0000000..cbdc8b0
--- /dev/null
+++ b/tests/php/phpt/variables/022-HashMember-4.phpt
@@ -0,0 +1,37 @@
+--TEST--
+get_complex_array (test HashMember #4)
+--SKIPIF--
+<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
+--FILEEOF--
+<?php
+
+var_export(TestVariables\test_HashMember_4());
+
+
+echo PHP_EOL;
+--EXPECT--
+array (
+ 0 =>
+ array (
+ 'key1' =>
+ array (
+ 'key2' =>
+ array (
+ 'key3' => 'val',
+ ),
+ ),
+ ),
+ 1 =>
+ array (
+ 'str1' => 'example',
+ 'str2' => 'example',
+ ),
+ 2 =>
+ array (
+ 'str1' =>
+ array (
+ 'str2' => 'val1-2',
+ 'str3' => 'val1-3',
+ ),
+ ),
+) \ No newline at end of file