summaryrefslogtreecommitdiff
path: root/tests/strings
diff options
context:
space:
mode:
authorFerenc Kovacs <tyrael@php.net>2011-11-26 18:41:45 +0000
committerFerenc Kovacs <tyrael@php.net>2011-11-26 18:41:45 +0000
commit52ddf31284be8560b672b0c4976c839dd3fbd4f5 (patch)
treefcc7082156ea47c99a143f4dc96a9a18f9ae0873 /tests/strings
parent0143fc9371cabf42ce448f748b8e53ef07076caf (diff)
downloadphp-git-52ddf31284be8560b672b0c4976c839dd3fbd4f5.tar.gz
adding some tests for string offsets
Diffstat (limited to 'tests/strings')
-rw-r--r--tests/strings/offsets_chaining_1.phpt12
-rw-r--r--tests/strings/offsets_chaining_2.phpt12
-rw-r--r--tests/strings/offsets_chaining_3.phpt12
-rw-r--r--tests/strings/offsets_chaining_4.phpt12
-rw-r--r--tests/strings/offsets_chaining_5.phpt22
-rw-r--r--tests/strings/offsets_general.phpt34
6 files changed, 104 insertions, 0 deletions
diff --git a/tests/strings/offsets_chaining_1.phpt b/tests/strings/offsets_chaining_1.phpt
new file mode 100644
index 0000000000..eecdfb9637
--- /dev/null
+++ b/tests/strings/offsets_chaining_1.phpt
@@ -0,0 +1,12 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string[0][0][0][0]);
+?>
+--EXPECTF--
+string(1) "f"
+
diff --git a/tests/strings/offsets_chaining_2.phpt b/tests/strings/offsets_chaining_2.phpt
new file mode 100644
index 0000000000..07f67f0fd0
--- /dev/null
+++ b/tests/strings/offsets_chaining_2.phpt
@@ -0,0 +1,12 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string{0}{0}[0][0]);
+?>
+--EXPECTF--
+string(1) "f"
+
diff --git a/tests/strings/offsets_chaining_3.phpt b/tests/strings/offsets_chaining_3.phpt
new file mode 100644
index 0000000000..23b8e70179
--- /dev/null
+++ b/tests/strings/offsets_chaining_3.phpt
@@ -0,0 +1,12 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump(isset($string[0][0][0][0]));
+?>
+--EXPECTF--
+bool(true)
+
diff --git a/tests/strings/offsets_chaining_4.phpt b/tests/strings/offsets_chaining_4.phpt
new file mode 100644
index 0000000000..79b95c135b
--- /dev/null
+++ b/tests/strings/offsets_chaining_4.phpt
@@ -0,0 +1,12 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump(isset($string{0}{0}[0][0]));
+?>
+--EXPECTF--
+bool(true)
+
diff --git a/tests/strings/offsets_chaining_5.phpt b/tests/strings/offsets_chaining_5.phpt
new file mode 100644
index 0000000000..f0e27c2cfd
--- /dev/null
+++ b/tests/strings/offsets_chaining_5.phpt
@@ -0,0 +1,22 @@
+--TEST--
+testing the behavior of string offset chaining
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$array = array('expected_array' => "foobar");
+var_dump(isset($array['expected_array']));
+var_dump($array['expected_array']);
+var_dump(isset($array['expected_array']['foo']));
+var_dump($array['expected_array']['foo']);
+var_dump(isset($array['expected_array']['foo']['bar']));
+var_dump($array['expected_array']['foo']['bar']);
+?>
+--EXPECTF--
+bool(true)
+string(6) "foobar"
+bool(true)
+string(1) "f"
+bool(true)
+string(1) "f"
+
diff --git a/tests/strings/offsets_general.phpt b/tests/strings/offsets_general.phpt
new file mode 100644
index 0000000000..3ad779d2d1
--- /dev/null
+++ b/tests/strings/offsets_general.phpt
@@ -0,0 +1,34 @@
+--TEST--
+testing the behavior of string offsets
+--INI--
+error_reporting=E_ALL | E_DEPRECATED
+--FILE--
+<?php
+$string = "foobar";
+var_dump($string[0]);
+var_dump($string[1]);
+var_dump(isset($string[0]));
+var_dump(isset($string[0][0]));
+var_dump($string["foo"]);
+var_dump(isset($string["foo"]["bar"]));
+var_dump($string{0});
+var_dump($string{1});
+var_dump(isset($string{0}));
+var_dump(isset($string{0}{0}));
+var_dump($string{"foo"});
+var_dump(isset($string{"foo"}{"bar"}));
+?>
+--EXPECT--
+string(1) "f"
+string(1) "o"
+bool(true)
+bool(true)
+string(1) "f"
+bool(true)
+string(1) "f"
+string(1) "o"
+bool(true)
+bool(true)
+string(1) "f"
+bool(true)
+