From de758769d3cf4d3f7d56cf1aae54a36d9af81461 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 28 Jul 2008 14:09:00 +0000 Subject: [PATCH] - New tests --- Zend/tests/036.phpt | 13 ++++++++++ Zend/tests/037.phpt | 19 +++++++++++++++ Zend/tests/038.phpt | 12 ++++++++++ Zend/tests/closure_024.phpt | 16 +++++++++++++ Zend/tests/closure_025.phpt | 12 ++++++++++ Zend/tests/closure_026.phpt | 47 +++++++++++++++++++++++++++++++++++++ Zend/tests/closure_027.phpt | 31 ++++++++++++++++++++++++ Zend/tests/closure_028.phpt | 14 +++++++++++ Zend/tests/closure_029.phpt | 14 +++++++++++ Zend/tests/closure_030.phpt | 20 ++++++++++++++++ Zend/tests/list_007.phpt | 13 ++++++++++ Zend/tests/objects_031.phpt | 28 ++++++++++++++++++++++ 12 files changed, 239 insertions(+) create mode 100644 Zend/tests/036.phpt create mode 100644 Zend/tests/037.phpt create mode 100644 Zend/tests/038.phpt create mode 100644 Zend/tests/closure_024.phpt create mode 100644 Zend/tests/closure_025.phpt create mode 100644 Zend/tests/closure_026.phpt create mode 100644 Zend/tests/closure_027.phpt create mode 100644 Zend/tests/closure_028.phpt create mode 100644 Zend/tests/closure_029.phpt create mode 100644 Zend/tests/closure_030.phpt create mode 100644 Zend/tests/list_007.phpt create mode 100644 Zend/tests/objects_031.phpt 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..235bc80514 --- /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) { + [u"a"]=> + array(1) { + [0]=> + object(Closure)#%d (0) { + } + } +} +int(1) +-------------- +unicode(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..1a62a046cb --- /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) { + [u"a"]=> + int(1) + } + [1]=> + object(stdClass)#%d (0) { + } + [2]=> + object(stdClass)#%d (0) { + } +} -- 2.40.0