Skip to content

Conversation

@ra1028
Copy link
Owner

@ra1028 ra1028 commented Sep 28, 2023

Pull Request Type

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • Chore

Description

Add a new testing function lookup to AtomTestContext such that testing code can access already cached value without any side effects.
It is convenient when you want to print current the state without starting a side-effect-full process initiated by read or watch.

Motivation and Context

read was supposed to be enough for dumping the current state of an atom but it actually initiates a side-effect-full process for a moment while it will be terminated immediately.
So, this PR is to add a useful, side-effect-free function for applications such as adding a print to debug the current state without changing the testing result.

Impact on Existing Code

AtomTestContext.wait(for:timeout:until:) started using the new lookup instead of read to check the current state to determine that the state is matched with the expected condition.
This is a change to eliminate a side effect that was unnecessary while waiting for a state change in that method, and there are no counterintuitive negative effects from it.

Copy link
Collaborator

@rasberik rasberik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ra1028 ra1028 merged commit f2fd43e into main Sep 28, 2023
@ra1028 ra1028 deleted the test-context-lookup-function branch September 28, 2023 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants