Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Make unset=null part of the interface of lastYieldedValue
Browse files Browse the repository at this point in the history
  • Loading branch information
rcahoon committed Mar 15, 2024
1 parent 7a3a365 commit 3572167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
public interface LaunchedContextWithValue<T> extends LaunchedContext {
/**
* Return the most recent value that the Procedure passed to Context.yield(T).
* Return null if a value has never been yielded, or a value has not been yielded since the last
* call to getAndClearLastYieldedValue.
*/
T lastYieldedValue();

Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/team766/framework/YieldWithValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ private static class ValueConsumer extends Procedure {
@Override
public void run(Context context) {
var generator = context.startAsync(new ValueGenerator());

assertNull(
"lastYieldedValue should be null before the procedure yields a value",
generator.lastYieldedValue());

while (generator.lastYieldedValue() == null || generator.lastYieldedValue() < 10) {
var value = generator.lastYieldedValue();
if (value != null) {
Expand Down

0 comments on commit 3572167

Please sign in to comment.