Skip to content

Commit

Permalink
#1991 - Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Apr 6, 2021
1 parent 55e8c66 commit 1e017a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stub/returns.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ namespace Stub;

class Returns
{
protected stringDefaultNull = null;

public function testReturnCast1() -> int
{
return (int) 5.0;
Expand Down Expand Up @@ -36,4 +38,12 @@ class Returns
{
return "Return back";
}

/**
* @issue https://github.com/zephir-lang/zephir/issues/1991
*/
public function returnNullOnString() -> string
{
return this->stringDefaultNull;
}
}
12 changes: 12 additions & 0 deletions tests/Extension/ReturnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@ public function testShouldReturnWithoutParameterStaticVersion(): void
{
$this->assertSame('Return back', Returns::returnWithoutParameter());
}

/**
* @issue https://github.com/zephir-lang/zephir/issues/1991
*/
public function testIssue1991ShouldThrow(): void
{
$tester = new Returns();

$this->expectException(\TypeError::class);

$tester->returnNullOnString();
}
}

0 comments on commit 1e017a3

Please sign in to comment.