Skip to content

Commit

Permalink
Add tests for a variety of callables
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 27, 2024
1 parent c016b6c commit 725e453
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/test/php/lang/ast/unittest/emit/PipelinesTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,53 @@ public function run() {
Assert::equals('TEST', $r);
}

#[Test]
public function pipe_to_variable() {
$r= $this->run('class %T {
public function run() {
$f= strtoupper(...);
return "test" |> $f;
}
}');

Assert::equals('TEST', $r);
}

#[Test]
public function pipe_to_callable_string() {
$r= $this->run('class %T {
public function run() {
return "test" |> "strtoupper";
}
}');

Assert::equals('TEST', $r);
}

#[Test]
public function pipe_to_callable_array() {
$r= $this->run('class %T {
public function toUpper($x) { return strtoupper($x); }
public function run() {
return "test" |> [$this, "toUpper"];
}
}');

Assert::equals('TEST', $r);
}

#[Test]
public function pipe_to_callable_without_all_args() {
$r= $this->run('class %T {
public function run() {
return "A&B" |> htmlspecialchars(...);
}
}');

Assert::equals('A&B', $r);
}

#[Test]
public function pipe_to_callable_new() {
$r= $this->run('class %T {
Expand Down

0 comments on commit 725e453

Please sign in to comment.