From: Felipe Pena Date: Mon, 28 Jul 2008 14:10:00 +0000 (+0000) Subject: - MFH: New tests X-Git-Tag: php-5.3.0alpha1~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e06259421563e7001ec48c44c1e8401e8d307b04;p=php - MFH: New tests --- diff --git a/Zend/tests/036.phpt b/Zend/tests/036.phpt new file mode 100644 index 0000000000..6feb23f679 --- /dev/null +++ b/Zend/tests/036.phpt @@ -0,0 +1,13 @@ +--TEST-- +Trying to use lambda in array offset +--FILE-- + +--EXPECTF-- +Warning: Illegal offset type in %s on line %d + +Warning: Illegal offset type in %s on line %d diff --git a/Zend/tests/037.phpt b/Zend/tests/037.phpt new file mode 100644 index 0000000000..d7057b4844 --- /dev/null +++ b/Zend/tests/037.phpt @@ -0,0 +1,19 @@ +--TEST-- +Trying to access inexistent static property of Closure +--FILE-- + +--EXPECTF-- +int(1) + +Fatal error: Access to undeclared static property: Closure::$x in %s on line %d diff --git a/Zend/tests/038.phpt b/Zend/tests/038.phpt new file mode 100644 index 0000000000..963e73f9ea --- /dev/null +++ b/Zend/tests/038.phpt @@ -0,0 +1,12 @@ +--TEST-- +Trying to use lambda as array key +--FILE-- + 1)); + +?> +--EXPECTF-- +Warning: Illegal offset type in %s on line %d +array(0) { +} diff --git a/Zend/tests/closure_024.phpt b/Zend/tests/closure_024.phpt new file mode 100644 index 0000000000..504e81efd9 --- /dev/null +++ b/Zend/tests/closure_024.phpt @@ -0,0 +1,16 @@ +--TEST-- +Closure 024: Trying to clone the Closure object +--FILE-- + +--EXPECTF-- +Fatal error: Trying to clone an uncloneable object of class Closure in %s on line %d diff --git a/Zend/tests/closure_025.phpt b/Zend/tests/closure_025.phpt new file mode 100644 index 0000000000..8ee187e1c8 --- /dev/null +++ b/Zend/tests/closure_025.phpt @@ -0,0 +1,12 @@ +--TEST-- +Closure 025: Using closure in create_function() +--FILE-- +__invoke(4)); + +?> +--EXPECT-- +int(8) diff --git a/Zend/tests/closure_026.phpt b/Zend/tests/closure_026.phpt new file mode 100644 index 0000000000..f9e6bd5e25 --- /dev/null +++ b/Zend/tests/closure_026.phpt @@ -0,0 +1,47 @@ +--TEST-- +Closure 026: Assigning a closure object to an array in $this +--FILE-- +a[] = function() { + return 1; + }; + + var_dump($this); + + var_dump($this->a[0]()); + } +} + +$x = new foo; + +print "--------------\n"; + +foreach ($x as $b => $c) { + var_dump($b, $c); + var_dump($c[0]()); +} + +?> +--EXPECTF-- +object(foo)#%d (1) { + ["a"]=> + array(1) { + [0]=> + object(Closure)#%d (0) { + } + } +} +int(1) +-------------- +string(1) "a" +array(1) { + [0]=> + object(Closure)#%d (0) { + } +} +int(1) diff --git a/Zend/tests/closure_027.phpt b/Zend/tests/closure_027.phpt new file mode 100644 index 0000000000..7787f729e5 --- /dev/null +++ b/Zend/tests/closure_027.phpt @@ -0,0 +1,31 @@ +--TEST-- +Closure 027: Testing Closure type-hint +--FILE-- + +--EXPECTF-- +object(stdClass)#%d (0) { +} +NULL + +Notice: Undefined variable: y in %s on line %d + +Warning: Missing argument 1 for (), called in %s on line %d and defined in %s on line %d +NULL + +Catchable fatal error: Argument 1 passed to test() must be an instance of Closure, instance of stdClass given, called in %s on line %d and defined in %s on line %d diff --git a/Zend/tests/closure_028.phpt b/Zend/tests/closure_028.phpt new file mode 100644 index 0000000000..35840755da --- /dev/null +++ b/Zend/tests/closure_028.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 028: Trying to use lambda directly in foreach +--FILE-- + +--EXPECT-- +ok diff --git a/Zend/tests/closure_029.phpt b/Zend/tests/closure_029.phpt new file mode 100644 index 0000000000..8d909c0256 --- /dev/null +++ b/Zend/tests/closure_029.phpt @@ -0,0 +1,14 @@ +--TEST-- +Closure 029: Testing lambda with instanceof operator +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/Zend/tests/closure_030.phpt b/Zend/tests/closure_030.phpt new file mode 100644 index 0000000000..318d2150a8 --- /dev/null +++ b/Zend/tests/closure_030.phpt @@ -0,0 +1,20 @@ +--TEST-- +Closure 030: Using lambda with variable variables +--FILE-- +__invoke(2)); + +?> +--EXPECT-- +array(1) { + [0]=> + int(1) +} +array(1) { + [0]=> + int(2) +} diff --git a/Zend/tests/list_007.phpt b/Zend/tests/list_007.phpt new file mode 100644 index 0000000000..35a25bce65 --- /dev/null +++ b/Zend/tests/list_007.phpt @@ -0,0 +1,13 @@ +--TEST-- +Using lambda with list() +--FILE-- + +--EXPECT-- +NULL +NULL diff --git a/Zend/tests/objects_031.phpt b/Zend/tests/objects_031.phpt new file mode 100644 index 0000000000..0bf2182098 --- /dev/null +++ b/Zend/tests/objects_031.phpt @@ -0,0 +1,28 @@ +--TEST-- +Cloning stdClass +--FILE-- +a = 1; + +var_dump($x); + +?> +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (1) { + ["a"]=> + int(1) + } + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + object(stdClass)#%d (0) { + } +}