Skip to content

Commit 5f8f3e1

Browse files
committed
wip
1 parent ad6564d commit 5f8f3e1

20 files changed

+949
-613
lines changed

Zend/tests/match/block_arg_return.phpt

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
Match expression block must not use return
33
--FILE--
44
<?php
5-
foo(match (1) {
6-
1 => { return; }
7-
});
5+
function test() {
6+
var_dump(match (1) {
7+
1 => { return; }
8+
});
9+
echo 'Unreached';
10+
}
11+
test();
812
?>
9-
--EXPECTF--
10-
Fatal error: Match expression whose result is used must not contain return, break, continue or goto in %s on line %d
13+
===DONE===
14+
--EXPECT--
15+
===DONE===

Zend/tests/match/block_expr_break_escape.phpt

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
Match expression block must not use break
33
--FILE--
44
<?php
5-
var_dump(match ($value) {
6-
1 => { break; },
7-
});
5+
function test() {
6+
str_repeat('a', 10) . match (1) {
7+
1 => { return; },
8+
};
9+
}
10+
11+
test();
812
?>
9-
--EXPECTF--
10-
Fatal error: Match expression whose result is used must not contain return, break, continue or goto in %s on line %d
13+
===DONE===
14+
--EXPECT--
15+
===DONE===

Zend/tests/match/block_expr_goto_escape.phpt

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ var_dump(match (1) {
99
});
1010
after:
1111
?>
12-
--EXPECTF--
13-
Fatal error: Match expression whose result is used must not contain return, break, continue or goto in %s on line %d
12+
===DONE===
13+
--EXPECT--
14+
===DONE===

Zend/tests/match/block_expr_return.phpt

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
Match expression block must not use return
33
--FILE--
44
<?php
5-
var_dump(match ($value) {
6-
1 => { return; },
7-
});
5+
6+
function test($a) {
7+
var_dump([$a] + match ($a) {
8+
42 => { return $a; },
9+
});
10+
}
11+
12+
var_dump(test(42));
13+
814
?>
9-
--EXPECTF--
10-
Fatal error: Match expression whose result is used must not contain return, break, continue or goto in %s on line %d
15+
--EXPECT--
16+
int(42)

Zend/tests/match/bugs/001.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
foreach ([1, 2, 3] as $value) {
8+
$x = match (1) {
9+
1 => { return 42; },
10+
};
11+
var_dump($value);
12+
}
13+
throw new Exception('Unreachable');
14+
}
15+
16+
var_dump(test());
17+
18+
?>
19+
--EXPECT--
20+
int(42)

Zend/tests/match/bugs/002.phpt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
foreach ([1, 2, 3] as $value) {
8+
$x = match (1) {
9+
1 => { continue 2; },
10+
};
11+
var_dump($value);
12+
}
13+
return 42;
14+
}
15+
16+
var_dump(test());
17+
18+
?>
19+
--EXPECT--
20+
int(42)

Zend/tests/match/bugs/003.phpt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
foreach ([1, 2, 3] as $value) {
8+
str_repeat('a', 10) . match (1) {
9+
1 => {
10+
try {
11+
return 42;
12+
} finally {}
13+
},
14+
};
15+
var_dump($value);
16+
}
17+
throw new Unreachable();
18+
}
19+
20+
var_dump(test());
21+
22+
?>
23+
--EXPECT--
24+
int(42)

Zend/tests/match/bugs/004.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
return str_repeat('a', 10) . match (1) {
8+
1 => {
9+
try {
10+
try {
11+
return 41;
12+
} finally {
13+
throw new Exception();
14+
}
15+
} catch (Exception) {}
16+
'b'
17+
},
18+
};
19+
}
20+
21+
var_dump(test());
22+
23+
?>
24+
--EXPECT--
25+
string(11) "aaaaaaaaaab"

Zend/tests/match/bugs/005.phpt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
return str_repeat('a', 10) . match (1) {
8+
1 => {
9+
foreach (range(1, 10) as $value) {
10+
return 'foo';
11+
}
12+
'b'
13+
},
14+
};
15+
}
16+
17+
var_dump(test());
18+
19+
?>
20+
--EXPECT--
21+
string(3) "foo"

Zend/tests/match/bugs/006.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
str_repeat('a', 10) . match (1) {
8+
1 => {
9+
str_repeat('a', 10) . match (1) {
10+
1 => {
11+
return 'foo';
12+
},
13+
};
14+
},
15+
};
16+
}
17+
18+
var_dump(test());
19+
20+
?>
21+
--EXPECT--
22+
string(3) "foo"

Zend/tests/match/bugs/007.phpt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
return str_repeat('a', 10) . match (1) {
8+
1 => {
9+
try {
10+
try {
11+
return str_repeat('a', 10) . match (1) {
12+
1 => {
13+
return 'foo';
14+
},
15+
};
16+
} finally {
17+
throw new Exception();
18+
}
19+
} catch (Exception) {}
20+
'b'
21+
},
22+
};
23+
}
24+
25+
var_dump(test());
26+
27+
?>
28+
--EXPECT--
29+
string(11) "aaaaaaaaaab"

Zend/tests/match/bugs/008.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function test($x) {}
8+
}
9+
10+
function test() {
11+
(new C())->test(match (1) {
12+
1 => {
13+
return 42;
14+
}
15+
});
16+
}
17+
18+
var_dump(test());
19+
20+
?>
21+
--EXPECT--
22+
int(42)

Zend/tests/match/bugs/009.phpt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function test($x) {
8+
return $x;
9+
}
10+
}
11+
12+
function test() {
13+
return (new C())->test(match (1) {
14+
1 => {
15+
try {
16+
throw new Exception();
17+
} catch (Exception) {}
18+
42
19+
}
20+
});
21+
}
22+
23+
var_dump(test());
24+
25+
?>
26+
--EXPECT--
27+
int(42)

0 commit comments

Comments
 (0)