[checks] Collapse clauses for described conditions

`IterableChecks.any`, `IterableChecks.every`, `MapChecks.containsKeyThat`,
and `MapChecks.containsValueThat` embed the description of a condition.
They collapse to a single line at the root, through a predicate noun such as
`an iterable containing a value that is greater than <7>`, but their clause
always used the multi-line form of a label followed by the indented
description. Where the clause itself is shown, such as when one of these
expectations is nested inside the condition of another, the description
never collapsed, while the same check reached through `has` did. Reported in
https://github.com/dart-lang/test/pull/2784#discussion_r4230540680:

    check([[1]]).any(.it()..any(.it()..isGreaterThan(1)));

    Expected: a List<List<int>> that:
      contains a value that:
        contains a value that:
          is greater than <1>

Add an internal `describedClause` helper next to `describedPredicateNoun`.
It joins the label to the description of the condition on a single line when
the condition describes in a single line and the result fits within 80
columns, and otherwise keeps the label followed by the indented description.
Both helpers share the logic for joining and the length limit. Use it for
the clauses of all four expectations. The inner `any` above now describes
itself as a single line, so the outer `any` collapses to a single
`Expected:` line at the root:

    an iterable containing a value that contains a value that is
    greater than <1>

Joining the label of `every`, `only has values that`, to a description such
as `is less than <10>` reads as `only has values that is less than <10>`.
Describe the condition as `every element` instead, which reads as
`every element is less than <10>` on one line, and `every element:` followed
by the description otherwise. Change the predicate noun to match:
`an iterable where every element is less than <10>`.
6 files changed
tree: b17e22b19d87ab3e1d9d763c7090c81adf3da74b
  1. .github/
  2. integration_tests/
  3. pkgs/
  4. tool/
  5. .gitattributes
  6. .gitignore
  7. analysis_options.yaml
  8. CODEOWNERS
  9. CONTRIBUTING.md
  10. mono_repo.yaml
  11. pubspec.yaml
  12. README.md
README.md

Dart CI OpenSSF Scorecard

What's here?

Welcome! package:test is the standard testing library for Dart and Flutter. If you have questions about Dart testing, please see the docs for package:test. package:test_api and package:test_core are implementation details and generally not user-facing.

package:checks is a relatively new library for expressing test expectations. It's a more modern version of package:matcher and features a literate API.

Packages

PackageDescriptionIssuesVersion
checksA framework for checking values against expectations and building custom expectations.issuespub package
fake_asyncFake asynchronous events such as timers and microtasks for deterministic testing.issuespub package
matcherSupport for specifying test expectations via an extensible Matcher class. Also includes a number of built-in Matcher implementations for common cases.issuespub package
testA full featured library for writing and running Dart tests across platforms.issuespub package
test_apiThe user facing API for structuring Dart tests and checking expectations.pub package
test_coreA basic library for writing tests and running them on the VM.pub package
test_descriptorAn API for defining and verifying files and directory structures.issuespub package
test_processTest processes: starting; validating stdout and stderr; checking exit code.issuespub package