@@ -32,7 +32,7 @@ public function testSimple(): void
3232 );
3333 }
3434
35- public function testSendingValues (): void
35+ public function testCompareSendingValues (): void
3636 {
3737 $ this ->compare (
3838 fn () => (function () {
@@ -50,7 +50,7 @@ public function testSendingValues(): void
5050 );
5151 }
5252
53- public function testThrowingExceptions (): void
53+ public function testCompareThrowingExceptions (): void
5454 {
5555 $ this ->compare (
5656 fn () => (function () {
@@ -71,7 +71,7 @@ public function testThrowingExceptions(): void
7171 );
7272 }
7373
74- public function testReturn (): void
74+ public function testCompareReturn (): void
7575 {
7676 $ this ->compare (
7777 fn () => (function () {
@@ -86,7 +86,7 @@ public function testReturn(): void
8686 );
8787 }
8888
89- public function testEmpty (): void
89+ public function testCompareEmpty (): void
9090 {
9191 $ this ->compare (
9292 fn () => (function () {
@@ -100,7 +100,7 @@ public function testEmpty(): void
100100 );
101101 }
102102
103- public function testEmptyReturn (): void
103+ public function testCompareEmptyReturn (): void
104104 {
105105 $ this ->compare (
106106 fn () => (function () {
@@ -115,7 +115,7 @@ public function testEmptyReturn(): void
115115 );
116116 }
117117
118- public function testEmptyThrow (): void
118+ public function testCompareEmptyThrow (): void
119119 {
120120 $ this ->compare (
121121 fn () => (function () {
@@ -126,7 +126,7 @@ public function testEmptyThrow(): void
126126 );
127127 }
128128
129- public function testEmptyThrowValid (): void
129+ public function testCompareEmptyThrowValid (): void
130130 {
131131 $ this ->compare (
132132 fn () => (function () {
@@ -137,7 +137,7 @@ public function testEmptyThrowValid(): void
137137 );
138138 }
139139
140- public function testEmptyThrowGetReturn (): void
140+ public function testCompareEmptyThrowGetReturn (): void
141141 {
142142 $ this ->compare (
143143 fn () => (function () {
@@ -148,7 +148,7 @@ public function testEmptyThrowGetReturn(): void
148148 );
149149 }
150150
151- public function testEmptyThrowGetKey (): void
151+ public function testCompareEmptyThrowGetKey (): void
152152 {
153153 $ this ->compare (
154154 fn () => (function () {
@@ -159,6 +159,45 @@ public function testEmptyThrowGetKey(): void
159159 );
160160 }
161161
162+ public function testLazyNotGeneratorValidGetReturn (): void
163+ {
164+ $ lazy = DeferredGenerator::fromHandler (fn () => 42 , EncodedValues::empty ());
165+
166+ $ this ->assertFalse ($ lazy ->valid ());
167+ $ this ->assertSame (42 , $ lazy ->getReturn ());
168+ }
169+
170+ public function testLazyNotGeneratorCurrent (): void
171+ {
172+ $ lazy = DeferredGenerator::fromHandler (fn () => 42 , EncodedValues::empty ());
173+
174+ $ this ->assertNull ($ lazy ->current ());
175+ }
176+
177+ public function testLazyNotGeneratorWithException (): void
178+ {
179+ $ lazy = DeferredGenerator::fromHandler (fn () => throw new \Exception ('foo ' ), EncodedValues::empty ());
180+
181+ $ this ->expectException (\Exception::class);
182+ $ this ->expectExceptionMessage ('foo ' );
183+
184+ $ lazy ->current ();
185+ }
186+
187+
188+ public function testLazyNotGeneratorWithException2 (): void
189+ {
190+ $ lazy = DeferredGenerator::fromHandler (fn () => throw new \Exception ('foo ' ), EncodedValues::empty ());
191+
192+ try {
193+ $ lazy ->current ();
194+ } catch (\Exception ) {
195+ // ignore
196+ }
197+
198+ $ this ->assertNull ($ lazy ->current ());
199+ }
200+
162201 /**
163202 * @param callable(): \Generator $generatorFactory
164203 * @param iterable<Action|int, array{Action, mixed}> $actions
0 commit comments