summaryrefslogtreecommitdiff
path: root/Zend/tests
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-03-31 13:25:26 +0300
committerDmitry Stogov <dmitry@zend.com>2015-03-31 13:25:26 +0300
commite8672deefc9e7fdddff0444b0bfce3e5e20b163e (patch)
treee096044aa21f1d4f12bdc666a85d71e4c450051f /Zend/tests
parentf9d1a47f24f4f702edeed3be372ecf60d3b2b11e (diff)
downloadphp-git-e8672deefc9e7fdddff0444b0bfce3e5e20b163e.tar.gz
Convert "Unsupported operands" fatal error into EngineException (exceptions can't be thrown at compile-time yet, so unsuported operands in constant expressions are still lead to fatal error).
Diffstat (limited to 'Zend/tests')
-rw-r--r--Zend/tests/add_002.phpt10
-rw-r--r--Zend/tests/add_003.phpt10
-rw-r--r--Zend/tests/add_004.phpt8
-rw-r--r--Zend/tests/add_007.phpt8
-rw-r--r--Zend/tests/constant_expressions_exceptions.inc2
-rw-r--r--Zend/tests/constant_expressions_exceptions_001.phpt7
-rw-r--r--Zend/tests/constant_expressions_exceptions_002.phpt13
-rw-r--r--Zend/tests/div_002.phpt8
-rw-r--r--Zend/tests/mul_001.phpt8
-rw-r--r--Zend/tests/not_002.phpt8
-rw-r--r--Zend/tests/sub_001.phpt8
11 files changed, 90 insertions, 0 deletions
diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt
index 437ac9113a..ca3b3eb6af 100644
--- a/Zend/tests/add_002.phpt
+++ b/Zend/tests/add_002.phpt
@@ -8,12 +8,22 @@ $a = array(1,2,3);
$o = new stdclass;
$o->prop = "value";
+try {
+ var_dump($a + $o);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a + $o;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Notice: Object of class stdClass could not be converted to int in %sadd_002.php on line %d
+
+Exception: Unsupported operand types
+
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
index 4223af3f19..f0c9314b2d 100644
--- a/Zend/tests/add_003.phpt
+++ b/Zend/tests/add_003.phpt
@@ -8,12 +8,22 @@ $a = array(1,2,3);
$o = new stdclass;
$o->prop = "value";
+try {
+ var_dump($o + $a);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $o + $a;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Notice: Object of class stdClass could not be converted to int in %sadd_003.php on line %d
+
+Exception: Unsupported operand types
+
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
index 492ff31ba3..5629ed2ea4 100644
--- a/Zend/tests/add_004.phpt
+++ b/Zend/tests/add_004.phpt
@@ -5,10 +5,18 @@ adding numbers to arrays
$a = array(1,2,3);
+try {
+ var_dump($a + 5);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a + 5;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d
diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt
index b2f1559b7a..b7d44a8683 100644
--- a/Zend/tests/add_007.phpt
+++ b/Zend/tests/add_007.phpt
@@ -7,10 +7,18 @@ $a = array(1,2,3);
$s1 = "some string";
+try {
+ var_dump($a + $s1);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a + $s1;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d
diff --git a/Zend/tests/constant_expressions_exceptions.inc b/Zend/tests/constant_expressions_exceptions.inc
new file mode 100644
index 0000000000..2b8f3befdb
--- /dev/null
+++ b/Zend/tests/constant_expressions_exceptions.inc
@@ -0,0 +1,2 @@
+<?php
+const T = array(1,2) - array(0);
diff --git a/Zend/tests/constant_expressions_exceptions_001.phpt b/Zend/tests/constant_expressions_exceptions_001.phpt
new file mode 100644
index 0000000000..076584a569
--- /dev/null
+++ b/Zend/tests/constant_expressions_exceptions_001.phpt
@@ -0,0 +1,7 @@
+--TEST--
+Constant Expressions with unsupported operands 001
+--FILE--
+<?php
+const T = array(1,2) - array(0);
+--EXPECTF--
+Fatal error: Unsupported operand types in %sconstant_expressions_exceptions_001.php on line 2
diff --git a/Zend/tests/constant_expressions_exceptions_002.phpt b/Zend/tests/constant_expressions_exceptions_002.phpt
new file mode 100644
index 0000000000..3259483197
--- /dev/null
+++ b/Zend/tests/constant_expressions_exceptions_002.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Constant Expressions with unsupported operands 002
+--FILE--
+<?php
+try {
+ require("constant_expressions_exceptions.inc");
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
+}
+?>
+DONE
+--EXPECTF--
+Fatal error: Unsupported operand types in %sconstant_expressions_exceptions.inc on line 2
diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt
index 6ade1d9f51..b74743380c 100644
--- a/Zend/tests/div_002.phpt
+++ b/Zend/tests/div_002.phpt
@@ -6,10 +6,18 @@ dividing arrays
$a = array(1,2,3);
$b = array(1);
+try {
+ var_dump($a / $b);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a / $b;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d
diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt
index 4c5a75e7d1..2a827af74f 100644
--- a/Zend/tests/mul_001.phpt
+++ b/Zend/tests/mul_001.phpt
@@ -6,10 +6,18 @@ multiplying arrays
$a = array(1,2,3);
$b = array(1);
+try {
+ var_dump($a * $b);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a * $b;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d
diff --git a/Zend/tests/not_002.phpt b/Zend/tests/not_002.phpt
index df27772a73..4c9be5befa 100644
--- a/Zend/tests/not_002.phpt
+++ b/Zend/tests/not_002.phpt
@@ -6,10 +6,18 @@ bitwise NOT and arrays
$a = array(1,2,3);
$b = array(1,2);
+try {
+ var_dump(~$b);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$a = ~$b;
var_dump($a);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d
diff --git a/Zend/tests/sub_001.phpt b/Zend/tests/sub_001.phpt
index 2a8b3cdffd..a9438fdcde 100644
--- a/Zend/tests/sub_001.phpt
+++ b/Zend/tests/sub_001.phpt
@@ -6,10 +6,18 @@ subtracting arrays
$a = array(1,2,3);
$b = array(1);
+try {
+ var_dump($a - $b);
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
+
$c = $a - $b;
var_dump($c);
echo "Done\n";
?>
--EXPECTF--
+Exception: Unsupported operand types
+
Fatal error: Unsupported operand types in %s on line %d