Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 226b92b

Browse files
juliend2iluuu1994
authored andcommitted
Nested match expression tests
Closes GH-12433
1 parent 6b73fcc commit 226b92b

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

‎Zend/tests/match/046.phpt‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Nested match expressions
3+
--FILE--
4+
<?php
5+
6+
// Nested in return expression:
7+
$b = 'b';
8+
echo match($b) {
9+
'a' => 1,
10+
'b' => match (1) {
11+
strpos('ab', $b) => 100,
12+
default => 15
13+
},
14+
default => 4
15+
};
16+
17+
echo "\n";
18+
19+
// Nested in condition expression:
20+
$c = 'c';
21+
echo match($c) {
22+
'foo' => 'bar',
23+
match ($c) { default => 'c' } => 300
24+
};
25+
26+
echo "\n";
27+
28+
// Nested in one of many condition expressions:
29+
$d = 'd';
30+
echo match($d) {
31+
'foo' => 'bar',
32+
match ($d) { default => 'd' },
33+
match ($d) { default => 'e' } => 500
34+
};
35+
36+
37+
?>
38+
--EXPECT--
39+
100
40+
300
41+
500

‎Zend/tests/match/047.phpt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Match expression inside subject expression
3+
--FILE--
4+
<?php
5+
6+
echo match (match ('b') { default => 'b' }) {
7+
'a' => 100,
8+
'b' => 200,
9+
'c' => 300
10+
};
11+
12+
?>
13+
--EXPECT--
14+
200

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /