diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:27 -0400 |
| commit | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (patch) | |
| tree | 41ccc042009cba53e4ce43e727fcba4c1cfbf7f3 /Zend/tests | |
| parent | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (diff) | |
| download | php-upstream/5.2.2.tar.gz | |
Imported Upstream version 5.2.2upstream/5.2.2
Diffstat (limited to 'Zend/tests')
127 files changed, 2946 insertions, 5 deletions
diff --git a/Zend/tests/017.phpt b/Zend/tests/017.phpt new file mode 100644 index 000000000..e8a5cfe85 --- /dev/null +++ b/Zend/tests/017.phpt @@ -0,0 +1,82 @@ +--TEST-- +builtin functions tests +--FILE-- +<?php + +var_dump(get_resource_type()); +var_dump(get_resource_type("")); +$fp = fopen(__FILE__, "r"); +var_dump(get_resource_type($fp)); +fclose($fp); +var_dump(get_resource_type($fp)); + +var_dump(get_loaded_extensions(true)); +var_dump(gettype(get_loaded_extensions())); +var_dump(count(get_loaded_extensions())); + +define("USER_CONSTANT", "test"); + +var_dump(get_defined_constants(true, true)); +var_dump(gettype(get_defined_constants(true))); +var_dump(gettype(get_defined_constants())); +var_dump(count(get_defined_constants())); + +function test () { +} + +var_dump(get_defined_functions(true)); +var_dump(gettype(get_defined_functions())); +var_dump(count(get_defined_functions())); + +var_dump(get_declared_interfaces(true)); +var_dump(gettype(get_declared_interfaces())); +var_dump(count(get_declared_interfaces())); + +var_dump(get_extension_funcs()); +var_dump(get_extension_funcs(true)); +var_dump(gettype(get_extension_funcs("standard"))); +var_dump(count(get_extension_funcs("standard"))); +var_dump(gettype(get_extension_funcs("zend"))); +var_dump(count(get_extension_funcs("zend"))); + + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for get_resource_type() in %s on line %d +NULL + +Warning: Supplied argument is not a valid resource handle in %s on line %d +bool(false) +string(6) "stream" +string(7) "Unknown" + +Warning: Wrong parameter count for get_loaded_extensions() in %s on line %d +NULL +string(5) "array" +int(%d) + +Warning: Wrong parameter count for get_defined_constants() in %s on line %d +NULL +string(5) "array" +string(5) "array" +int(%d) + +Warning: Wrong parameter count for get_defined_functions() in %s on line %d +NULL +string(5) "array" +int(%d) + +Warning: Wrong parameter count for get_declared_interfaces() in %s on line %d +NULL +string(5) "array" +int(%d) + +Warning: Wrong parameter count for get_extension_funcs() in %s on line %d +NULL +bool(false) +string(5) "array" +int(%d) +string(5) "array" +int(%d) +Done diff --git a/Zend/tests/018.phpt b/Zend/tests/018.phpt new file mode 100644 index 000000000..ea875c678 --- /dev/null +++ b/Zend/tests/018.phpt @@ -0,0 +1,36 @@ +--TEST-- +constant() tests +--FILE-- +<?php + +var_dump(constant()); +var_dump(constant("", "")); +var_dump(constant("")); + +var_dump(constant(array())); + +define("TEST_CONST", 1); +var_dump(constant("TEST_CONST")); + +define("TEST_CONST2", "test"); +var_dump(constant("TEST_CONST2")); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for constant() in %s on line %d +NULL + +Warning: Wrong parameter count for constant() in %s on line %d +NULL + +Warning: constant(): Couldn't find constant in %s on line %d +NULL + +Notice: Array to string conversion in %s on line %d + +Warning: constant(): Couldn't find constant Array in %s on line %d +NULL +int(1) +string(4) "test" +Done diff --git a/Zend/tests/add_001.phpt b/Zend/tests/add_001.phpt new file mode 100644 index 000000000..8d12aea11 --- /dev/null +++ b/Zend/tests/add_001.phpt @@ -0,0 +1,73 @@ +--TEST-- +adding arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array("str", "here"); + +$c = $a + $b; +var_dump($c); + +$a = array(1,2,3); +$b = array(1,2,4); + +$c = $a + $b; +var_dump($c); + +$a = array("a"=>"aaa",2,3); +$b = array(1,2,"a"=>"bbbbbb"); + +$c = $a + $b; +var_dump($c); + +$a += $b; +var_dump($c); + +$a += $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +array(3) { + ["a"]=> + string(3) "aaa" + [0]=> + int(2) + [1]=> + int(3) +} +Done diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt new file mode 100644 index 000000000..437ac9113 --- /dev/null +++ b/Zend/tests/add_002.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding objects to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $a + $o; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_003.phpt b/Zend/tests/add_003.phpt new file mode 100644 index 000000000..4223af3f1 --- /dev/null +++ b/Zend/tests/add_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +adding arrays to objects +--FILE-- +<?php + +$a = array(1,2,3); + +$o = new stdclass; +$o->prop = "value"; + +$c = $o + $a; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Notice: Object of class stdClass could not be converted to int in %s on line %d + +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_004.phpt b/Zend/tests/add_004.phpt new file mode 100644 index 000000000..492ff31ba --- /dev/null +++ b/Zend/tests/add_004.phpt @@ -0,0 +1,14 @@ +--TEST-- +adding numbers to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$c = $a + 5; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/add_005.phpt b/Zend/tests/add_005.phpt new file mode 100644 index 000000000..7e9bc25d8 --- /dev/null +++ b/Zend/tests/add_005.phpt @@ -0,0 +1,22 @@ +--TEST-- +adding integers to doubles +--INI-- +precision=14 +--FILE-- +<?php + +$i = 75636; +$d = 2834681123.123123; + +$c = $i + $d; +var_dump($c); + +$c = $d + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(2834756759.1231) +float(2834756759.1231) +Done diff --git a/Zend/tests/add_006.phpt b/Zend/tests/add_006.phpt new file mode 100644 index 000000000..c3f127e9c --- /dev/null +++ b/Zend/tests/add_006.phpt @@ -0,0 +1,47 @@ +--TEST-- +adding numbers to strings +--FILE-- +<?php + +$i = 75636; +$s1 = "this is a string"; +$s2 = "876222numeric"; +$s3 = "48474874"; +$s4 = "25.68"; + +$c = $i + $s1; +var_dump($c); + +$c = $i + $s2; +var_dump($c); + +$c = $i + $s3; +var_dump($c); + +$c = $i + $s4; +var_dump($c); + +$c = $s1 + $i; +var_dump($c); + +$c = $s2 + $i; +var_dump($c); + +$c = $s3 + $i; +var_dump($c); + +$c = $s4 + $i; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(75636) +int(951858) +int(48550510) +float(75661.68) +int(75636) +int(951858) +int(48550510) +float(75661.68) +Done diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt new file mode 100644 index 000000000..b2f1559b7 --- /dev/null +++ b/Zend/tests/add_007.phpt @@ -0,0 +1,16 @@ +--TEST-- +adding strings to arrays +--FILE-- +<?php + +$a = array(1,2,3); + +$s1 = "some string"; + +$c = $a + $s1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/and_001.phpt b/Zend/tests/and_001.phpt new file mode 100644 index 000000000..109b2ce99 --- /dev/null +++ b/Zend/tests/and_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +bitwise AND and strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test long"; +$s1 = "some"; + +var_dump($s & $s1); + +$s = "test"; +$s1 = "some long"; + +var_dump($s & $s1); + +$s = "test"; +$s &= "some long"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(3) "020" +string(4) "pead" +string(4) "pead" +string(4) "pead" +string(4) "pead" +Done diff --git a/Zend/tests/bug33282.phpt b/Zend/tests/bug33282.phpt new file mode 100644 index 000000000..65e3c16cf --- /dev/null +++ b/Zend/tests/bug33282.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #33282 (Re-assignment by reference does not clear the is_ref flag) +--FILE-- +<?php + $a = array(1, 2, 3); + $r = &$a[0]; + $r = &$a[1]; + $r = &$a[2]; + var_dump($a); +?> +--EXPECT-- +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + &int(3) +} diff --git a/Zend/tests/bug34617.phpt b/Zend/tests/bug34617.phpt index 60a07ea6d..826ff1000 100755 --- a/Zend/tests/bug34617.phpt +++ b/Zend/tests/bug34617.phpt @@ -1,7 +1,7 @@ --TEST--
Bug #34617 (zend_deactivate: objects_store used after zend_objects_store_destroy is called)
--SKIPIF--
-<?php if (!extension_loaded("xml")) print "skip"; ?>
+<?php if (!extension_loaded("xml")) print "skip the xml extension not available"; ?>
--FILE--
<?php
class Thing {}
@@ -15,4 +15,4 @@ function boom() boom();
?>
--EXPECT--
-ok
\ No newline at end of file +ok
diff --git a/Zend/tests/bug35106.phpt b/Zend/tests/bug35106.phpt new file mode 100755 index 000000000..a3f166cd5 --- /dev/null +++ b/Zend/tests/bug35106.phpt @@ -0,0 +1,14 @@ +--TEST--
+Bug #35106 (nested foreach fails when array variable has a reference)
+--FILE--
+<?php
+$a=array("1","2");
+$b=&$a;
+foreach($a as $i){
+ echo $i;
+ foreach($a as $p);
+}
+echo "\n";
+?>
+--EXPECT--
+12
diff --git a/Zend/tests/bug35634.phpt b/Zend/tests/bug35634.phpt new file mode 100755 index 000000000..9681b6ad4 --- /dev/null +++ b/Zend/tests/bug35634.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #35634 (Erroneous "Class declarations may not be nested" error raised) +--INI-- +error_reporting=0 +--FILE-- +<?php +if (defined("pass3")) { + + class ErrorClass { + } + +} else if (defined("pass2")) { + + class TestClass { + function __construct() { + } + function TestClass() { + $this->__construct(); + } + } + +} else { + + function errorHandler($errorNumber, $errorMessage, $fileName, $lineNumber) { + define("pass3", 1); + include(__FILE__); + die("Error: $errorMessage ($fileName:$lineNumber)\n"); + } + + set_error_handler('errorHandler'); + define("pass2", 1); + include(__FILE__); +} +?> +--EXPECTF-- +Error: Redefining already defined constructor for class TestClass (%sbug35634.php:12) diff --git a/Zend/tests/bug36214.phpt b/Zend/tests/bug36214.phpt new file mode 100755 index 000000000..dae25452c --- /dev/null +++ b/Zend/tests/bug36214.phpt @@ -0,0 +1,54 @@ +--TEST--
+Bug #36214 (__get method works properly only when conditional operator is used)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) die("skip SPL is no available"); ?>
+--FILE--
+<?php
+class context {
+ public $stack = array();
+
+ public function __set($name,$var) {
+ $this->stack[$name] = $var;return;
+ }
+
+ public function &__get($name) {
+ return $this->stack[$name];
+ }
+}
+
+$ctx = new context;
+$ctx->comment_preview = array();
+$ctx->comment_preview[0] = 1;
+$ctx->comment_preview[1] = 2;
+var_dump($ctx->comment_preview);
+
+$comment_preview = array();
+$comment_preview[0] = 1;
+$comment_preview[1] = 2;
+$ctx->comment_preview = $comment_preview;
+var_dump($ctx->comment_preview);
+
+$ctx->comment_preview = new ArrayObject();
+$ctx->comment_preview[0] = 1;
+$ctx->comment_preview[1] = 2;
+var_dump($ctx->comment_preview);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+object(ArrayObject)#2 (2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
diff --git a/Zend/tests/bug37212.phpt b/Zend/tests/bug37212.phpt index 5320a6173..81cc34fdb 100755 --- a/Zend/tests/bug37212.phpt +++ b/Zend/tests/bug37212.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #3721 (Access to protected property of common base class) +Bug #37212 (Access to protected property of common base class) --FILE-- <?php diff --git a/Zend/tests/bug39297.phpt b/Zend/tests/bug39297.phpt new file mode 100755 index 000000000..01e3f9172 --- /dev/null +++ b/Zend/tests/bug39297.phpt @@ -0,0 +1,45 @@ +--TEST--
+Bug #39297 (Memory corryption because of indirect modification of overloaded array)
+--FILE--
+<?php
+function compareByRef(&$first, &$second) {
+ return $first === $second;
+}
+
+class MyTree implements ArrayAccess {
+ public $parent;
+ public $children = array();
+
+ public function offsetExists($offset) {
+ }
+
+ public function offsetUnset($offset) {
+ }
+
+ public function offsetSet($offset, $value) {
+ echo "offsetSet()\n";
+ $cannonicalName = strtolower($offset);
+ $this->children[$cannonicalName] = $value;
+ $value->parent = $this;
+ }
+
+ public function offsetGet($offset) {
+ echo "offsetGet()\n";
+ $cannonicalName = strtolower($offset);
+ return $this->children[$cannonicalName];
+ }
+
+}
+
+$id = 'Test';
+
+$root = new MyTree();
+$child = new MyTree();
+$root[$id] = $child;
+
+var_dump(compareByRef($root[$id], $child));
+?>
+--EXPECT--
+offsetSet()
+offsetGet()
+bool(true)
diff --git a/Zend/tests/bug39438.phpt b/Zend/tests/bug39438.phpt new file mode 100755 index 000000000..2dac58ac6 --- /dev/null +++ b/Zend/tests/bug39438.phpt @@ -0,0 +1,45 @@ +--TEST--
+Bug #39438 (Fatal error: Out of memory)
+--INI--
+memory_limit=16M
+--FILE--
+<?php
+$i=0;
+$test2=array(
+ 'a1_teasermenu' => array(
+ 'downloadcounter' => 2777,
+ 'versions' => array(
+ '0.1.0' => array (
+ 'title' => 'A1 Teasermenu',
+ 'description' => 'Displays a teaser for advanced subpages or a selection of advanced pages',
+ 'state' => 'stable',
+ 'reviewstate' => 0,
+ 'category' => 'plugin',
+ 'downloadcounter' => 2787,
+ 'lastuploaddate' => 1088427240,
+ 'dependencies' => array (
+ 'depends' => array(
+ 'typo3' =>'',
+ 'php' =>'',
+ 'cms' => ''
+ ),
+ 'conflicts' => array('' =>'')
+ ),
+ 'authorname' => 'Mirko Balluff',
+ 'authoremail' => 'balluff@amt1.de',
+ 'ownerusername' => 'amt1',
+ 't3xfilemd5' => '3a4ec198b6ea8d0bc2d69d9b7400398f',
+ )
+ )
+ )
+);
+$test=array();
+while($i<1200) {
+ $test[]=$test2;
+ $i++;
+}
+$out=serialize($test);
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug39445.phpt b/Zend/tests/bug39445.phpt new file mode 100755 index 000000000..87f5f03ff --- /dev/null +++ b/Zend/tests/bug39445.phpt @@ -0,0 +1,16 @@ +--TEST--
+Bug #39445 (Calling debug_backtrace() in the __toString() function produces a crash)
+--FILE--
+<?php
+class test {
+ public function __toString() {
+ debug_backtrace();
+ return 'lowercase';
+ }
+}
+
+ $test = new test();
+ echo strtoupper($test);
+?>
+--EXPECT--
+LOWERCASE
diff --git a/Zend/tests/bug39449.phpt b/Zend/tests/bug39449.phpt new file mode 100755 index 000000000..725c0d47b --- /dev/null +++ b/Zend/tests/bug39449.phpt @@ -0,0 +1,40 @@ +--TEST--
+Bug #39449 (Overloaded array properties do not work correctly)
+--FILE--
+<?php
+class A {
+ private $keys = array();
+ public function & __get($val) {
+ return $this->keys[$val];
+ }
+ public function __set($k, $v) {
+ $this->keys[$k] = $v;
+ }
+}
+
+$a =new A();
+$a->arr = array('a','b','c');
+
+$b = &$a->arr;
+$b[]= 'd';
+
+foreach ($a->arr as $k => $v) {
+ echo "$k => $v\n";
+}
+
+$a->arr[]='d';
+
+foreach ($a->arr as $k => $v) {
+ echo "$k => $v\n";
+}
+?>
+--EXPECT--
+0 => a
+1 => b
+2 => c
+3 => d
+0 => a
+1 => b
+2 => c
+3 => d
+4 => d
diff --git a/Zend/tests/bug39602.phpt b/Zend/tests/bug39602.phpt new file mode 100755 index 000000000..daa10e4fd --- /dev/null +++ b/Zend/tests/bug39602.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #39602 (Invalid session.save_handler crashes PHP) +--SKIPIF-- +<?php if (!extension_loaded("session")) die("skip"); ?> +--INI-- +session.save_handler=qwerty +error_reporting=0 +--FILE-- +<?php +ini_set("session.save_handler","files"); +$x = new stdClass(); +echo "ok"; +?> +--EXPECT-- +ok diff --git a/Zend/tests/bug39721.phpt b/Zend/tests/bug39721.phpt new file mode 100755 index 000000000..63edfc23e --- /dev/null +++ b/Zend/tests/bug39721.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #39721 (Runtime inheritance causes data corruption) +--FILE-- +<?php +class test2 { + private static $instances = 0; + public $instance; + + public function __construct() { + $this->instance = ++self::$instances; + } + +} + +$foo = new test2(); + +if (is_object($foo)) { + class test2_child extends test2 { + + } +} + +$child = new test2_child(); + +echo $foo->instance . "\n"; +echo $child->instance . "\n"; +?> +--EXPECT-- +1 +2 diff --git a/Zend/tests/bug39775.phpt b/Zend/tests/bug39775.phpt new file mode 100755 index 000000000..b06797df8 --- /dev/null +++ b/Zend/tests/bug39775.phpt @@ -0,0 +1,20 @@ +--TEST--
+Bug #39775 ("Indirect modification ..." message is not shown)
+--FILE--
+<?php
+class test {
+ var $array = array();
+ function __get($var) {
+ $v =& $this->array;
+ return $this->array;
+ }
+}
+$t = new test;
+$t->anything[] = 'bar';
+print_r($t->anything);
+?>
+--EXPECTF--
+Notice: Indirect modification of overloaded property test::$anything has no effect in %sbug39775.php on line 10
+Array
+(
+)
diff --git a/Zend/tests/bug39825.phpt b/Zend/tests/bug39825.phpt new file mode 100755 index 000000000..294b32d87 --- /dev/null +++ b/Zend/tests/bug39825.phpt @@ -0,0 +1,13 @@ +--TEST--
+Bug #39825 (foreach produces memory error)
+--FILE--
+<?php
+$array = array(1 => 2, "foo" => "bar");
+$obj = (object)$array;
+foreach ($obj as $name => $value) {
+ echo "$name -> $value\n";
+}
+?>
+--EXPECT--
+1 -> 2
+foo -> bar
diff --git a/Zend/tests/bug39944.phpt b/Zend/tests/bug39944.phpt new file mode 100755 index 000000000..4249988ff --- /dev/null +++ b/Zend/tests/bug39944.phpt @@ -0,0 +1,88 @@ +--TEST-- +Bug #39944 (References broken) +--FILE-- +<?php +$intTheValue = 0; + +function &getValue() { + global $intTheValue; + return $intTheValue; +} + +function setValue(&$int, $iNewValue) { + $int = $iNewValue; +} + +setValue(getValue(), 10); +echo "intTheValue = {$intTheValue}\n"; + +$b = &$intTheValue; + +setValue(getValue(), 10); +echo "intTheValue = {$intTheValue}\n"; + +/****/ + +$arrTheArray = array(); + +function &getArray() { + global $arrTheArray; + return $arrTheArray; +} + +function addToArray(&$arr, $strToAdd) { + $arr[] = $strToAdd; +} + +addToArray(getArray(), "xx1"); +$a = getArray(); +addToArray($a, "xx2"); +$b = &$arrTheArray; +addToArray($b, "xx3"); +addToArray(getArray(), "xx4"); +$a = getArray(); +addToArray($a, "xx5"); +echo "arrTheArray = " . print_r($arrTheArray, 1); + +/****/ + +class RefTest { + protected $arr; + + function Add($strToAdd) { + $this->addToArray($this->getArray(), $strToAdd); + } + + function &getArray() { + if (!$this->arr) + $this->arr = array(); + return $this->arr; + } + + private function addToArray(&$arr, $strToAdd) { + $arr[] = $strToAdd; + } +} + +$objRefTest = new RefTest(); +$objRefTest->Add("xx1"); +$objRefTest->Add("xx2"); +$objRefTest->Add("xx3"); + +echo "objRefTest->getArray() = " . print_r($objRefTest->getArray(), 1); +?> +--EXPECT-- +intTheValue = 10 +intTheValue = 10 +arrTheArray = Array +( + [0] => xx1 + [1] => xx3 + [2] => xx4 +) +objRefTest->getArray() = Array +( + [0] => xx1 + [1] => xx2 + [2] => xx3 +) diff --git a/Zend/tests/bug39990.phpt b/Zend/tests/bug39990.phpt new file mode 100755 index 000000000..b2df0b540 --- /dev/null +++ b/Zend/tests/bug39990.phpt @@ -0,0 +1,17 @@ +--TEST--
+Bug #39990 (Cannot "foreach" over overloaded properties)
+--FILE--
+<?php
+ class Foo {
+ public function __get($name) {
+ return array('Hello', 'World');
+ }
+ }
+
+ $obj=new Foo();
+ foreach($obj->arr as $value)
+ echo "$value\n";
+?>
+--EXPECT--
+Hello
+World
diff --git a/Zend/tests/bug40236.inc b/Zend/tests/bug40236.inc new file mode 100755 index 000000000..0fbbfc9ff --- /dev/null +++ b/Zend/tests/bug40236.inc @@ -0,0 +1,10 @@ +<?php
+function func1() { }
+function func2() { }
+function func3() { }
+function func4() { }
+function func5() { }
+function func6() { }
+function func7() { }
+print ("ok\n");
+?>
\ No newline at end of file diff --git a/Zend/tests/bug40236.phpt b/Zend/tests/bug40236.phpt new file mode 100755 index 000000000..9d8f48639 --- /dev/null +++ b/Zend/tests/bug40236.phpt @@ -0,0 +1,14 @@ +--TEST--
+Bug #40236 (php -a function allocation eats memory)
+--SKIPIF--
+if (php_sapi_name() != "cli") die("skip CLI only");
+--FILE--
+<?php
+$php = getenv('TEST_PHP_EXECUTABLE');
+$cmd = "$php -d memory_limit=4M -a ".dirname(__FILE__)."/bug40236.inc";
+echo `$cmd`;
+?>
+--EXPECTF--
+Interactive %s
+
+ok
diff --git a/Zend/tests/bug40261.phpt b/Zend/tests/bug40261.phpt new file mode 100755 index 000000000..93a555708 --- /dev/null +++ b/Zend/tests/bug40261.phpt @@ -0,0 +1,25 @@ +--TEST--
+Bug #40261 (Extremely slow data handling due to memory fragmentation)
+--INI--
+memory_limit=128M
+--FILE--
+<?php
+$num = 100000;
+
+$a = Array();
+for ($i=0; $i<$num; $i++) {
+ $a[$i] = Array(1);
+}
+
+for ($i=0; $i<$num; $i++) {
+ $b[$i] = $a[$i][0];
+}
+
+unset($a);
+for ($i=0; $i<$num; $i++) {
+ $b[$i] = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+}
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug40621.phpt b/Zend/tests/bug40621.phpt new file mode 100644 index 000000000..564ba55be --- /dev/null +++ b/Zend/tests/bug40621.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #40621 (Crash when constructor called inappropriately (statically)) +--FILE-- +<?php + +class Foo { + private function __construct() { } + function get() { + self::__construct(); + } +} + +Foo::get(); + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Non-static method Foo::get() should not be called statically in %s on line %d + +Fatal error: Non-static method Foo::__construct() cannot be called statically in %s on line %d diff --git a/Zend/tests/bug40770.phpt b/Zend/tests/bug40770.phpt new file mode 100755 index 000000000..a73338501 --- /dev/null +++ b/Zend/tests/bug40770.phpt @@ -0,0 +1,22 @@ +--TEST--
+Bug #40770 Apache child exits when PHP memory limit reached
+--INI--
+memory_limit=8M
+--SKIPIF--
+<?php
+$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
+if ($zend_mm_enabled === "0") {
+ die("skip Zend MM disabled");
+}
+?>
+--FILE--
+<?php
+ini_set('display_errors',true);
+$mb=148;
+$var = '';
+for ($i=0; $i<=$mb; $i++) {
+ $var.= str_repeat('a',1*1024*1024);
+}
+?>
+--EXPECTF--
+Fatal error: Allowed memory size of 8388608 bytes exhausted%s(tried to allocate %d bytes) in %s on line %d
diff --git a/Zend/tests/bug40784.phpt b/Zend/tests/bug40784.phpt new file mode 100644 index 000000000..6da8f2a16 --- /dev/null +++ b/Zend/tests/bug40784.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #40784 (Case sensivity in constructor's fallback) +--FILE-- +<?php + +class A { + function A () { echo "I'm A\n"; } +} + +class B extends A { + function __construct() { + parent::__construct(); + parent::__constrUct(); + } +} + +$b = new B; + +echo "Done\n"; +?> +--EXPECTF-- +I'm A +I'm A +Done diff --git a/Zend/tests/bug40809.phpt b/Zend/tests/bug40809.phpt new file mode 100755 index 000000000..be27dbd67 --- /dev/null +++ b/Zend/tests/bug40809.phpt @@ -0,0 +1,33 @@ +--TEST--
+Bug #40809 Poor perfomance of ".="
+--FILE--
+<?php
+error_reporting(E_ALL|E_STRICT);
+
+$num_increments = 100;
+$num_repeats = 1000;
+$increment = 50;
+
+/* Create some more holes to give the memory allocator something to
+ * work with. */
+$num = 5000;
+$a = Array();
+for ($i=0; $i<$num; $i++) {
+ $a[$i] = Array(1);
+}
+for ($i=0; $i<$num; $i++) {
+ $b[$i] = $a[$i][0];
+}
+unset($a);
+
+for ($i=0;$i<$num_repeats;$i++) {
+ $evil = "";
+ for ($j=0;$j<$num_increments;$j++) {
+ $evil .= str_repeat("a", $increment);
+ }
+ unset($evil);
+}
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug40815.phpt b/Zend/tests/bug40815.phpt new file mode 100644 index 000000000..6f7477a9e --- /dev/null +++ b/Zend/tests/bug40815.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #40815 (using strings like "class::func" and static methods in set_exception_handler() might result in crash). +--FILE-- +<?php + +class ehandle{ + static public function exh ($ex) { + echo 'foo'; + } +} + +set_exception_handler("ehandle::exh"); + +throw new Exception ("Whiii"); +echo "Done\n"; +?> +--EXPECTF-- +foo diff --git a/Zend/tests/bug40833.phpt b/Zend/tests/bug40833.phpt new file mode 100755 index 000000000..c56ca4c3b --- /dev/null +++ b/Zend/tests/bug40833.phpt @@ -0,0 +1,72 @@ +--TEST-- +Bug #40833 (Crash when using unset() on an ArrayAccess object retrieved via __get) +--FILE-- +<?php + class entity + { + private $data; + private $modified; + + function __get($name) + { + if ( isset($this->data[$name]) ) + return $this->data[$name]; + else + return $this->data[$name] = new set($this); + } + + function __set($name, $value) + { + $this->modified[$name] = $value; + } + } + + class set implements ArrayAccess + { + private $entity; + + function __construct($entity) + { + $this->entity = $entity; + $this->entity->whatever = $this; + } + + function clear() { + $this->entity->whatever = null; + } + + function offsetUnset($offset) + { + $this->clear(); +// $this->entity->{$this->name} = null; + } + + function offsetSet($offset, $value) + { + } + + function offsetGet($offset) + { + return 'Bogus '; + } + + function offsetExists($offset) + { + } + } + + $entity = new entity(); + echo($entity->whatever[0]); + + //This will crash +// $entity->whatever->clear(); + unset($entity->whatever[0]); + + //This will not crash (comment previous & uncomment this to test +// $test = $entity->whatever; unset($test[0]); + + echo($entity->whatever[0]); + echo "ok\n"; +?> +--EXPECT-- +Bogus Bogus ok diff --git a/Zend/tests/bug40899.phpt b/Zend/tests/bug40899.phpt new file mode 100644 index 000000000..7be0f6b8e --- /dev/null +++ b/Zend/tests/bug40899.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #40899 (memory leak when nesting list()) +--FILE-- +<?php +list(list($a,$b),$c)=array(array('a','b'),'c'); +echo "$a$b$c\n"; +?> +--EXPECT-- +abc diff --git a/Zend/tests/bug41026.phpt b/Zend/tests/bug41026.phpt new file mode 100644 index 000000000..7caac215e --- /dev/null +++ b/Zend/tests/bug41026.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #41026 (segfault when calling "self::method()" in shutdown functions) +--FILE-- +<?php + +class try_class +{ + static public function main () + { + register_shutdown_function (array ("self", "on_shutdown")); + } + + static public function on_shutdown () + { + printf ("CHECKPOINT\n"); /* never reached */ + } +} + +try_class::main (); + +echo "Done\n"; +?> +--EXPECTF-- +Done + +Warning: (Registered shutdown functions) Unable to call self::on_shutdown() - function does not exist in Unknown on line 0 diff --git a/Zend/tests/bug41075.phpt b/Zend/tests/bug41075.phpt new file mode 100644 index 000000000..ddeb7cc0c --- /dev/null +++ b/Zend/tests/bug41075.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #41075(memleak when creating default object caused exception) +--FILE-- +<?php + +function err($errno, $errstr, $errfile, $errline) +{ + throw new Exception($errstr); +} + +set_error_handler("err"); + +class test { + function foo() { + $var = $this->blah->prop = "string"; + var_dump($this->blah); + } +} + +$t = new test; +try { + $t->foo(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(40) "Creating default object from empty value" +Done diff --git a/Zend/tests/bug41117_1.phpt b/Zend/tests/bug41117_1.phpt new file mode 100755 index 000000000..f555b637a --- /dev/null +++ b/Zend/tests/bug41117_1.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41117 (Altering $this via argument) +--FILE-- +<?php +class foo { + function __construct($this) { + echo $this."\n"; + } +} +$obj = new foo("Hello world"); +?> +--EXPECTF-- +Fatal error: Cannot re-assign $this in %sbug41117_1.php on line 3 + diff --git a/Zend/tests/bug41209.phpt b/Zend/tests/bug41209.phpt new file mode 100644 index 000000000..0834b376b --- /dev/null +++ b/Zend/tests/bug41209.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #41209 (Segmentation fault with ArrayAccess, set_error_handler and undefined var) +--FILE-- +<?php + +class env +{ + public function __construct() + { + set_error_handler(array(__CLASS__, 'errorHandler')); + } + + public static function errorHandler($errno, $errstr, $errfile, $errline) + { + throw new ErrorException($errstr, 0, $errno, $errfile, $errline); + } +} + +class cache implements ArrayAccess +{ + private $container = array(); + + public function offsetGet($id) {} + + public function offsetSet($id, $value) {} + + public function offsetUnset($id) {} + + public function offsetExists($id) + { + return isset($this->containers[(string) $id]); + } +} + +$env = new env(); +$cache = new cache(); +var_dump(isset($cache[$id])); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: id' in %s:%d +Stack trace: +#0 %s(%d): env::errorHandler() +#1 {main} + thrown in %s on line %d diff --git a/Zend/tests/cast_to_array.phpt b/Zend/tests/cast_to_array.phpt Binary files differnew file mode 100644 index 000000000..5e351052b --- /dev/null +++ b/Zend/tests/cast_to_array.phpt diff --git a/Zend/tests/cast_to_bool.phpt b/Zend/tests/cast_to_bool.phpt new file mode 100644 index 000000000..75ab09d1b --- /dev/null +++ b/Zend/tests/cast_to_bool.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to boolean +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (bool)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +Done diff --git a/Zend/tests/cast_to_double.phpt b/Zend/tests/cast_to_double.phpt new file mode 100644 index 000000000..7afc2708b --- /dev/null +++ b/Zend/tests/cast_to_double.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to double +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (double)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(0) +float(8754456) +float(0) +float(0) +float(9876545) +float(0.1) +float(0) +float(1) +float(0) +float(1) +float(0) +float(%d) + +Notice: Object of class test could not be converted to double in %s on line %d +float(1) +Done diff --git a/Zend/tests/cast_to_int.phpt b/Zend/tests/cast_to_int.phpt new file mode 100644 index 000000000..28c57ddf6 --- /dev/null +++ b/Zend/tests/cast_to_int.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to integer +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + $tmp = (int)$var; + var_dump($tmp); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(8754456) +int(0) +int(0) +int(9876545) +int(0) +int(0) +int(1) +int(0) +int(1) +int(0) +int(%d) + +Notice: Object of class test could not be converted to int in %s on line %d +int(1) +Done diff --git a/Zend/tests/cast_to_object.phpt b/Zend/tests/cast_to_object.phpt Binary files differnew file mode 100644 index 000000000..f8d487847 --- /dev/null +++ b/Zend/tests/cast_to_object.phpt diff --git a/Zend/tests/cast_to_string.phpt b/Zend/tests/cast_to_string.phpt Binary files differnew file mode 100644 index 000000000..d06daa2e7 --- /dev/null +++ b/Zend/tests/cast_to_string.phpt diff --git a/Zend/tests/concat_001.phpt b/Zend/tests/concat_001.phpt new file mode 100644 index 000000000..be1297655 --- /dev/null +++ b/Zend/tests/concat_001.phpt @@ -0,0 +1,78 @@ +--TEST-- +concat difffent types +--INI-- +precision=14 +--FILE-- +<?php + +class test { + function __toString() { + return "this is test object"; + } +} + +$a = array(1,2,3); +$o = new test; +$s = "some string"; +$i = 222; +$d = 2323.444; + +var_dump($a.$o); +var_dump($a.$s); +var_dump($a.$i); +var_dump($a.$d); +var_dump($a.$a); + +var_dump($o.$a); +var_dump($o.$s); +var_dump($o.$i); +var_dump($o.$d); +var_dump($o.$o); + +var_dump($s.$o); +var_dump($s.$a); +var_dump($s.$i); +var_dump($s.$d); +var_dump($s.$s); + +var_dump($i.$a); +var_dump($i.$o); +var_dump($i.$s); +var_dump($i.$d); +var_dump($i.$i); + +var_dump($d.$a); +var_dump($d.$o); +var_dump($d.$s); +var_dump($d.$i); +var_dump($d.$d); + +echo "Done\n"; +?> +--EXPECTF-- +string(24) "Arraythis is test object" +string(16) "Arraysome string" +string(8) "Array222" +string(13) "Array2323.444" +string(10) "ArrayArray" +string(24) "this is test objectArray" +string(30) "this is test objectsome string" +string(22) "this is test object222" +string(27) "this is test object2323.444" +string(38) "this is test objectthis is test object" +string(30) "some stringthis is test object" +string(16) "some stringArray" +string(14) "some string222" +string(19) "some string2323.444" +string(22) "some stringsome string" +string(8) "222Array" +string(22) "222this is test object" +string(14) "222some string" +string(11) "2222323.444" +string(6) "222222" +string(13) "2323.444Array" +string(27) "2323.444this is test object" +string(19) "2323.444some string" +string(11) "2323.444222" +string(16) "2323.4442323.444" +Done diff --git a/Zend/tests/div_001.phpt b/Zend/tests/div_001.phpt new file mode 100644 index 000000000..5fa264a11 --- /dev/null +++ b/Zend/tests/div_001.phpt @@ -0,0 +1,32 @@ +--TEST-- +dividing doubles +--INI-- +precision=14 +--FILE-- +<?php + +$d1 = 1.1; +$d2 = 434234.234; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = 1.1; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +$d1 = "1.1"; +$d2 = "434234.234"; + +$c = $d2 / $d1; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +float(394758.39454545) +float(394758.39454545) +float(394758.39454545) +Done diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt new file mode 100644 index 000000000..6ade1d9f5 --- /dev/null +++ b/Zend/tests/div_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +dividing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a / $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/double_to_string.phpt b/Zend/tests/double_to_string.phpt new file mode 100644 index 000000000..d1098e719 --- /dev/null +++ b/Zend/tests/double_to_string.phpt @@ -0,0 +1,52 @@ +--TEST-- +double to string conversion tests +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 290000000000000000, + 290000000000000, + 29000000000000, + 29000000000000.123123, + 29000000000000.7123123, + 29000.7123123, + 239234242.7123123, + 0.12345678901234567890, + 10000000000000, + 100000000000000, + 1000000000000000001, + 100000000000001, + 10000000000, + 999999999999999, + 9999999999999999, + (float)0 + ); + +foreach ($doubles as $d) { + var_dump((string)$d); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(7) "2.9E+17" +string(7) "2.9E+14" +string(14) "29000000000000" +string(14) "29000000000000" +string(14) "29000000000001" +string(13) "29000.7123123" +string(15) "239234242.71231" +string(16) "0.12345678901235" +string(14) "10000000000000" +string(7) "1.0E+14" +string(7) "1.0E+18" +string(7) "1.0E+14" +string(11) "10000000000" +string(7) "1.0E+15" +string(7) "1.0E+16" +string(1) "0" +Done diff --git a/Zend/tests/double_to_string_64bit.phpt b/Zend/tests/double_to_string_64bit.phpt new file mode 100644 index 000000000..c52c38c57 --- /dev/null +++ b/Zend/tests/double_to_string_64bit.phpt @@ -0,0 +1,56 @@ +--TEST-- +double to string conversion tests (64bit) +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 29000000000000000000000000000000000000, + 290000000000000000, + 290000000000000, + 29000000000000, + 29000000000000.123123, + 29000000000000.7123123, + 29000.7123123, + 239234242.7123123, + 0.12345678901234567890, + 10000000000000000000000000000000000000000000000, + 1000000000000000000000000000000000, + 100000000000000001, + 1000006000000000011, + 100000000000001, + 10000000000, + 999999999999999999, + 9999999999999999999, + 9999999999999999999999999999999999999, + (float)0 + ); + +foreach ($doubles as $d) { + var_dump((string)$d); +} + +echo "Done\n"; +?> +--EXPECTF-- +string(7) "2.9E+37" +string(18) "290000000000000000" +string(15) "290000000000000" +string(14) "29000000000000" +string(14) "29000000000000" +string(14) "29000000000001" +string(13) "29000.7123123" +string(15) "239234242.71231" +string(16) "0.12345678901235" +string(7) "1.0E+46" +string(7) "1.0E+33" +string(18) "100000000000000001" +string(19) "1000006000000000011" +string(15) "100000000000001" +string(11) "10000000000" +string(18) "999999999999999999" +string(7) "1.0E+19" +string(7) "1.0E+37" +string(1) "0" +Done diff --git a/Zend/tests/errmsg_001.phpt b/Zend/tests/errmsg_001.phpt new file mode 100644 index 000000000..b85e032b9 --- /dev/null +++ b/Zend/tests/errmsg_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: Non-abstract method must contain body +--FILE-- +<?php + +abstract class test { +} + +class Impl extends Test { + function Foo(); +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Non-abstract method Impl::Foo() must contain body in %s on line %d diff --git a/Zend/tests/errmsg_002.phpt b/Zend/tests/errmsg_002.phpt new file mode 100644 index 000000000..b7330c9f1 --- /dev/null +++ b/Zend/tests/errmsg_002.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: function cannot be declared private +--FILE-- +<?php + +abstract class test { + abstract private function foo() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Abstract function test::foo() cannot be declared private in %s on line %d diff --git a/Zend/tests/errmsg_003.phpt b/Zend/tests/errmsg_003.phpt new file mode 100644 index 000000000..64e458781 --- /dev/null +++ b/Zend/tests/errmsg_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +errmsg: cannot reassign $this (by ref) +--FILE-- +<?php + +class test { + function foo() { + $a = new test; + $this = &$a; + } +} + +$t = new test; +$t->foo(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot re-assign $this in %s on line %d diff --git a/Zend/tests/errmsg_004.phpt b/Zend/tests/errmsg_004.phpt new file mode 100644 index 000000000..e6d22d6ab --- /dev/null +++ b/Zend/tests/errmsg_004.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: can't use function return value in write context +--FILE-- +<?php + +function foo() { + return "blah"; +} + +foo() = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Can't use function return value in write context in %s on line %d diff --git a/Zend/tests/errmsg_005.phpt b/Zend/tests/errmsg_005.phpt new file mode 100644 index 000000000..31c924cbb --- /dev/null +++ b/Zend/tests/errmsg_005.phpt @@ -0,0 +1,18 @@ +--TEST-- +errmsg: can't use method return value in write context +--FILE-- +<?php + +class test { + function foo() { + return "blah"; + } +} + +$t = new test; +$t->foo() = 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Can't use method return value in write context in %s on line %d diff --git a/Zend/tests/errmsg_006.phpt b/Zend/tests/errmsg_006.phpt new file mode 100644 index 000000000..976093d85 --- /dev/null +++ b/Zend/tests/errmsg_006.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for reading +--FILE-- +<?php + +$a = array(); +$b = $a[]; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/errmsg_007.phpt b/Zend/tests/errmsg_007.phpt new file mode 100644 index 000000000..1ac296695 --- /dev/null +++ b/Zend/tests/errmsg_007.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for reading - 2 +--FILE-- +<?php + +$a = array(); +isset($a[]); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for reading in %s on line %d diff --git a/Zend/tests/errmsg_008.phpt b/Zend/tests/errmsg_008.phpt new file mode 100644 index 000000000..e900603a8 --- /dev/null +++ b/Zend/tests/errmsg_008.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: can't use [] for unsetting +--FILE-- +<?php + +$a = array(); +unset($a[]); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use [] for unsetting in %s on line %d diff --git a/Zend/tests/errmsg_009.phpt b/Zend/tests/errmsg_009.phpt new file mode 100644 index 000000000..4834fa3e7 --- /dev/null +++ b/Zend/tests/errmsg_009.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: multiple access type modifiers are not allowed (properties) +--FILE-- +<?php + +class test { + public private $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/errmsg_010.phpt b/Zend/tests/errmsg_010.phpt new file mode 100644 index 000000000..ae2572f7b --- /dev/null +++ b/Zend/tests/errmsg_010.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: multiple access type modifiers are not allowed (methods) +--FILE-- +<?php + +class test { + private protected function foo() {} +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Multiple access type modifiers are not allowed in %s on line %d diff --git a/Zend/tests/errmsg_011.phpt b/Zend/tests/errmsg_011.phpt new file mode 100644 index 000000000..9cfde0f8b --- /dev/null +++ b/Zend/tests/errmsg_011.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: cannot redeclare (method) +--FILE-- +<?php + +class test { + + function foo() {} + function foo() {} + +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare test::foo() in %s on line %d diff --git a/Zend/tests/errmsg_012.phpt b/Zend/tests/errmsg_012.phpt new file mode 100644 index 000000000..183785be0 --- /dev/null +++ b/Zend/tests/errmsg_012.phpt @@ -0,0 +1,11 @@ +--TEST-- +errmsg: __autoload() must take exactly 1 argument +--FILE-- +<?php + +function __autoload($a, $b) {} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: __autoload() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_013.phpt b/Zend/tests/errmsg_013.phpt new file mode 100644 index 000000000..d1f248ec2 --- /dev/null +++ b/Zend/tests/errmsg_013.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: default value for parameters with array type hint can only be an array or NULL +--FILE-- +<?php + +class test { + function foo(array $a = "s") { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Default value for parameters with array type hint can only be an array or NULL in %s on line %d diff --git a/Zend/tests/errmsg_014.phpt b/Zend/tests/errmsg_014.phpt new file mode 100644 index 000000000..77e12b05e --- /dev/null +++ b/Zend/tests/errmsg_014.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: cannot call __clone() method on objects +--FILE-- +<?php + +class test { + function __clone() { + } +} + +$t = new test; +$t->__clone(); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot call __clone() method on objects - use 'clone $obj' instead in %s on line %d diff --git a/Zend/tests/errmsg_015.phpt b/Zend/tests/errmsg_015.phpt new file mode 100644 index 000000000..8e626e509 --- /dev/null +++ b/Zend/tests/errmsg_015.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __clone() cannot accept any arguments +--FILE-- +<?php + +class test { + function __clone($var) { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__clone() cannot accept any arguments in %s on line %d diff --git a/Zend/tests/errmsg_016.phpt b/Zend/tests/errmsg_016.phpt new file mode 100644 index 000000000..ccda07b9a --- /dev/null +++ b/Zend/tests/errmsg_016.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __isset() must take exactly 1 argument +--FILE-- +<?php + +class test { + function __isset() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__isset() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_017.phpt b/Zend/tests/errmsg_017.phpt new file mode 100644 index 000000000..df2b66568 --- /dev/null +++ b/Zend/tests/errmsg_017.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __unset() must take exactly 1 argument +--FILE-- +<?php + +class test { + function __unset() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Method test::__unset() must take exactly 1 argument in %s on line %d diff --git a/Zend/tests/errmsg_018.phpt b/Zend/tests/errmsg_018.phpt new file mode 100644 index 000000000..fb05cb1a5 --- /dev/null +++ b/Zend/tests/errmsg_018.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: static abstract function +--FILE-- +<?php + +class test { + static abstract function foo (); +} + +echo "Done\n"; +?> +--EXPECTF-- +Strict Standards: Static function test::foo() should not be abstract in %s on line %d + +Fatal error: Class test contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (test::foo) in %s on line %d diff --git a/Zend/tests/errmsg_019.phpt b/Zend/tests/errmsg_019.phpt new file mode 100644 index 000000000..2b45650cf --- /dev/null +++ b/Zend/tests/errmsg_019.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: __destruct() cannot take arguments +--FILE-- +<?php + +class test { + function __destruct($var) { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Destructor test::__destruct() cannot take arguments in %s on line %d diff --git a/Zend/tests/errmsg_020.phpt b/Zend/tests/errmsg_020.phpt new file mode 100644 index 000000000..8199d5d06 --- /dev/null +++ b/Zend/tests/errmsg_020.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: disabled function +--INI-- +disable_functions=phpinfo +--FILE-- +<?php + +phpinfo(); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: phpinfo() has been disabled for security reasons in %s on line %d +Done diff --git a/Zend/tests/errmsg_021.phpt b/Zend/tests/errmsg_021.phpt new file mode 100644 index 000000000..4e62f8511 --- /dev/null +++ b/Zend/tests/errmsg_021.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: disabled class +--INI-- +disable_classes=stdclass +--FILE-- +<?php + +class test extends stdclass { +} + +$t = new test; + +echo "Done\n"; +?> +--EXPECTF-- +Warning: test() has been disabled for security reasons in %s on line %d +Done diff --git a/Zend/tests/errmsg_022.phpt b/Zend/tests/errmsg_022.phpt new file mode 100644 index 000000000..ea7b082f9 --- /dev/null +++ b/Zend/tests/errmsg_022.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: only variables can be passed by reference +--FILE-- +<?php + +function foo (&$var) { +} + +foo(1); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Only variables can be passed by reference in %s on line %d diff --git a/Zend/tests/errmsg_023.phpt b/Zend/tests/errmsg_023.phpt new file mode 100644 index 000000000..9fd7804ea --- /dev/null +++ b/Zend/tests/errmsg_023.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: access level must be the same or weaker +--FILE-- +<?php + +class test1 { + protected $var; +} + +class test extends test1 { + private $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Access level to test::$var must be protected (as in class test1) or weaker in %s on line %d diff --git a/Zend/tests/errmsg_024.phpt b/Zend/tests/errmsg_024.phpt new file mode 100644 index 000000000..d8d06cbce --- /dev/null +++ b/Zend/tests/errmsg_024.phpt @@ -0,0 +1,17 @@ +--TEST-- +errmsg: cannot change initial value of property +--FILE-- +<?php + +class test1 { + static protected $var = 1; +} + +class test extends test1 { + static $var = 10; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot change initial value of property static protected test1::$var in class test in %s on line %d diff --git a/Zend/tests/errmsg_025.phpt b/Zend/tests/errmsg_025.phpt new file mode 100644 index 000000000..d853f7342 --- /dev/null +++ b/Zend/tests/errmsg_025.phpt @@ -0,0 +1,20 @@ +--TEST-- +errmsg: cannot inherit previously inherited constant +--FILE-- +<?php + +interface test1 { + const FOO = 10; +} + +interface test2 { + const FOO = 10; +} + +class test implements test1, test2 { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot inherit previously-inherited constant FOO from interface test2 in %s on line %d diff --git a/Zend/tests/errmsg_026.phpt b/Zend/tests/errmsg_026.phpt new file mode 100644 index 000000000..195412290 --- /dev/null +++ b/Zend/tests/errmsg_026.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot redeclare class +--FILE-- +<?php + +class stdclass { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare class stdclass in %s on line %d diff --git a/Zend/tests/errmsg_027.phpt b/Zend/tests/errmsg_027.phpt new file mode 100644 index 000000000..f4fec6155 --- /dev/null +++ b/Zend/tests/errmsg_027.phpt @@ -0,0 +1,16 @@ +--TEST-- +errmsg: class declarations may not be nested +--FILE-- +<?php + +class test { + function foo() { + class test2 { + } + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Class declarations may not be nested in %s on line %d diff --git a/Zend/tests/errmsg_028.phpt b/Zend/tests/errmsg_028.phpt new file mode 100644 index 000000000..3331cb35b --- /dev/null +++ b/Zend/tests/errmsg_028.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as class name +--FILE-- +<?php + +class self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_029.phpt b/Zend/tests/errmsg_029.phpt new file mode 100644 index 000000000..73b85ce6a --- /dev/null +++ b/Zend/tests/errmsg_029.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as class name +--FILE-- +<?php + +class parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_030.phpt b/Zend/tests/errmsg_030.phpt new file mode 100644 index 000000000..ab6ccbd41 --- /dev/null +++ b/Zend/tests/errmsg_030.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as parent class name +--FILE-- +<?php + +class test extends self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_031.phpt b/Zend/tests/errmsg_031.phpt new file mode 100644 index 000000000..6e3564854 --- /dev/null +++ b/Zend/tests/errmsg_031.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as parent class name +--FILE-- +<?php + +class test extends parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as class name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_032.phpt b/Zend/tests/errmsg_032.phpt new file mode 100644 index 000000000..6e34604cd --- /dev/null +++ b/Zend/tests/errmsg_032.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __construct() cannot be static +--FILE-- +<?php + +class test { + + static function __construct() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Constructor test::__construct() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_033.phpt b/Zend/tests/errmsg_033.phpt new file mode 100644 index 000000000..96938900e --- /dev/null +++ b/Zend/tests/errmsg_033.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __destruct() cannot be static +--FILE-- +<?php + +class test { + + static function __destruct() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Destructor test::__destruct() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_034.phpt b/Zend/tests/errmsg_034.phpt new file mode 100644 index 000000000..1494fe532 --- /dev/null +++ b/Zend/tests/errmsg_034.phpt @@ -0,0 +1,15 @@ +--TEST-- +errmsg: __clone() cannot be static +--FILE-- +<?php + +class test { + + static function __clone() { + } +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Clone method test::__clone() cannot be static in %s on line %d diff --git a/Zend/tests/errmsg_035.phpt b/Zend/tests/errmsg_035.phpt new file mode 100644 index 000000000..76cbe3d48 --- /dev/null +++ b/Zend/tests/errmsg_035.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'self' as interface name +--FILE-- +<?php + +class test implements self { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'self' as interface name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_036.phpt b/Zend/tests/errmsg_036.phpt new file mode 100644 index 000000000..d1f4274bd --- /dev/null +++ b/Zend/tests/errmsg_036.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot use 'parent' as interface name +--FILE-- +<?php + +class test implements parent { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use 'parent' as interface name as it is reserved in %s on line %d diff --git a/Zend/tests/errmsg_037.phpt b/Zend/tests/errmsg_037.phpt new file mode 100644 index 000000000..6b98bb333 --- /dev/null +++ b/Zend/tests/errmsg_037.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: properties cannot be abstract +--FILE-- +<?php + +class test { + abstract $var = 1; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Properties cannot be declared abstract in %s on line %d diff --git a/Zend/tests/errmsg_038.phpt b/Zend/tests/errmsg_038.phpt new file mode 100644 index 000000000..fdab803ba --- /dev/null +++ b/Zend/tests/errmsg_038.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: properties cannot be final +--FILE-- +<?php + +class test { + final $var = 1; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot declare property test::$var final, the final modifier is allowed only for methods in %s on line %d diff --git a/Zend/tests/errmsg_039.phpt b/Zend/tests/errmsg_039.phpt new file mode 100644 index 000000000..000081187 --- /dev/null +++ b/Zend/tests/errmsg_039.phpt @@ -0,0 +1,14 @@ +--TEST-- +errmsg: cannot redeclare property +--FILE-- +<?php + +class test { + var $var; + var $var; +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot redeclare test::$var in %s on line %d diff --git a/Zend/tests/errmsg_040.phpt b/Zend/tests/errmsg_040.phpt new file mode 100644 index 000000000..f3d0afcf0 --- /dev/null +++ b/Zend/tests/errmsg_040.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: arrays are not allowed in class constants +--FILE-- +<?php + +class test { + const TEST = array(1,2,3); +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Arrays are not allowed in class constants in %s on line %d diff --git a/Zend/tests/errmsg_041.phpt b/Zend/tests/errmsg_041.phpt new file mode 100644 index 000000000..bfcafd261 --- /dev/null +++ b/Zend/tests/errmsg_041.phpt @@ -0,0 +1,11 @@ +--TEST-- +errmsg: instanceof expects an object instance, constant given +--FILE-- +<?php + +var_dump("abc" instanceof stdclass); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: instanceof expects an object instance, constant given in %s on line %d diff --git a/Zend/tests/errmsg_042.phpt b/Zend/tests/errmsg_042.phpt new file mode 100644 index 000000000..3b4ea7c26 --- /dev/null +++ b/Zend/tests/errmsg_042.phpt @@ -0,0 +1,13 @@ +--TEST-- +errmsg: key element cannot be a reference +--FILE-- +<?php + +$a = array(1,2,3); +foreach ($a as &$k=>$v) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Key element cannot be a reference in %s on line %d diff --git a/Zend/tests/errmsg_043.phpt b/Zend/tests/errmsg_043.phpt new file mode 100644 index 000000000..3de8bc206 --- /dev/null +++ b/Zend/tests/errmsg_043.phpt @@ -0,0 +1,12 @@ +--TEST-- +errmsg: cannot create references to temp array +--FILE-- +<?php + +foreach (array(1,2,3) as $k=>&$v) { +} + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot create references to elements of a temporary array expression in %s on line %d diff --git a/Zend/tests/foreach.phpt b/Zend/tests/foreach.phpt new file mode 100644 index 000000000..041a7636e --- /dev/null +++ b/Zend/tests/foreach.phpt @@ -0,0 +1,25 @@ +--TEST-- +foreach() by-ref bug +--FILE-- +<?php +$foo = array(1,2,3,4); +foreach($foo as $key => &$val) { + if($val == 3) { + $foo[$key] = 0; + } else { + $val++; + } +} +var_dump($foo); +?> +--EXPECT-- +array(4) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(0) + [3]=> + &int(5) +} diff --git a/Zend/tests/globals.inc b/Zend/tests/globals.inc new file mode 100644 index 000000000..976237cf1 --- /dev/null +++ b/Zend/tests/globals.inc @@ -0,0 +1,15 @@ +<?php + +var_dump(isset($_SERVER)); +var_dump(empty($_SERVER)); +var_dump(gettype($_SERVER)); +var_dump(count($_SERVER)); + +var_dump($_SERVER['PHP_SELF']); +unset($_SERVER['PHP_SELF']); +var_dump($_SERVER['PHP_SELF']); + +unset($_SERVER); +var_dump($_SERVER); + +?> diff --git a/Zend/tests/globals_001.phpt b/Zend/tests/globals_001.phpt new file mode 100644 index 000000000..b678c5310 --- /dev/null +++ b/Zend/tests/globals_001.phpt @@ -0,0 +1,34 @@ +--TEST-- +globals in global scope +--INIT-- +variables_order="egpcs" +--FILE-- +<?php + +var_dump(isset($_SERVER)); +var_dump(empty($_SERVER)); +var_dump(gettype($_SERVER)); +var_dump(count($_SERVER)); + +var_dump($_SERVER['PHP_SELF']); +unset($_SERVER['PHP_SELF']); +var_dump($_SERVER['PHP_SELF']); + +unset($_SERVER); +var_dump($_SERVER); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_002.phpt b/Zend/tests/globals_002.phpt new file mode 100644 index 000000000..3bc3dae2d --- /dev/null +++ b/Zend/tests/globals_002.phpt @@ -0,0 +1,37 @@ +--TEST-- +globals in local scope +--INIT-- +variables_order="egpcs" +--FILE-- +<?php +function test() { + var_dump(isset($_SERVER)); + var_dump(empty($_SERVER)); + var_dump(gettype($_SERVER)); + var_dump(count($_SERVER)); + + var_dump($_SERVER['PHP_SELF']); + unset($_SERVER['PHP_SELF']); + var_dump($_SERVER['PHP_SELF']); + + unset($_SERVER); + var_dump($_SERVER); +} + +test(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_003.phpt b/Zend/tests/globals_003.phpt new file mode 100644 index 000000000..dcc7935a9 --- /dev/null +++ b/Zend/tests/globals_003.phpt @@ -0,0 +1,43 @@ +--TEST-- +globals in local scope - 2 +--INIT-- +variables_order="egpcs" +--FILE-- +<?php + +class test { + + static function bar() { + + var_dump(isset($_SERVER)); + var_dump(empty($_SERVER)); + var_dump(gettype($_SERVER)); + var_dump(count($_SERVER)); + + var_dump($_SERVER['PHP_SELF']); + unset($_SERVER['PHP_SELF']); + var_dump($_SERVER['PHP_SELF']); + + unset($_SERVER); + var_dump($_SERVER); + + } +} + +test::bar(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/globals_004.phpt b/Zend/tests/globals_004.phpt new file mode 100644 index 000000000..e06791e61 --- /dev/null +++ b/Zend/tests/globals_004.phpt @@ -0,0 +1,28 @@ +--TEST-- +globals in local scope - 3 +--INIT-- +variables_order="egpcs" +--FILE-- +<?php + +function test() { + include dirname(__FILE__)."/globals.inc"; +} + +test(); + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +string(5) "array" +int(%d) +string(%d) "%s" + +Notice: Undefined index: PHP_SELF in %s on line %d +NULL + +Notice: Undefined variable: _SERVER in %s on line %d +NULL +Done diff --git a/Zend/tests/halt_compiler1.phpt b/Zend/tests/halt_compiler1.phpt new file mode 100644 index 000000000..4987b29b2 --- /dev/null +++ b/Zend/tests/halt_compiler1.phpt @@ -0,0 +1,8 @@ +--TEST-- +__HALT_COMPILER(); +--FILE-- +<?php echo 'test'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); +?> +===DONE=== +--EXPECT-- +testint(73)
\ No newline at end of file diff --git a/Zend/tests/halt_compiler2.phpt b/Zend/tests/halt_compiler2.phpt new file mode 100644 index 000000000..0ced2142c --- /dev/null +++ b/Zend/tests/halt_compiler2.phpt @@ -0,0 +1,23 @@ +--TEST-- +__HALT_COMPILER(); 2 files +--FILE-- +<?php +$text = "<?php echo 'test'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); ?> +hi there"; +file_put_contents(dirname(__FILE__) . '/test1.php', $text); +$text = "<?php echo 'test2'; var_dump(__COMPILER_HALT_OFFSET__); __HALT_COMPILER(); ?> +hi there 2"; +file_put_contents(dirname(__FILE__) . '/test2.php', $text); +include dirname(__FILE__) . '/test1.php'; +include dirname(__FILE__) . '/test2.php'; +?> +==DONE== +--CLEAN-- +<?php +unlink(dirname(__FILE__) . '/test1.php'); +unlink(dirname(__FILE__) . '/test2.php'); +?> +--EXPECT-- +testint(73) +test2int(74) +==DONE==
\ No newline at end of file diff --git a/Zend/tests/halt_compiler3.phpt b/Zend/tests/halt_compiler3.phpt new file mode 100644 index 000000000..6ee16f79b --- /dev/null +++ b/Zend/tests/halt_compiler3.phpt @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 1 +--FILE-- +<?php +define ('__COMPILER_HALT_OFFSET__', 1); +?> +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d +==DONE==
\ No newline at end of file diff --git a/Zend/tests/halt_compiler4.phpt b/Zend/tests/halt_compiler4.phpt new file mode 100644 index 000000000..43e532ce7 --- /dev/null +++ b/Zend/tests/halt_compiler4.phpt @@ -0,0 +1,10 @@ +--TEST-- +__HALT_COMPILER(); bad define() of __COMPILER_HALT_OFFSET__ 2 +--FILE-- +<?php +define ('__COMPILER_HALT_OFFSET__', 1); +__HALT_COMPILER(); +?> +==DONE== +--EXPECTF-- +Notice: Constant __COMPILER_HALT_OFFSET__ already defined in %s on line %d
\ No newline at end of file diff --git a/Zend/tests/hex_overflow_32bit.phpt b/Zend/tests/hex_overflow_32bit.phpt new file mode 100644 index 000000000..36e9a7e9d --- /dev/null +++ b/Zend/tests/hex_overflow_32bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +testing integer overflow (32bit) +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 0x1736123FFFAAA, + 0XFFFFFFFFFFFFFFFFFF, + 0xAAAAAAAAAAAAAAEEEEEEEEEBBB, + 0x66666666666666666777777, + ); + +foreach ($doubles as $d) { + $l = $d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(4083360297110%d) +float(4.7223664828%dE+21) +float(1.3521606402%dE+31) +float(1.9807040628%dE+27) +Done diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt new file mode 100644 index 000000000..88596f3d5 --- /dev/null +++ b/Zend/tests/mod_001.phpt @@ -0,0 +1,17 @@ +--TEST-- +modulus by zero +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a % $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Division by zero in %s on line %d +bool(false) +Done diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt new file mode 100644 index 000000000..4c5a75e7d --- /dev/null +++ b/Zend/tests/mul_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +multiplying arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a * $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/not_001.phpt b/Zend/tests/not_001.phpt new file mode 100644 index 000000000..6eb0f000c --- /dev/null +++ b/Zend/tests/not_001.phpt @@ -0,0 +1,22 @@ +--TEST-- +bitwise NOT, doubles and strings +--FILE-- +<?php + +$d = 23.67; +$s = "48484.22"; +$s1 = "test"; +$s2 = "some"; + +$s = ~$d; +var_dump($s); + +$s1 = ~$s2; +var_dump(bin2hex($s1)); + +echo "Done\n"; +?> +--EXPECTF-- +int(-24) +string(8) "8c90929a" +Done diff --git a/Zend/tests/not_002.phpt b/Zend/tests/not_002.phpt new file mode 100644 index 000000000..df27772a7 --- /dev/null +++ b/Zend/tests/not_002.phpt @@ -0,0 +1,15 @@ +--TEST-- +bitwise NOT and arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1,2); + +$a = ~$b; +var_dump($a); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/oct_overflow_32bit.phpt b/Zend/tests/oct_overflow_32bit.phpt new file mode 100644 index 000000000..d27c1f547 --- /dev/null +++ b/Zend/tests/oct_overflow_32bit.phpt @@ -0,0 +1,31 @@ +--TEST-- +testing integer overflow (32bit) +--INI-- +precision=14 +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); ?> +--FILE-- +<?php + +$doubles = array( + 076545676543223, + 032325463734, + 077777797777777, + 07777777777777977777777777, + 03333333333333382222222222222, + ); + +foreach ($doubles as $d) { + $l = (double)$d; + var_dump($l); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(4308640384%d) +float(3545655%d) +float(262143) +float(549755813%d) +float(1884877076%d) +Done diff --git a/Zend/tests/offset_assign.phpt b/Zend/tests/offset_assign.phpt new file mode 100644 index 000000000..eebf63c4f --- /dev/null +++ b/Zend/tests/offset_assign.phpt @@ -0,0 +1,11 @@ +--TEST-- +Crash on $x['x']['y'] += 1 when $x is string +--FILE-- +<?php +$x = "a"; +$x['x']['y'] += 1; + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Cannot use string offset as an array in %s on line %d diff --git a/Zend/tests/or_001.phpt b/Zend/tests/or_001.phpt new file mode 100644 index 000000000..1e4e5131a --- /dev/null +++ b/Zend/tests/or_001.phpt @@ -0,0 +1,29 @@ +--TEST-- +bitwise OR and strings +--FILE-- +<?php + +$s = "323423"; +$s1 = "2323.555"; + +var_dump($s | $s1); +var_dump($s1 | $s); + +$s = "some"; +$s1 = "test"; + +var_dump($s | $s1); + +$s = "some"; +$s |= "test"; + +var_dump($s); + +echo "Done\n"; +?> +--EXPECTF-- +string(8) "3337>755" +string(8) "3337>755" +string(4) "wou" +string(4) "wou" +Done diff --git a/Zend/tests/settype_array.phpt b/Zend/tests/settype_array.phpt Binary files differnew file mode 100644 index 000000000..5da023205 --- /dev/null +++ b/Zend/tests/settype_array.phpt diff --git a/Zend/tests/settype_bool.phpt b/Zend/tests/settype_bool.phpt new file mode 100644 index 000000000..cf59200b8 --- /dev/null +++ b/Zend/tests/settype_bool.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to boolean using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "bool"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +Done diff --git a/Zend/tests/settype_double.phpt b/Zend/tests/settype_double.phpt new file mode 100644 index 000000000..931a3d9df --- /dev/null +++ b/Zend/tests/settype_double.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to double using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "double"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +float(0) +float(8754456) +float(0) +float(0) +float(9876545) +float(0.1) +float(0) +float(1) +float(0) +float(1) +float(0) +float(%d) + +Notice: Object of class test could not be converted to double in %s on line %d +float(1) +Done diff --git a/Zend/tests/settype_int.phpt b/Zend/tests/settype_int.phpt new file mode 100644 index 000000000..7b96cd594 --- /dev/null +++ b/Zend/tests/settype_int.phpt @@ -0,0 +1,55 @@ +--TEST-- +casting different variables to integer using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "int"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +int(0) +int(8754456) +int(0) +int(0) +int(9876545) +int(0) +int(0) +int(1) +int(0) +int(1) +int(0) +int(%d) + +Notice: Object of class test could not be converted to int in %s on line %d +int(1) +Done diff --git a/Zend/tests/settype_null.phpt b/Zend/tests/settype_null.phpt new file mode 100644 index 000000000..0abf2f981 --- /dev/null +++ b/Zend/tests/settype_null.phpt @@ -0,0 +1,53 @@ +--TEST-- +casting different variables to null using settype() +--FILE-- +<?php + +$r = fopen(__FILE__, "r"); + +class test { + function __toString() { + return "10"; + } +} + +$o = new test; + +$vars = array( + "string", + "8754456", + "", + "\0", + 9876545, + 0.10, + array(), + array(1,2,3), + false, + true, + NULL, + $r, + $o +); + +foreach ($vars as $var) { + settype($var, "null"); + var_dump($var); +} + +echo "Done\n"; +?> +--EXPECTF-- +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +NULL +Done diff --git a/Zend/tests/settype_object.phpt b/Zend/tests/settype_object.phpt Binary files differnew file mode 100644 index 000000000..d619dce7e --- /dev/null +++ b/Zend/tests/settype_object.phpt diff --git a/Zend/tests/settype_resource.phpt b/Zend/tests/settype_resource.phpt Binary files differnew file mode 100644 index 000000000..cc8cde34f --- /dev/null +++ b/Zend/tests/settype_resource.phpt diff --git a/Zend/tests/settype_string.phpt b/Zend/tests/settype_string.phpt Binary files differnew file mode 100644 index 000000000..d3beb54cb --- /dev/null +++ b/Zend/tests/settype_string.phpt diff --git a/Zend/tests/shift_001.phpt b/Zend/tests/shift_001.phpt new file mode 100644 index 000000000..aeb399452 --- /dev/null +++ b/Zend/tests/shift_001.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings left +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s <<= 2; +var_dump($s); + +$s1 <<= 1; +var_dump($s1); + +$s2 <<= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(492) +int(0) +int(362760) +Done diff --git a/Zend/tests/shift_002.phpt b/Zend/tests/shift_002.phpt new file mode 100644 index 000000000..4d8421a56 --- /dev/null +++ b/Zend/tests/shift_002.phpt @@ -0,0 +1,25 @@ +--TEST-- +shifting strings right +--FILE-- +<?php + +$s = "123"; +$s1 = "test"; +$s2 = "45345some"; + +$s >>= 2; +var_dump($s); + +$s1 >>= 1; +var_dump($s1); + +$s2 >>= 3; +var_dump($s2); + +echo "Done\n"; +?> +--EXPECTF-- +int(30) +int(0) +int(5668) +Done diff --git a/Zend/tests/sub_001.phpt b/Zend/tests/sub_001.phpt new file mode 100644 index 000000000..2a8b3cdff --- /dev/null +++ b/Zend/tests/sub_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +subtracting arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(1); + +$c = $a - $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +Fatal error: Unsupported operand types in %s on line %d diff --git a/Zend/tests/unset_cv08.phpt b/Zend/tests/unset_cv08.phpt index 04fff3d40..d5d52efdb 100644 --- a/Zend/tests/unset_cv08.phpt +++ b/Zend/tests/unset_cv08.phpt @@ -11,6 +11,5 @@ echo "ok\n"; ?>
--EXPECTF--
ok
-
-Notice: Undefined variable: b in %sunset_cv08.php on line %d
+ok
ok
diff --git a/Zend/tests/xor_001.phpt b/Zend/tests/xor_001.phpt new file mode 100644 index 000000000..e1a521dff --- /dev/null +++ b/Zend/tests/xor_001.phpt @@ -0,0 +1,16 @@ +--TEST-- +XORing arrays +--FILE-- +<?php + +$a = array(1,2,3); +$b = array(); + +$c = $a ^ $b; +var_dump($c); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +Done diff --git a/Zend/tests/xor_002.phpt b/Zend/tests/xor_002.phpt new file mode 100644 index 000000000..0cf4054fa --- /dev/null +++ b/Zend/tests/xor_002.phpt @@ -0,0 +1,39 @@ +--TEST-- +XORing strings +--FILE-- +<?php + +$s = "123"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "1235"; +$s1 = "234"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some long"; +$s1 = "test"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s1 = "test long"; +var_dump(bin2hex($s ^ $s1)); + +$s = "some"; +$s ^= "test long"; +var_dump(bin2hex($s)); + +echo "Done\n"; +?> +--EXPECTF-- +string(6) "030107" +string(6) "030107" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +string(8) "070a1e11" +Done diff --git a/Zend/tests/xor_003.phpt b/Zend/tests/xor_003.phpt new file mode 100644 index 000000000..8aa1c636b --- /dev/null +++ b/Zend/tests/xor_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +XORing booleans +--FILE-- +<?php + +$t = true; +$f = false; + +var_dump($t ^ $f); +var_dump($t ^ $t); +var_dump($f ^ $f); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(0) +int(0) +Done |
