Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Use a shorter doc header for CustomMatcher #256

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.0, dev]
sdk: [3.4, dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.17-wip

* Require Dart 3.4

## 0.12.16+1

* Require Dart 3.0
Expand Down
4 changes: 3 additions & 1 deletion lib/src/custom_matcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import 'description.dart';
import 'interfaces.dart';
import 'util.dart';

/// A useful utility class for implementing other matchers through inheritance.
/// A base class for [Matcher] instances that match based on some feature of the
/// value under test.
///
/// Derived classes should call the base constructor with a feature name and
/// description, and an instance matcher, and should implement the
/// [featureValueOf] abstract method.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/expect/expect_async.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class _ExpectedFunction<T> {
void _afterRun() {
if (_complete) return;
if (_minExpectedCalls > 0 && _actualCalls < _minExpectedCalls) return;
if (_isDone != null && !_isDone!()) return;
if (_isDone != null && !_isDone()) return;

// Mark this callback as complete and remove it from the test case's
// outstanding callback count; if that hits zero the test is done.
Expand Down
6 changes: 3 additions & 3 deletions lib/src/expect/future_matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class _Completes extends AsyncMatcher {

String? result;
if (_matcher is AsyncMatcher) {
result = await (_matcher as AsyncMatcher).matchAsync(value) as String?;
result = await _matcher.matchAsync(value) as String?;
if (result == null) return null;
} else {
var matchState = {};
if (_matcher!.matches(value, matchState)) return null;
result = _matcher!
if (_matcher.matches(value, matchState)) return null;
result = _matcher
.describeMismatch(value, StringDescription(), matchState, false)
.toString();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/expect/throws_matcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ class Throws extends AsyncMatcher {
if (_matcher == null) return null;

var matchState = {};
if (_matcher!.matches(error, matchState)) return null;
if (_matcher.matches(error, matchState)) return null;

var result = _matcher!
var result = _matcher
.describeMismatch(error, StringDescription(), matchState, false)
.toString();

Expand Down
8 changes: 6 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: matcher
version: 0.12.16+1
version: 0.12.17-wip
description: >-
Support for specifying test expectations via an extensible Matcher class.
Also includes a number of built-in Matcher implementations for common cases.
repository: https://github.com/dart-lang/matcher

environment:
sdk: ^3.0.0
sdk: ^3.4.0

dependencies:
async: ^2.10.0
Expand All @@ -19,3 +19,7 @@ dev_dependencies:
fake_async: ^1.3.0
lints: ^3.0.0
test: ^1.23.0

dependency_overrides:
test: 1.25.0
test_api: 0.7.3