123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- --TEST--
- GC 038: Garbage created by compound assignment operators (e.g. +=)
- --INI--
- zend.enable_gc = 1
- --FILE--
- <?php
- function test_add() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x += 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "+=\t$n\n";
- }
- test_add();
- function test_sub() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x -= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "-=\t$n\n";
- }
- test_sub();
- function test_mul() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x *= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "*=\t$n\n";
- }
- test_mul();
- function test_div() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x /= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "/=\t$n\n";
- }
- test_div();
- function test_mod() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x %= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "%=\t$n\n";
- }
- test_mod();
- function test_sl() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x <<= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "<<=\t$n\n";
- }
- test_sl();
- function test_sr() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x >>= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo ">>=\t$n\n";
- }
- test_sr();
- function test_or() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x |= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "|=\t$n\n";
- }
- test_or();
- function test_and() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x &= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "&=\t$n\n";
- }
- test_and();
- function test_xor() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x ^= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "^=\t$n\n";
- }
- test_xor();
- function test_pow() {
- $x = new stdClass;
- $x->x = $x;
- try {
- $x **= 5;
- } catch (TypeError $e) { unset($x); }
- $n = gc_collect_cycles();
- echo "**=\t$n\n";
- }
- test_pow();
- class Y {
- function __toString() {
- return "y";
- }
- }
- function test_concat() {
- $x = new Y;
- $x->x= $x;
- @$x .= "x";
- $n = gc_collect_cycles();
- echo ".=\t$n\n";
- }
- test_concat();
- ?>
- --EXPECTF--
- += 1
- -= 1
- *= 1
- /= 1
- %= 1
- <<= 1
- >>= 1
- |= 1
- &= 1
- ^= 1
- **= 1
- .= 1
|