]> granicus.if.org Git - php/commitdiff
New tests for memory leaks
authorDmitry Stogov <dmitry@php.net>
Fri, 19 Dec 2003 15:08:56 +0000 (15:08 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 19 Dec 2003 15:08:56 +0000 (15:08 +0000)
tests/classes/assign_op_property_001.phpt [new file with mode: 0644]
tests/classes/incdec_property_001.phpt [new file with mode: 0644]
tests/classes/incdec_property_002.phpt [new file with mode: 0644]
tests/classes/incdec_property_003.phpt [new file with mode: 0644]
tests/classes/incdec_property_004.phpt [new file with mode: 0644]

diff --git a/tests/classes/assign_op_property_001.phpt b/tests/classes/assign_op_property_001.phpt
new file mode 100644 (file)
index 0000000..54e519e
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ZE2 assign_op property of overloaded object
+--FILE--
+<?php 
+
+class Test {
+       private $real_a = 2;
+       
+       function __set($property, $value) {
+         if ($property = "a") {
+           $this->real_a = $value;
+         }
+       }
+
+       function __get($property) {
+         if ($property = "a") {
+           return $this->real_a;
+         }
+       }
+}
+
+$obj = new Test;
+var_dump($obj->a);
+$obj->a += 2;
+var_dump($obj->a);
+echo "---Done---\n";
+?>
+--EXPECT--
+int(2)
+int(4)
+---Done---
diff --git a/tests/classes/incdec_property_001.phpt b/tests/classes/incdec_property_001.phpt
new file mode 100644 (file)
index 0000000..39bf06f
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ZE2 post increment/decrement property of overloaded object
+--FILE--
+<?php 
+
+class Test {
+       private $real_a = 2;
+       
+       function __set($property, $value) {
+         if ($property = "a") {
+           $this->real_a = $value;
+         }
+       }
+
+       function __get($property) {
+         if ($property = "a") {
+           return $this->real_a;
+         }
+       }
+}
+
+$obj = new Test;
+var_dump($obj->a);
+$obj->a++;
+var_dump($obj->a);
+echo "---Done---\n";
+?>
+--EXPECT--
+int(2)
+int(3)
+---Done---
diff --git a/tests/classes/incdec_property_002.phpt b/tests/classes/incdec_property_002.phpt
new file mode 100644 (file)
index 0000000..fe08625
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ZE2 post increment/decrement property of overloaded object with assignment
+--FILE--
+<?php 
+
+class Test {
+       private $real_a = 2;
+       
+       function __set($property, $value) {
+         if ($property = "a") {
+           $this->real_a = $value;
+         }
+       }
+
+       function __get($property) {
+         if ($property = "a") {
+           return $this->real_a;
+         }
+       }
+}
+
+$obj = new Test;
+var_dump($obj->a);
+$t1 = $obj->a++;
+var_dump($obj->a);
+echo "---Done---\n";
+?>
+--EXPECT--
+int(2)
+int(3)
+---Done---
diff --git a/tests/classes/incdec_property_003.phpt b/tests/classes/incdec_property_003.phpt
new file mode 100644 (file)
index 0000000..d26277a
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ZE2 pre increment/decrement property of overloaded object
+--FILE--
+<?php 
+
+class Test {
+       private $real_a = 2;
+       
+       function __set($property, $value) {
+         if ($property = "a") {
+           $this->real_a = $value;
+         }
+       }
+
+       function __get($property) {
+         if ($property = "a") {
+           return $this->real_a;
+         }
+       }
+}
+
+$obj = new Test;
+var_dump($obj->a);
+++$obj->a;
+var_dump($obj->a);
+echo "---Done---\n";
+?>
+--EXPECT--
+int(2)
+int(3)
+---Done---
diff --git a/tests/classes/incdec_property_004.phpt b/tests/classes/incdec_property_004.phpt
new file mode 100644 (file)
index 0000000..5ccad19
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+ZE2 pre increment/decrement property of overloaded object with assignment
+--FILE--
+<?php 
+
+class Test {
+       private $real_a = 2;
+       
+       function __set($property, $value) {
+         if ($property = "a") {
+           $this->real_a = $value;
+         }
+       }
+
+       function __get($property) {
+         if ($property = "a") {
+           return $this->real_a;
+         }
+       }
+}
+
+$obj = new Test;
+var_dump($obj->a);
+$t1 = ++$obj->a;
+var_dump($obj->a);
+echo "---Done---\n";
+?>
+--EXPECT--
+int(2)
+int(3)
+---Done---