Skip to content

Commit b9e10f6

Browse files
committed
Move tests to subfolder and import unique tests from HHVM
1 parent 66a6252 commit b9e10f6

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Zend/tests/pipe-op/pipe-101.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
Pipe Operator Nested expressions
3+
--FILE--
4+
<?php
5+
6+
// Imported from HackLang test: pipevar-3.php
7+
function main($bar) {
8+
$foo = "Hello!";
9+
array(1, 2, 3)
10+
|> array_map(function($x) { return $x + 1; }, $$)
11+
|> array_merge(
12+
array(50, 60, 70)
13+
|> array_map(function ($x) { return $x * 2; }, $$)
14+
|> array_filter($$, function ($x) { return $x != 100; }),
15+
$$)
16+
|> var_dump($$);
17+
18+
var_dump($foo);
19+
var_dump($bar);
20+
}
21+
22+
main("Goodbye");
23+
24+
--EXPECT--
25+
array(5) {
26+
[0]=>
27+
int(120)
28+
[1]=>
29+
int(140)
30+
[2]=>
31+
int(2)
32+
[3]=>
33+
int(3)
34+
[4]=>
35+
int(4)
36+
}
37+
string(6) "Hello!"
38+
string(7) "Goodbye"
39+

Zend/tests/pipe-op/pipe-102.phpt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
--TEST--
2+
Pipe Operator Operation Ordering
3+
--FILE--
4+
<?php
5+
6+
// Imported from HackLang test: pipevar-4.php
7+
8+
class Wrapper {
9+
public $val;
10+
public function __construct(array $val) {
11+
$this->val = $val;
12+
var_dump("Make wrapper");
13+
}
14+
public function __destruct() {
15+
var_dump("Destroy wrapper");
16+
}
17+
}
18+
19+
function beep($x) {
20+
if ($x instanceof Wrapper) {
21+
var_dump("beep: <Wrapper>");
22+
} else if (is_array($x)) {
23+
var_dump("beep: <array>");
24+
} else {
25+
var_dump("beep: ".$x);
26+
}
27+
return $x;
28+
}
29+
function wrap($x) {
30+
return new Wrapper($x);
31+
}
32+
function unwrap($y) {
33+
return $y->val;
34+
}
35+
36+
function main($bar) {
37+
$foo = "Hello!";
38+
$out = array(1, 2, 3)
39+
|> array_map(function ($x) { return $x + beep(1); }, $$)
40+
|> array_merge(
41+
array(50, 60, 70)
42+
|> array_map(function ($x) { return $x * beep(2); }, $$)
43+
|> array_filter($$, function ($x) { return $x != beep(100); }),
44+
$$)
45+
|> array_filter($$, function ($x) { return $x != beep(3); })
46+
|> wrap($$)
47+
|> beep($$)
48+
|> unwrap($$)
49+
|> beep($$)
50+
|> array_map(function ($x) { return "STR: $x"; }, $$);
51+
52+
var_dump($foo);
53+
var_dump($out);
54+
var_dump($bar);
55+
}
56+
57+
main("Goodbye");
58+
59+
--EXPECT--
60+
string(7) "beep: 1"
61+
string(7) "beep: 1"
62+
string(7) "beep: 1"
63+
string(7) "beep: 2"
64+
string(7) "beep: 2"
65+
string(7) "beep: 2"
66+
string(9) "beep: 100"
67+
string(9) "beep: 100"
68+
string(9) "beep: 100"
69+
string(7) "beep: 3"
70+
string(7) "beep: 3"
71+
string(7) "beep: 3"
72+
string(7) "beep: 3"
73+
string(7) "beep: 3"
74+
string(12) "Make wrapper"
75+
string(15) "beep: <Wrapper>"
76+
string(15) "Destroy wrapper"
77+
string(13) "beep: <array>"
78+
string(6) "Hello!"
79+
array(4) {
80+
[0]=>
81+
string(8) "STR: 120"
82+
[1]=>
83+
string(8) "STR: 140"
84+
[2]=>
85+
string(6) "STR: 2"
86+
[4]=>
87+
string(6) "STR: 4"
88+
}
89+
string(7) "Goodbye"
90+

0 commit comments

Comments
 (0)