Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take callbacks for actual and which #1901

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on Feb 3, 2023

  1. Make label arguments take callbacks

    The main benefit this brings is it brings more alignment with the
    `clause` arguments for `expect` calls. The docs will be able to focus on
    the difference in how the value is use (preceding "that" in the case of
    labels, standing on its own in a list in the case of clauses) and can
    use a consistent description for how it is passed.
    
    A secondary benefit is that it allows multiline labels and avoid
    workaround like joining with `r'\n'`.
    
    A final benefit is that it saves some unnecessary String formatting
    since the callback isn't called if no expectations fail on the Subject,
    or when used as a soft check where the failure details are ignored.
    
    - Make the `label` arguments to `nest` and `nestAsync`, and the _label
      field in `_TestContext` an `Iterable<String> Function()`.
    - Wrap strings that had been passed to `String` arguments with callbacks
      that return the string in a list.
    - When writing the label in a failure, write all lines, and use a
      postfix " that:".
    - Update some `Map` expectations which had manually joined with literal
      slash-n to keep the label or clause to a single line to take advantage
      of the multiline allowance. Split tests for the changed
      implementations and add tests for the descriptions with multiline
      examples. Some of these could have used multiline clauses before.
    natebosch committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    8ab184b View commit details
    Browse the repository at this point in the history
  2. Take callbacks for actual and which

    This aligns these arguments with all the other failure formatting
    arguments like `clause` and `label`. There may be some performance
    benefit in some cases where a rejection from `softCheck` is ignored and
    expensive String operations are avoid, but in the typical case this just
    introduces closures which will be invoked shortly.
    
    Replace the default empty list for `actual` with a default function.
    This is a slight behavior change where passing `() => []` will not get
    overwritten with the default, but passing `[]` would have. Only
    defaulting for when the argument was not passed at all is slightly
    better behavior.
    
    Replace a bunch of `Iterable<String>` with `Iterable<String> Function()`
    and invoke them at the moment the strings are needed.
    natebosch committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    b95c060 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2023

  1. Configuration menu
    Copy the full SHA
    ce01c15 View commit details
    Browse the repository at this point in the history

Commits on Jun 8, 2023

  1. Configuration menu
    Copy the full SHA
    0fb37ad View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9749077 View commit details
    Browse the repository at this point in the history