Skip to content

Commit 9915924

Browse files
committed
Add tests for pipe optimizations.
1 parent ba646f5 commit 9915924

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
--TEST--
2+
Pipe operator optimizes away most callables
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.opt_debug_level=0x20000
7+
--EXTENSIONS--
8+
opcache
9+
--FILE--
10+
<?php
11+
12+
function _test1(int $a): int {
13+
return $a + 1;
14+
}
15+
16+
class Other {
17+
public function foo(int $a): int {
18+
return $a * 2;
19+
}
20+
21+
public static function bar(int $a): int {
22+
return $a -1;
23+
}
24+
}
25+
26+
$o = new Other();
27+
28+
$res1 = 5
29+
|> _test1(...)
30+
|> $o->foo(...)
31+
|> Other::bar(...)
32+
;
33+
34+
var_dump($res1);
35+
?>
36+
--EXPECTF--
37+
$_main:
38+
; (lines=18, args=0, vars=2, tmps=2)
39+
; (after optimizer)
40+
; %s:1-27
41+
0000 V2 = NEW 0 string("Other")
42+
0001 DO_FCALL
43+
0002 ASSIGN CV0($o) V2
44+
0003 INIT_FCALL 1 112 string("_test1")
45+
0004 SEND_VAL int(5) 1
46+
0005 T2 = DO_UCALL
47+
0006 INIT_METHOD_CALL 1 CV0($o) string("foo")
48+
0007 SEND_VAL_EX T2 1
49+
0008 V3 = DO_FCALL
50+
0009 T2 = QM_ASSIGN V3
51+
0010 INIT_STATIC_METHOD_CALL 1 string("Other") string("bar")
52+
0011 SEND_VAL T2 1
53+
0012 V2 = DO_UCALL
54+
0013 ASSIGN CV1($res1) V2
55+
0014 INIT_FCALL 1 96 string("var_dump")
56+
0015 SEND_VAR CV1($res1) 1
57+
0016 DO_ICALL
58+
0017 RETURN int(1)
59+
LIVE RANGES:
60+
2: 0001 - 0002 (new)
61+
2: 0010 - 0011 (tmp/var)
62+
63+
_test1:
64+
; (lines=4, args=1, vars=1, tmps=1)
65+
; (after optimizer)
66+
; %s:3-5
67+
0000 CV0($a) = RECV 1
68+
0001 T1 = ADD CV0($a) int(1)
69+
0002 VERIFY_RETURN_TYPE T1
70+
0003 RETURN T1
71+
72+
Other::foo:
73+
; (lines=4, args=1, vars=1, tmps=1)
74+
; (after optimizer)
75+
; %s:8-10
76+
0000 CV0($a) = RECV 1
77+
0001 T1 = ADD CV0($a) CV0($a)
78+
0002 VERIFY_RETURN_TYPE T1
79+
0003 RETURN T1
80+
81+
Other::bar:
82+
; (lines=4, args=1, vars=1, tmps=1)
83+
; (after optimizer)
84+
; %s:12-14
85+
0000 CV0($a) = RECV 1
86+
0001 T1 = SUB CV0($a) int(1)
87+
0002 VERIFY_RETURN_TYPE T1
88+
0003 RETURN T1
89+
int(11)

0 commit comments

Comments
 (0)