xref: /PHP-7.4/Zend/tests/gc_038.phpt (revision d679f022)
1--TEST--
2GC 038: Garbage created by compound assignment operators (e.g. +=)
3--INI--
4zend.enable_gc = 1
5--FILE--
6<?php
7function test_add() {
8	$x = new stdClass;
9	$x->x= $x;
10	@$x += 5;
11	$n = gc_collect_cycles();
12	echo "+=\t$n\n";
13}
14test_add();
15
16function test_sub() {
17	$x = new stdClass;
18	$x->x= $x;
19	@$x -= 5;
20	$n = gc_collect_cycles();
21	echo "-=\t$n\n";
22}
23test_sub();
24
25function test_mul() {
26	$x = new stdClass;
27	$x->x= $x;
28	@$x *= 5;
29	$n = gc_collect_cycles();
30	echo "*=\t$n\n";
31}
32test_mul();
33
34function test_div() {
35	$x = new stdClass;
36	$x->x= $x;
37	@$x /= 5;
38	$n = gc_collect_cycles();
39	echo "/=\t$n\n";
40}
41test_div();
42
43function test_mod() {
44	$x = new stdClass;
45	$x->x= $x;
46	@$x %= 5;
47	$n = gc_collect_cycles();
48	echo "%=\t$n\n";
49}
50test_mod();
51
52function test_sl() {
53	$x = new stdClass;
54	$x->x= $x;
55	@$x <<= 5;
56	$n = gc_collect_cycles();
57	echo "<<=\t$n\n";
58}
59test_sl();
60
61function test_sr() {
62	$x = new stdClass;
63	$x->x= $x;
64	@$x >>= 5;
65	$n = gc_collect_cycles();
66	echo ">>=\t$n\n";
67}
68test_sr();
69
70function test_or() {
71	$x = new stdClass;
72	$x->x= $x;
73	@$x |= 1;
74	$n = gc_collect_cycles();
75	echo "|=\t$n\n";
76}
77test_or();
78
79function test_and() {
80	$x = new stdClass;
81	$x->x= $x;
82	@$x &= 1;
83	$n = gc_collect_cycles();
84	echo "&=\t$n\n";
85}
86test_and();
87
88function test_xor() {
89	$x = new stdClass;
90	$x->x= $x;
91	@$x ^= 1;
92	$n = gc_collect_cycles();
93	echo "^=\t$n\n";
94}
95test_xor();
96
97function test_pow() {
98	$x = new stdClass;
99	$x->x= $x;
100	@$x **= 1;
101	$n = gc_collect_cycles();
102	echo "**=\t$n\n";
103}
104test_pow();
105
106class Y {
107	function __toString() {
108		return "y";
109	}
110}
111function test_concat() {
112	$x = new Y;
113	$x->x= $x;
114	@$x .= "x";
115	$n = gc_collect_cycles();
116	echo ".=\t$n\n";
117}
118test_concat();
119?>
120--EXPECT--
121+=	1
122-=	1
123*=	1
124/=	1
125%=	1
126<<=	1
127>>=	1
128|=	1
129&=	1
130^=	1
131**=	1
132.=	1
133