test: add Task and CompletableTask coverage#272
Open
YunchuWang wants to merge 1 commit into
Open
Conversation
…e classes Add comprehensive unit tests for the foundational Task<T> and CompletableTask<T> classes which previously had zero direct test coverage. Tests cover: - Task: getResult() before completion, after failure, after success - Task: getException() on non-failed and failed tasks - Task: isComplete and isFailed state tracking - CompletableTask: complete() with various result types (null, undefined) - CompletableTask: fail() with and without explicit TaskFailureDetails - CompletableTask: double-completion and cross-state error guards - CompletableTask: parent notification via onChildCompleted() Fixes #232 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds direct unit tests for the foundational Task<T> and CompletableTask<T> classes to ensure their base completion/failure semantics are covered independently of composite tasks and the orchestration executor, addressing the test gap described in #232.
Changes:
- Adds isolated unit coverage for
Task.getResult(),Task.getException(),isComplete, andisFailed. - Adds unit coverage for
CompletableTask.complete()/fail()including double-completion/failure guards and parent notification behavior. - Introduces a small helper to construct
TaskFailureDetailsfor failure-path assertions.
|
|
||
| it("should notify parent via onChildCompleted when parent is set", () => { | ||
| const child = new CompletableTask<number>(); | ||
| // Use WhenAllTask as the parent since CompositeTask is abstract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #232