summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-05-11 03:15:13 +0000
committerFelipe Pena <felipe@php.net>2008-05-11 03:15:13 +0000
commit3d7013045b0be30f94f608356d65b07ec6e616c3 (patch)
tree5485cba97c401496caca29bbfd24035b70c33172
parentc28ebf6a9205f2c9da80d0f1ba025c9694e437d4 (diff)
downloadphp-git-3d7013045b0be30f94f608356d65b07ec6e616c3.tar.gz
- New tests
-rw-r--r--Zend/tests/031.phpt11
-rw-r--r--Zend/tests/032.phpt13
-rw-r--r--Zend/tests/033.phpt31
-rw-r--r--Zend/tests/anonymous_func_001.phpt35
-rw-r--r--Zend/tests/anonymous_func_002.phpt16
-rw-r--r--Zend/tests/anonymous_func_003.phpt15
-rw-r--r--Zend/tests/dynamic_call_001.phpt17
-rw-r--r--Zend/tests/dynamic_call_002.phpt12
-rw-r--r--Zend/tests/dynamic_call_003.phpt13
-rw-r--r--Zend/tests/dynamic_call_004.phpt12
-rw-r--r--Zend/tests/exception_001.phpt48
-rw-r--r--Zend/tests/exception_002.phpt19
-rw-r--r--Zend/tests/exception_003.phpt14
-rw-r--r--Zend/tests/heredoc_015.phpt41
-rw-r--r--Zend/tests/heredoc_016.phpt42
-rw-r--r--Zend/tests/heredoc_017.phpt17
-rw-r--r--Zend/tests/instanceof_001.phpt29
-rw-r--r--Zend/tests/instanceof_002.phpt33
-rw-r--r--Zend/tests/jump14.phpt28
-rw-r--r--Zend/tests/list_003.phpt24
-rw-r--r--Zend/tests/list_004.phpt21
-rw-r--r--Zend/tests/list_005.phpt52
-rw-r--r--Zend/tests/nowdoc_016.phpt41
-rw-r--r--Zend/tests/nowdoc_017.phpt16
-rw-r--r--Zend/tests/objects_022.phpt39
-rw-r--r--Zend/tests/objects_023.phpt15
-rw-r--r--Zend/tests/unicode_001.phpt80
-rw-r--r--Zend/tests/unicode_002.phpt14
28 files changed, 748 insertions, 0 deletions
diff --git a/Zend/tests/031.phpt b/Zend/tests/031.phpt
new file mode 100644
index 0000000000..8db52a5deb
--- /dev/null
+++ b/Zend/tests/031.phpt
@@ -0,0 +1,11 @@
+--TEST--
+Testing array with '[]' passed as argument by value
+--FILE--
+<?php
+
+function test($var) { }
+test($arr[]);
+
+?>
+--EXPECTF--
+Fatal error: Cannot use [] for reading in %s on line %d
diff --git a/Zend/tests/032.phpt b/Zend/tests/032.phpt
new file mode 100644
index 0000000000..8f7f994647
--- /dev/null
+++ b/Zend/tests/032.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Testing array with '[]' passed as argument by reference
+--FILE--
+<?php
+
+function test(&$var) { }
+test($arr[]);
+
+print "ok!\n";
+
+?>
+--EXPECT--
+ok!
diff --git a/Zend/tests/033.phpt b/Zend/tests/033.phpt
new file mode 100644
index 0000000000..c8651159a6
--- /dev/null
+++ b/Zend/tests/033.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Using undefined multidimensional array
+--FILE--
+<?php
+
+$arr[1][2][3][4][5];
+
+echo $arr[1][2][3][4][5];
+
+$arr[1][2][3][4][5]->foo;
+
+$arr[1][2][3][4][5]->foo = 1;
+
+$arr[][] = 2;
+
+$arr[][]->bar = 2;
+
+?>
+--EXPECTF--
+
+Notice: Undefined variable: arr in %s on line %d
+
+Notice: Undefined variable: arr in %s on line %d
+
+Notice: Undefined variable: arr in %s on line %d
+
+Notice: Trying to get property of non-object in %s on line %d
+
+Strict Standards: Creating default object from empty value in %s on line %d
+
+Strict Standards: Creating default object from empty value in %s on line %d
diff --git a/Zend/tests/anonymous_func_001.phpt b/Zend/tests/anonymous_func_001.phpt
new file mode 100644
index 0000000000..644a7f49ad
--- /dev/null
+++ b/Zend/tests/anonymous_func_001.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Testing calls to anonymous function
+--FILE--
+<?php
+
+for ($i = 0; $i < 10; $i++) {
+ $a = create_function('', 'return '. $i .';');
+ var_dump($a());
+
+ $b = "\0lambda_". ($i + 1);
+ var_dump($b());
+}
+
+?>
+--EXPECT--
+int(0)
+int(0)
+int(1)
+int(1)
+int(2)
+int(2)
+int(3)
+int(3)
+int(4)
+int(4)
+int(5)
+int(5)
+int(6)
+int(6)
+int(7)
+int(7)
+int(8)
+int(8)
+int(9)
+int(9)
diff --git a/Zend/tests/anonymous_func_002.phpt b/Zend/tests/anonymous_func_002.phpt
new file mode 100644
index 0000000000..4c40b62300
--- /dev/null
+++ b/Zend/tests/anonymous_func_002.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Testing anonymous function return as array key and accessing $GLOBALS
+--FILE--
+<?php
+
+$test = create_function('$v', 'return $v;');
+
+$arr = array(create_function('', 'return $GLOBALS["arr"];'), 2);
+
+var_dump($arr[$test(1)]);
+var_dump($arr[$test(0)]() == $arr);
+
+?>
+--EXPECT--
+int(2)
+bool(true)
diff --git a/Zend/tests/anonymous_func_003.phpt b/Zend/tests/anonymous_func_003.phpt
new file mode 100644
index 0000000000..32c5cf085c
--- /dev/null
+++ b/Zend/tests/anonymous_func_003.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Using throw $var with anonymous function return
+--FILE--
+<?php
+
+try {
+ $a = create_function('', 'return new Exception("test");');
+ throw $a();
+} catch (Exception $e) {
+ var_dump($e->getMessage() == 'test');
+}
+
+?>
+--EXPECT--
+bool(true)
diff --git a/Zend/tests/dynamic_call_001.phpt b/Zend/tests/dynamic_call_001.phpt
new file mode 100644
index 0000000000..94e4203caf
--- /dev/null
+++ b/Zend/tests/dynamic_call_001.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Testing dynamic call to constructor (old-style)
+--FILE--
+<?php
+
+class foo {
+ public function foo() {
+ }
+}
+
+$a = 'foo';
+
+$a::$a();
+
+?>
+--EXPECTF--
+Fatal error: Non-static method foo::foo() cannot be called statically in %s on line %d
diff --git a/Zend/tests/dynamic_call_002.phpt b/Zend/tests/dynamic_call_002.phpt
new file mode 100644
index 0000000000..dcb1529692
--- /dev/null
+++ b/Zend/tests/dynamic_call_002.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Testing dynamic call with invalid value for method name
+--FILE--
+<?php
+
+$a = new stdClass;
+
+$a::$a();
+
+?>
+--EXPECTF--
+Fatal error: Function name must be a string in %s on line %d
diff --git a/Zend/tests/dynamic_call_003.phpt b/Zend/tests/dynamic_call_003.phpt
new file mode 100644
index 0000000000..15b830ec68
--- /dev/null
+++ b/Zend/tests/dynamic_call_003.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Testing dynamic call with invalid method name
+--FILE--
+<?php
+
+$a = new stdClass;
+$b = 1;
+
+$a::$b();
+
+?>
+--EXPECTF--
+Fatal error: Function name must be a string in %s on line %d
diff --git a/Zend/tests/dynamic_call_004.phpt b/Zend/tests/dynamic_call_004.phpt
new file mode 100644
index 0000000000..6e833035a6
--- /dev/null
+++ b/Zend/tests/dynamic_call_004.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Testing dynamic call with undefined variables
+--FILE--
+<?php
+
+$a::$b();
+
+?>
+--EXPECTF--
+Notice: Undefined variable: a in %s on line %d
+
+Fatal error: Class name must be a valid object or a string in %s on line %d
diff --git a/Zend/tests/exception_001.phpt b/Zend/tests/exception_001.phpt
new file mode 100644
index 0000000000..d4e5534288
--- /dev/null
+++ b/Zend/tests/exception_001.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Testing nested exceptions
+--FILE--
+<?php
+
+try {
+ try {
+ try {
+ try {
+ throw new Exception(NULL);
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ throw $e;
+ }
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ throw $e;
+ }
+ } catch (Exception $e) {
+ var_dump($e->getMessage());
+ throw $e;
+ }
+} catch (Exception $e) {
+ var_dump($e->getMessage());
+ throw $e;
+}
+
+?>
+--EXPECTF--
+string(0) ""
+string(0) ""
+string(0) ""
+string(0) ""
+
+Fatal error: Uncaught exception 'Exception' in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
+--UEXPECTF--
+unicode(0) ""
+unicode(0) ""
+unicode(0) ""
+unicode(0) ""
+
+Fatal error: Uncaught exception 'Exception' in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/Zend/tests/exception_002.phpt b/Zend/tests/exception_002.phpt
new file mode 100644
index 0000000000..25f0c61f9d
--- /dev/null
+++ b/Zend/tests/exception_002.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Testing exception and GOTO
+--FILE--
+<?php
+
+goto foo;
+
+try {
+ print 1;
+
+ foo:
+ print 2;
+} catch (Exception $e) {
+
+}
+
+?>
+--EXPECT--
+2
diff --git a/Zend/tests/exception_003.phpt b/Zend/tests/exception_003.phpt
new file mode 100644
index 0000000000..e060aace05
--- /dev/null
+++ b/Zend/tests/exception_003.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Throwing exception in global scope
+--FILE--
+<?php
+
+throw new Exception(1);
+
+?>
+--EXPECTF--
+
+Fatal error: Uncaught exception 'Exception' with message '1' in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/Zend/tests/heredoc_015.phpt b/Zend/tests/heredoc_015.phpt
new file mode 100644
index 0000000000..21658cf8a5
--- /dev/null
+++ b/Zend/tests/heredoc_015.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Testing heredoc with escape sequences
+--FILE--
+<?php
+
+$test = <<<TEST
+TEST;
+
+var_dump(strlen($test) == 0);
+
+$test = <<<TEST
+\
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<TEST
+\0
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<TEST
+\n
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<TEST
+\\'
+TEST;
+
+var_dump(strlen($test) == 2);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/Zend/tests/heredoc_016.phpt b/Zend/tests/heredoc_016.phpt
new file mode 100644
index 0000000000..de00036ccd
--- /dev/null
+++ b/Zend/tests/heredoc_016.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Testing heredoc (double quotes) with escape sequences
+--FILE--
+<?php
+
+$test = <<<"TEST"
+TEST;
+
+var_dump(strlen($test) == 0);
+
+$test = <<<"TEST"
+\
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<"TEST"
+\0
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<"TEST"
+\n
+TEST;
+
+var_dump(strlen($test) == 1);
+
+$test = <<<"TEST"
+\\'
+TEST;
+
+var_dump(strlen($test) == 2);
+
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/Zend/tests/heredoc_017.phpt b/Zend/tests/heredoc_017.phpt
new file mode 100644
index 0000000000..e0ffddf05f
--- /dev/null
+++ b/Zend/tests/heredoc_017.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Testinh heredoc syntax
+--FILE--
+<?php
+
+$a = <<<A
+ A;
+;
+ A;
+\;
+A;
+
+var_dump(strlen($a) == 12);
+
+?>
+--EXPECT--
+bool(true)
diff --git a/Zend/tests/instanceof_001.phpt b/Zend/tests/instanceof_001.phpt
new file mode 100644
index 0000000000..b88e174c16
--- /dev/null
+++ b/Zend/tests/instanceof_001.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Testing instanceof operator with several operators
+--FILE--
+<?php
+
+$a = new stdClass;
+var_dump($a instanceof stdClass);
+
+var_dump(new stdCLass instanceof stdClass);
+
+$b = create_function('', 'return new stdClass;');
+var_dump($b() instanceof stdClass);
+
+$c = array(new stdClass);
+var_dump($c[0] instanceof stdClass);
+
+var_dump(@$inexistent instanceof stdClass);
+
+var_dump("$a" instanceof stdClass);
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+
+Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d
diff --git a/Zend/tests/instanceof_002.phpt b/Zend/tests/instanceof_002.phpt
new file mode 100644
index 0000000000..d3f4a35358
--- /dev/null
+++ b/Zend/tests/instanceof_002.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Testing instanceof operator with class and interface inheriteds
+--FILE--
+<?php
+
+interface ITest {
+}
+
+interface IFoo extends ITest {
+}
+
+class foo extends stdClass implements ITest {
+}
+
+var_dump(new foo instanceof stdClass);
+var_dump(new foo instanceof ITest);
+var_dump(new foo instanceof IFoo);
+
+class bar extends foo implements IFoo {
+}
+
+var_dump(new bar instanceof stdClass);
+var_dump(new bar instanceof ITest);
+var_dump(new bar instanceof IFoo);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+bool(true)
diff --git a/Zend/tests/jump14.phpt b/Zend/tests/jump14.phpt
new file mode 100644
index 0000000000..2cc6391ce9
--- /dev/null
+++ b/Zend/tests/jump14.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Testing GOTO inside blocks
+--FILE--
+<?php
+
+goto A;
+
+{
+ B:
+ goto C;
+ return;
+}
+
+A:
+ goto B;
+
+
+
+{
+ C:
+ {
+ print "Done!\n";
+ }
+}
+
+?>
+--EXPECT--
+Done!
diff --git a/Zend/tests/list_003.phpt b/Zend/tests/list_003.phpt
new file mode 100644
index 0000000000..4a509f6a82
--- /dev/null
+++ b/Zend/tests/list_003.phpt
@@ -0,0 +1,24 @@
+--TEST--
+list() with non-array
+--FILE--
+<?php
+
+list($a) = NULL;
+
+list($b) = 1;
+
+list($c) = 1.;
+
+list($d) = 'foo';
+
+list($e) = print '';
+
+var_dump($a, $b, $c, $d, $e);
+
+?>
+--EXPECT--
+NULL
+NULL
+NULL
+NULL
+NULL
diff --git a/Zend/tests/list_004.phpt b/Zend/tests/list_004.phpt
new file mode 100644
index 0000000000..862a4e4313
--- /dev/null
+++ b/Zend/tests/list_004.phpt
@@ -0,0 +1,21 @@
+--TEST--
+list() with array reference
+--FILE--
+<?php
+
+$arr = array(2, 1);
+$b =& $arr;
+
+list(,$a) = $b;
+
+var_dump($a, $b);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+ [0]=>
+ int(2)
+ [1]=>
+ int(1)
+}
diff --git a/Zend/tests/list_005.phpt b/Zend/tests/list_005.phpt
new file mode 100644
index 0000000000..fae814a727
--- /dev/null
+++ b/Zend/tests/list_005.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Testing list() with several variables
+--FILE--
+<?php
+
+$a = "foo";
+
+list($a, $b, $c) = $a;
+
+var_dump($a, $b, $c);
+
+print "----\n";
+
+$a = 1;
+
+list($a, $b, $c) = $a;
+
+var_dump($a, $b, $c);
+
+print "----\n";
+
+$a = new stdClass;
+
+list($a, $b, $c) = $a;
+
+var_dump($a, $b, $c);
+
+print "----\n";
+
+$a = array(1, 2, 3);
+
+list($a, $b, $c) = $a;
+
+var_dump($a, $b, $c);
+
+?>
+--EXPECT--
+NULL
+NULL
+NULL
+----
+NULL
+NULL
+NULL
+----
+NULL
+NULL
+NULL
+----
+int(1)
+int(2)
+int(3)
diff --git a/Zend/tests/nowdoc_016.phpt b/Zend/tests/nowdoc_016.phpt
new file mode 100644
index 0000000000..01eea4e751
--- /dev/null
+++ b/Zend/tests/nowdoc_016.phpt
@@ -0,0 +1,41 @@
+--TEST--
+Testing nowdocs with escape sequences
+--FILE--
+<?php
+
+$test = <<<'TEST'
+TEST;
+
+var_dump(strlen($test));
+
+$test = <<<'TEST'
+\
+TEST;
+
+var_dump(strlen($test));
+
+$test = <<<'TEST'
+\0
+TEST;
+
+var_dump(strlen($test));
+
+$test = <<<'TEST'
+\n
+TEST;
+
+var_dump(strlen($test));
+
+$test = <<<'TEST'
+\\'
+TEST;
+
+var_dump(strlen($test));
+
+?>
+--EXPECT--
+int(0)
+int(1)
+int(2)
+int(2)
+int(3)
diff --git a/Zend/tests/nowdoc_017.phpt b/Zend/tests/nowdoc_017.phpt
new file mode 100644
index 0000000000..5d29a86ba8
--- /dev/null
+++ b/Zend/tests/nowdoc_017.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Testing nowdoc in default value for property
+--FILE--
+<?php
+
+class foo {
+ public $bar = <<<'EOT'
+bar
+EOT;
+}
+
+print "ok!\n";
+
+?>
+--EXPECT--
+ok!
diff --git a/Zend/tests/objects_022.phpt b/Zend/tests/objects_022.phpt
new file mode 100644
index 0000000000..5a80e0a411
--- /dev/null
+++ b/Zend/tests/objects_022.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Testing 'self', 'parent' as type-hint
+--FILE--
+<?php
+
+interface iTest { }
+
+class baz implements iTest {}
+
+class bar { }
+
+class foo extends bar {
+ public function testFoo(self $obj) {
+ var_dump($obj);
+ }
+ public function testBar(parent $obj) {
+ var_dump($obj);
+ }
+ public function testBaz(iTest $obj) {
+ var_dump($obj);
+ }
+}
+
+$foo = new foo;
+$foo->testFoo(new foo);
+$foo->testBar(new bar);
+$foo->testBaz(new baz);
+$foo->testFoo(new stdClass); // Catchable fatal error
+
+?>
+--EXPECTF--
+object(foo)#%d (0) {
+}
+object(bar)#%d (0) {
+}
+object(baz)#%d (0) {
+}
+
+Catchable fatal error: Argument 1 passed to foo::testFoo() must be an instance of foo, instance of stdClass given, called in %s on line %d and defined in %s on line %d
diff --git a/Zend/tests/objects_023.phpt b/Zend/tests/objects_023.phpt
new file mode 100644
index 0000000000..042a20e9d8
--- /dev/null
+++ b/Zend/tests/objects_023.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Creating instances dynamically
+--FILE--
+<?php
+
+$arr = array(new stdClass, 'stdClass');
+
+new $arr[0]();
+new $arr[1]();
+
+print "ok\n";
+
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/unicode_001.phpt b/Zend/tests/unicode_001.phpt
new file mode 100644
index 0000000000..5a10854afe
--- /dev/null
+++ b/Zend/tests/unicode_001.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Comparing size of binary and unicode strings
+--FILE--
+<?php
+
+$test = b<<<FOO
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = b<<<'FOO'
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = b<<<"FOO"
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = b"傀傂两亨乄了乆刄";
+
+var_dump(strlen($test));
+
+$test = (binary) "傀傂两亨乄了乆刄";
+
+var_dump(strlen($test));
+
+$test = <<<FOO
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = <<<'FOO'
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = <<<"FOO"
+傀傂两亨乄了乆刄
+FOO;
+
+var_dump(strlen($test));
+
+$test = "傀傂两亨乄了乆刄";
+
+var_dump(strlen($test));
+
+$test = "傀傂两亨乄了乆刄";
+
+var_dump(strlen($test));
+
+?>
+--EXPECT--
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+--UEXPECT--
+int(24)
+int(24)
+int(24)
+int(24)
+int(24)
+int(8)
+int(8)
+int(8)
+int(8)
+int(8)
diff --git a/Zend/tests/unicode_002.phpt b/Zend/tests/unicode_002.phpt
new file mode 100644
index 0000000000..8c6ac1c9c0
--- /dev/null
+++ b/Zend/tests/unicode_002.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Testing normalization in array key
+--FILE--
+<?php
+
+$GLOBALS["\u212B"] = ' 승인 ';
+
+var_dump(isset($GLOBALS['Å']));
+
+?>
+--EXPECT--
+bool(false)
+--UEXPECT--
+bool(true)