Unit test compute_constants()#184
Merged
alice-i-cecile merged 25 commits intoDioxusLabs:mainfrom Jun 23, 2022
Merged
Conversation
Collaborator
Author
|
Updated the PR description to reflect the work done so far |
alice-i-cecile
approved these changes
Jun 23, 2022
Collaborator
alice-i-cecile
left a comment
There was a problem hiding this comment.
Looks good to me now. Are you happy with this?
Collaborator
Author
Yes! I'm very happy with how this turned out, and I think this is the right place to stop ^^ |
mcrvaz
pushed a commit
to mcrvaz/taffy
that referenced
this pull request
Jun 24, 2022
* Begin testing algo-constants * Separating out resolve into own trait + module * Fix tests * Add convenience methods to Size * Move tests to resolve * Add tests for maybe_resolve Size<Dimension> * Move resolve tests to resolve.rs * Rewording parent -> context * Add last test * Add tests for resolve_or_default for Dimension * Adding rect constructors * Using consts instead of constructors * from_some() -> new() * Add note to releases * Turning constructors to consts * Rect convenience constructors * Add test-suite for rect resolve_or_default * Apply suggestions from code review Co-authored-by: Alice Cecile <[email protected]> * Fix clippy lints & add docs * Add tests for Rect -> Option -> Rect * Finish testing algo-consts * Apply suggestions from alice * Tweak RELEASES.md wording Co-authored-by: Alice Cecile <[email protected]>
jkelleyrtp
pushed a commit
that referenced
this pull request
Oct 10, 2022
* Begin testing algo-constants * Separating out resolve into own trait + module * Fix tests * Add convenience methods to Size * Move tests to resolve * Add tests for maybe_resolve Size<Dimension> * Move resolve tests to resolve.rs * Rewording parent -> context * Add last test * Add tests for resolve_or_default for Dimension * Adding rect constructors * Using consts instead of constructors * from_some() -> new() * Add note to releases * Turning constructors to consts * Rect convenience constructors * Add test-suite for rect resolve_or_default * Apply suggestions from code review Co-authored-by: Alice Cecile <[email protected]> * Fix clippy lints & add docs * Add tests for Rect -> Option -> Rect * Finish testing algo-consts * Apply suggestions from alice * Tweak RELEASES.md wording Co-authored-by: Alice Cecile <[email protected]>
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.
Objective
One more step towards #92
This PR is a bit of a mixed bag, so let me know if I should split it up.
The objective of this PR is to set us up so that we can start testing the flexbox algorithm.
Context
While trying to cover the
compute_constants()in tests, I discovered the code needed a bit refactoring and massaging in order to actually be testable.Here I realized that the different
resolve()methods can be abstracted to a "Resolve" trait, and following the convention ofMaybeMath, we now haveMaybeResolveandResolveOrDefault.These traits encapsulate behaviour where we need to resolve from a potentially context-dependent size / dimension into a context-independent size / dimensions. In other words:
Dimension) or two dimensional (Size<Dimension>/Rect<Dimension>)Dimension::Points(n)tells us that this isnlongDimension::Percent(n)tells us that this isn * parent.widthlongresolvecome in.The only real difference between the two is what they output when they are unable to resolve the size
MaybeResolvewill return aOption<f32>with aNoneas the fallbackResolveOrDefaultwill return af32with the value0.0as the fallbackChangelog
resolvewhich houses all code related codeMaybeResolveResolveOrDefaultDimension.resolve()andSize<Dimension>.resolve()has been replaced byimpl MaybeResolvecompute_constants()to make it easier to test#[must_use]on static constructors that was missing themSize<Dimension>,Rect<Dimension>Size<f32>.zero()has now becomeSize::<f32>::ZEROPoint<f32>.zero()has now becomePoint::<f32>::ZEROnew()constructor toSize<f32>Rect<T>.mapas not used anymoreFeedback wanted