Deprecate the name parameter of isInstanceOf.
Closes #4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c817eea..ee00a46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 0.11.4+4
+
+* Deprecate the name parameter to `isInstanceOf`. All language implementations
+ now support converting the type parameter to a string directly.
+
## 0.11.4+3
* Fix the examples for `equalsIgnoringWhitespace`.
diff --git a/lib/src/core_matchers.dart b/lib/src/core_matchers.dart
index a3d1f57..ba0ac2e 100644
--- a/lib/src/core_matchers.dart
+++ b/lib/src/core_matchers.dart
@@ -372,23 +372,15 @@
/// 'Foo', we would write:
///
/// expect(bar, new isInstanceOf<Foo>());
-///
-/// To get better error message, supply a name when creating the
-/// Type wrapper; e.g.:
-///
-/// expect(bar, new isInstanceOf<Foo>('Foo'));
-///
-/// Note that this does not currently work in dart2js; it will
-/// match any type, and isNot(new isInstanceof<T>()) will always
-/// fail. This is because dart2js currently ignores template type
-/// parameters.
class isInstanceOf<T> extends Matcher {
- final String _name;
- const isInstanceOf([name = 'specified type']) : this._name = name;
+ /// The [name] parameter does nothing; it's deprecated and will be removed in
+ /// future version of [matcher].
+ const isInstanceOf([@deprecated String name]);
+
bool matches(obj, Map matchState) => obj is T;
- // The description here is lame :-(
+
Description describe(Description description) =>
- description.add('an instance of ${_name}');
+ description.add('an instance of $T');
}
/// A matcher that matches a function call against no exception.
diff --git a/pubspec.yaml b/pubspec.yaml
index 3771a1f..47e8e84 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: matcher
-version: 0.11.4+3
+version: 0.11.4+4
author: Dart Team <misc@dartlang.org>
description: Support for specifying test expectations
homepage: https://github.com/dart-lang/matcher
diff --git a/test/core_matchers_test.dart b/test/core_matchers_test.dart
index 7024894..5cd17da 100644
--- a/test/core_matchers_test.dart
+++ b/test/core_matchers_test.dart
@@ -177,9 +177,9 @@
});
test('isInstanceOf', () {
- shouldFail(0, new isInstanceOf<String>('String'),
+ shouldFail(0, new isInstanceOf<String>(),
"Expected: an instance of String Actual: <0>");
- shouldPass('cow', new isInstanceOf<String>('String'));
+ shouldPass('cow', new isInstanceOf<String>());
});
group('Predicate Matchers', () {