source: src/router/php7/Zend/tests/compound_assign_failure.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 6 weeks ago

update php

File size: 2.6 KB
Line 
1--TEST--
2Behavior of failing compound assignment
3--INI--
4opcache.optimization_level=0
5--FILE--
6<?php
7
8try {
9        $a = 1;
10        $a %= 0;
11} catch (Error $e) { var_dump($a); }
12
13try {
14        $a = 1;
15        $a >>= -1;
16} catch (Error $e) { var_dump($a); }
17
18try {
19        $a = 1;
20        $a <<= -1;
21} catch (Error $e) { var_dump($a); }
22
23set_error_handler(function($type, $msg) { throw new Exception($msg); });
24
25try {
26        $a = [];
27        $a .= "foo";
28} catch (Throwable $e) { var_dump($a); }
29
30try {
31        $a = "foo";
32        $a .= [];
33} catch (Throwable $e) { var_dump($a); }
34
35$x = new stdClass;
36try { $x += 1; }
37catch (Exception $e) {}
38var_dump($x);
39
40$x = 1;
41try { $x += new stdClass; }
42catch (Exception $e) {}
43var_dump($x);
44
45$x = new stdClass;
46try { $x -= 1; }
47catch (Exception $e) {}
48var_dump($x);
49
50$x = 1;
51try { $x -= new stdClass; }
52catch (Exception $e) {}
53var_dump($x);
54
55$x = new stdClass;
56try { $x *= 1; }
57catch (Exception $e) {}
58var_dump($x);
59
60$x = 1;
61try { $x *= new stdClass; }
62catch (Exception $e) {}
63var_dump($x);
64
65$x = new stdClass;
66try { $x /= 1; }
67catch (Exception $e) {}
68var_dump($x);
69
70$x = 1;
71try { $x /= new stdClass; }
72catch (Exception $e) {}
73var_dump($x);
74
75$x = new stdClass;
76try { $x %= 1; }
77catch (Exception $e) {}
78var_dump($x);
79
80$x = 1;
81try { $x %= new stdClass; }
82catch (Exception $e) {}
83var_dump($x);
84
85$x = new stdClass;
86try { $x **= 1; }
87catch (Exception $e) {}
88var_dump($x);
89
90$x = 1;
91try { $x **= new stdClass; }
92catch (Exception $e) {}
93var_dump($x);
94
95$x = new stdClass;
96try { $x ^= 1; }
97catch (Exception $e) {}
98var_dump($x);
99
100$x = 1;
101try { $x ^= new stdClass; }
102catch (Exception $e) {}
103var_dump($x);
104
105$x = new stdClass;
106try { $x &= 1; }
107catch (Exception $e) {}
108var_dump($x);
109
110$x = 1;
111try { $x &= new stdClass; }
112catch (Exception $e) {}
113var_dump($x);
114
115$x = new stdClass;
116try { $x |= 1; }
117catch (Exception $e) {}
118var_dump($x);
119
120$x = 1;
121try { $x |= new stdClass; }
122catch (Exception $e) {}
123var_dump($x);
124
125$x = new stdClass;
126try { $x <<= 1; }
127catch (Exception $e) {}
128var_dump($x);
129
130$x = 1;
131try { $x <<= new stdClass; }
132catch (Exception $e) {}
133var_dump($x);
134
135$x = new stdClass;
136try { $x >>= 1; }
137catch (Exception $e) {}
138var_dump($x);
139
140$x = 1;
141try { $x >>= new stdClass; }
142catch (Exception $e) {}
143var_dump($x);
144?>
145--EXPECTF--
146int(1)
147int(1)
148int(1)
149array(0) {
150}
151string(3) "foo"
152object(stdClass)#%d (0) {
153}
154int(1)
155object(stdClass)#%d (0) {
156}
157int(1)
158object(stdClass)#%d (0) {
159}
160int(1)
161object(stdClass)#%d (0) {
162}
163int(1)
164object(stdClass)#%d (0) {
165}
166int(1)
167object(stdClass)#%d (0) {
168}
169int(1)
170object(stdClass)#%d (0) {
171}
172int(1)
173object(stdClass)#%d (0) {
174}
175int(1)
176object(stdClass)#%d (0) {
177}
178int(1)
179object(stdClass)#%d (0) {
180}
181int(1)
182object(stdClass)#%d (0) {
183}
184int(1)
Note: See TracBrowser for help on using the repository browser.