Skip to content

Conversation

@cbracken
Copy link
Member

Description

Flutter's moreOrLessEquals has a few advantages over closeTo from the matcher package:

  • It emits the epsilon value in the test result on failure.
  • It uses a named parameter for epsilon, which improves readability at the call site.
  • It has a reasonable default for epsilon in cases where something more specific isn't required.

Using it also has the nice property that it aids in its own discovery when when people go looking for such functionality in new tests.

This change also migrates the physics tests to use the default value of epsilon, and includes a couple unrelated whitespace formatting cleanups.

Related changes

This is a followup patch to #64914, which migrated uses of closeTo that used the default value for epsilon. This change covers cases where values other than the default value are used.

@cbracken cbracken requested a review from Hixie August 31, 2020 01:52
@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Aug 31, 2020
@cbracken
Copy link
Member Author

This is more of a "what do you think?" PR for the reasons listed in the description. Thoughts?

Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:

   * It emits the epsilon value in the test result on failure.
   * It uses a named parameter for epsilon, which improves readability
     at the call site.
   * It has a reasonable default for epsilon in cases where something
     more specific isn't required.

Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.

This change also includes a couple unrelated whitespace formatting cleanups.
Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

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

RSLGTM

@cbracken cbracken merged commit c0ea00e into flutter:master Aug 31, 2020
@cbracken cbracken deleted the moreMoreOrLess branch August 31, 2020 05:20
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
Flutter's `moreOrLessEquals` has a few advantages over `closeTo` from
the `matcher` package:

   * It emits the epsilon value in the test result on failure.
   * It uses a named parameter for epsilon, which improves readability
     at the call site.
   * It has a reasonable default for epsilon in cases where something
     more specific isn't required.

Using it also has the nice property that it aids in its own discovery
when when people go looking for such functionality in new tests.

This change also includes a couple unrelated whitespace formatting cleanups.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants