com php-src: add overflowingness test: Zend/tests/type_declar ations/typed_properties_038.phpt
| From: | Bob Weinand | Date: | Tue, 05 Apr 2016 08:28:38 +0000 |
| Subject: | com php-src: add overflowingness test: Zend/tests/type_declar ations/typed_properties_038.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95584@lists.php.net to get a copy of this message | ||
Commit: 88ff051ed4429cca891cc2f534e996ff95e11fc5
Author: Joe Watkins <krakjoe@php.net> Tue, 5 Apr 2016 09:28:38 +0100
Parents: e7d8aa77b5833fe250192ebc44f378ac418dc037
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=88ff051ed4429cca891cc2f534e996ff95e11fc5
Log:
add overflowingness test
Changed paths:
A Zend/tests/type_declarations/typed_properties_038.phpt
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_038.phpt
b/Zend/tests/type_declarations/typed_properties_038.phpt
new file mode 100644
index 0000000..9673d41
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_038.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Test typed properties overflowing
+--FILE--
+<?php
+$foo = new class {
+ public int $bar = PHP_INT_MAX;
+};
+
+try {
+ $foo->bar++;
+} catch(TypeError $t) {
+ var_dump($t->getMessage());
+}
+
+var_dump($foo);
+
+try {
+ $foo->bar += 1;
+} catch(TypeError $t) {
+ var_dump($t->getMessage());
+}
+
+var_dump($foo);
+
+try {
+ ++$foo->bar;
+} catch(TypeError $t) {
+ var_dump($t->getMessage());
+}
+
+var_dump($foo);
+
+try {
+ $foo->bar = $foo->bar + 1;
+} catch(TypeError $t) {
+ var_dump($t->getMessage());
+}
+
+var_dump($foo);
+--EXPECTF--
+string(64) "Typed property class@anonymous::$bar must be integer, float used"
+object(class@anonymous)#%d (%d) {
+ ["bar"]=>
+ int(%d)
+}
+string(64) "Typed property class@anonymous::$bar must be integer, float used"
+object(class@anonymous)#%d (%d) {
+ ["bar"]=>
+ int(%d)
+}
+string(64) "Typed property class@anonymous::$bar must be integer, float used"
+object(class@anonymous)#%d (%d) {
+ ["bar"]=>
+ int(%d)
+}
+string(64) "Typed property class@anonymous::$bar must be integer, float used"
+object(class@anonymous)#%d (%d) {
+ ["bar"]=>
+ int(%d)
+}