Skip to content

Commit a0e68a1

Browse files
committed
Add match long jump table test
1 parent c0cd669 commit a0e68a1

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

Zend/tests/match/019.phpt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
--TEST--
2+
Match expression long jump table
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.opt_debug_level=0x20000
7+
--SKIPIF--
8+
<?php if (!extension_loaded('Zend OPcache')) die('skip Zend OPcache extension not available'); ?>
9+
--FILE--
10+
<?php
11+
12+
function test($char) {
13+
return match ($char) {
14+
1 => '1',
15+
2, 3 => '2, 3',
16+
4 => '4',
17+
5, 6 => '5, 6',
18+
7 => '7',
19+
8, 9 => '8, 9',
20+
default => 'default'
21+
};
22+
}
23+
24+
foreach (range(0, 10) as $char) {
25+
var_dump(test($char));
26+
}
27+
28+
--EXPECTF--
29+
$_main:
30+
; (lines=15, args=0, vars=1, tmps=2)
31+
; (after optimizer)
32+
; %s
33+
0000 INIT_FCALL 2 %d string("range")
34+
0001 SEND_VAL int(0) 1
35+
0002 SEND_VAL int(10) 2
36+
0003 V2 = DO_ICALL
37+
0004 V1 = FE_RESET_R V2 0013
38+
0005 FE_FETCH_R V1 CV0($char) 0013
39+
0006 INIT_FCALL 1 %d string("var_dump")
40+
0007 INIT_FCALL 1 %d string("test")
41+
0008 SEND_VAR CV0($char) 1
42+
0009 V2 = DO_UCALL
43+
0010 SEND_VAR V2 1
44+
0011 DO_ICALL
45+
0012 JMP 0005
46+
0013 FE_FREE V1
47+
0014 RETURN int(1)
48+
LIVE RANGES:
49+
1: 0005 - 0013 (loop)
50+
51+
test:
52+
; (lines=27, args=1, vars=1, tmps=1)
53+
; (after optimizer)
54+
; %s
55+
0000 CV0($char) = RECV 1
56+
0001 MATCH_LONG CV0($char) 1: 0020, 2: 0021, 3: 0021, 4: 0022, 5: 0023, 6: 0023, 7: 0024, 8: 0025, 9: 0025, default: 0026
57+
0002 T1 = IS_IDENTICAL CV0($char) int(1)
58+
0003 JMPNZ T1 0020
59+
0004 T1 = IS_IDENTICAL CV0($char) int(2)
60+
0005 JMPNZ T1 0021
61+
0006 T1 = IS_IDENTICAL CV0($char) int(3)
62+
0007 JMPNZ T1 0021
63+
0008 T1 = IS_IDENTICAL CV0($char) int(4)
64+
0009 JMPNZ T1 0022
65+
0010 T1 = IS_IDENTICAL CV0($char) int(5)
66+
0011 JMPNZ T1 0023
67+
0012 T1 = IS_IDENTICAL CV0($char) int(6)
68+
0013 JMPNZ T1 0023
69+
0014 T1 = IS_IDENTICAL CV0($char) int(7)
70+
0015 JMPNZ T1 0024
71+
0016 T1 = IS_IDENTICAL CV0($char) int(8)
72+
0017 JMPNZ T1 0025
73+
0018 T1 = IS_IDENTICAL CV0($char) int(9)
74+
0019 JMPZNZ T1 0026 0025
75+
0020 RETURN string("1")
76+
0021 RETURN string("2, 3")
77+
0022 RETURN string("4")
78+
0023 RETURN string("5, 6")
79+
0024 RETURN string("7")
80+
0025 RETURN string("8, 9")
81+
0026 RETURN string("default")
82+
string(7) "default"
83+
string(1) "1"
84+
string(4) "2, 3"
85+
string(4) "2, 3"
86+
string(1) "4"
87+
string(4) "5, 6"
88+
string(4) "5, 6"
89+
string(1) "7"
90+
string(4) "8, 9"
91+
string(4) "8, 9"
92+
string(7) "default"

0 commit comments

Comments
 (0)