From 1e017a3aa01523915c81d8c205e2d11138045509 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Tue, 6 Apr 2021 07:58:52 +0100 Subject: [PATCH] #1991 - Add failing test case --- stub/returns.zep | 10 ++++++++++ tests/Extension/ReturnsTest.php | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/stub/returns.zep b/stub/returns.zep index 702930d261..17a2ec9a5f 100644 --- a/stub/returns.zep +++ b/stub/returns.zep @@ -3,6 +3,8 @@ namespace Stub; class Returns { + protected stringDefaultNull = null; + public function testReturnCast1() -> int { return (int) 5.0; @@ -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; + } } diff --git a/tests/Extension/ReturnsTest.php b/tests/Extension/ReturnsTest.php index 43c052d98d..d2da1ed39f 100644 --- a/tests/Extension/ReturnsTest.php +++ b/tests/Extension/ReturnsTest.php @@ -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(); + } }