Skip to content

Commit

Permalink
Merge pull request #2430 from zephir-lang/#2396-default
Browse files Browse the repository at this point in the history
#2396 - Add test cases with default param value
  • Loading branch information
Jeckerson authored Jun 2, 2024
2 parents cb1359a + 02d088e commit d02af51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions stub/oo/ooparams.zep
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,19 @@ class OoParams
{
return parameter;
}

public function getDefaultParamValue(int i = 0)
{
return i;
}

public function getDefaultParamValue1(int i = 1)
{
return i;
}

public function getDefaultParamValueStr(string str = "default")
{
return str;
}
}
4 changes: 4 additions & 0 deletions tests/Extension/Oo/OoParamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public function testOoParams(): void

$this->assertSame($this->test->setList([1, 2, 3, 4, 5]), [1, 2, 3, 4, 5]);
$this->assertSame($this->test->setList([]), []);

$this->assertSame(0, $this->test->getDefaultParamValue());
$this->assertSame(1, $this->test->getDefaultParamValue1());
$this->assertSame('default', $this->test->getDefaultParamValueStr());
}

public function setObjectClassCast(): void
Expand Down

0 comments on commit d02af51

Please # to comment.