mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
Remove the matchers_lite.dart library.
It was literally only used by one test, and only used a single function not already defined in minitest. That function was only used in one place and wasn't very useful, so just refactored to not use it. Change-Id: Ib51ac255233aa29bcaf19aaba16bc99d7eff724d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135965 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
82e2d4cabc
commit
44f027b8b2
2 changed files with 3 additions and 58 deletions
|
@ -1,55 +0,0 @@
|
|||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
/// This library is supposed help to remove dependencies on package:test from
|
||||
/// an existing test.
|
||||
///
|
||||
/// Feel free to add more matchers, as long as they remain lite. Batteries
|
||||
/// aren't included here. This is intended to be used in low-level platform
|
||||
/// tests and shouldn't rely on advanced features such as reflection. Using
|
||||
/// asynchronous code is acceptable, but only for testing code that is
|
||||
/// *already* asynchronous, but try to avoid using "async" and other generators
|
||||
/// (it's hard testing the implemention of generators if the test
|
||||
/// infrastructure relies on them itself).
|
||||
library expect.matchers_lite;
|
||||
|
||||
import "expect.dart" show Expect;
|
||||
|
||||
typedef Matcher = void Function(Object actual);
|
||||
|
||||
void expect(dynamic actual, dynamic expected) {
|
||||
if (expected is Matcher) {
|
||||
expected(actual);
|
||||
} else {
|
||||
equals(expected)(actual);
|
||||
}
|
||||
}
|
||||
|
||||
Matcher unorderedEquals(Iterable<Object> expected) {
|
||||
return (Object actual) =>
|
||||
Expect.setEquals(expected, actual as Iterable<Object>);
|
||||
}
|
||||
|
||||
fail(String message) {
|
||||
Expect.fail(message);
|
||||
}
|
||||
|
||||
Matcher same(Object expected) {
|
||||
return (Object actual) => Expect.identical(expected, actual);
|
||||
}
|
||||
|
||||
Matcher equals(Object expected) {
|
||||
if (expected is String) {
|
||||
return (Object actual) => Expect.stringEquals(expected, actual as String);
|
||||
} else if (expected is Iterable<Object>) {
|
||||
return (dynamic actual) =>
|
||||
Expect.listEquals(expected.toList(), actual.toList());
|
||||
} else {
|
||||
return (Object actual) => Expect.equals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
final Matcher isEmpty = (dynamic actual) => Expect.isTrue(actual.isEmpty);
|
||||
|
||||
final Matcher isNull = (Object actual) => Expect.isNull(actual);
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:expect/matchers_lite.dart";
|
||||
import "package:expect/minitest.dart";
|
||||
|
||||
import "package:kernel/ast.dart";
|
||||
import "package:kernel/class_hierarchy.dart";
|
||||
|
@ -744,8 +744,8 @@ abstract class B extends self::A {}
|
|||
]));
|
||||
expect(hierarchy.getDeclaredMembers(a, setters: true),
|
||||
unorderedEquals([setter, abstractSetter, nonFinalField]));
|
||||
expect(hierarchy.getDeclaredMembers(b), isEmpty);
|
||||
expect(hierarchy.getDeclaredMembers(b, setters: true), isEmpty);
|
||||
expect(hierarchy.getDeclaredMembers(b).isEmpty, isTrue);
|
||||
expect(hierarchy.getDeclaredMembers(b, setters: true).isEmpty, isTrue);
|
||||
}
|
||||
|
||||
void test_getDispatchTarget() {
|
||||
|
|
Loading…
Reference in a new issue