Rewrite doc comments to refer to TypeError (#131)
This will be the type going forward. Keep a reference to `CastError` for
now, we can drop it after a few SDK releases.
Ignore usage of `CastError` in a test so that we can keep running on
the oldest supported stable SDK. We can switch this when the minimum
SDK is bumped.
diff --git a/lib/src/algorithms.dart b/lib/src/algorithms.dart
index 9722b77..cb6a03f 100644
--- a/lib/src/algorithms.dart
+++ b/lib/src/algorithms.dart
@@ -12,7 +12,8 @@
/// is unpredictable.
///
/// If [compare] is omitted, this defaults to calling [Comparable.compareTo] on
-/// the objects. If any object is not [Comparable], this throws a [CastError].
+/// the objects. If any object is not [Comparable], this throws a [TypeError]
+/// (`CastError` on some SDK versions).
///
/// Returns -1 if [value] is not in the list by default.
int binarySearch<T>(List<T> sortedList, T value, {int Function(T, T) compare}) {
@@ -40,7 +41,8 @@
/// is unpredictable.
///
/// If [compare] is omitted, this defaults to calling [Comparable.compareTo] on
-/// the objects. If any object is not [Comparable], this throws a [CastError].
+/// the objects. If any object is not [Comparable], this throws a [TypeError]
+/// (`CastError` on some SDK versions).
///
/// Returns [sortedList.length] if all the items in [sortedList] compare less
/// than [value].
@@ -96,7 +98,8 @@
/// insertion sort.
///
/// If [compare] is omitted, this defaults to calling [Comparable.compareTo] on
-/// the objects. If any object is not [Comparable], this throws a [CastError].
+/// the objects. If any object is not [Comparable], this throws a [TypeError]
+/// (`CastError` on some SDK versions).
///
/// Insertion sort is a simple sorting algorithm. For `n` elements it does on
/// the order of `n * log(n)` comparisons but up to `n` squared moves. The
@@ -139,7 +142,8 @@
/// merge sort algorithm.
///
/// If [compare] is omitted, this defaults to calling [Comparable.compareTo] on
-/// the objects. If any object is not [Comparable], this throws a [CastError].
+/// the objects. If any object is not [Comparable], this throws a [TypeError]
+/// (`CastError` on some SDK versions).
///
/// Merge-sorting works by splitting the job into two parts, sorting each
/// recursively, and then merging the two sorted parts.
diff --git a/test/queue_list_test.dart b/test/queue_list_test.dart
index d37cc61..a47e862 100644
--- a/test/queue_list_test.dart
+++ b/test/queue_list_test.dart
@@ -284,7 +284,8 @@
);
expect(
() => numQueue.add(1),
- throwsCastError,
+ // ignore: deprecated_member_use
+ throwsA(isA<CastError>()),
skip: isDart2 ? false : 'In Dart1 a TypeError is not thrown',
);
});
diff --git a/test/utils.dart b/test/utils.dart
index 48cd7cf..2c80fe2 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -2,10 +2,6 @@
// 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:test/test.dart';
-
-final Matcher throwsCastError = throwsA(TypeMatcher<CastError>());
-
/// A hack to determine whether we are running in a Dart 2 runtime.
final bool isDart2 = _isTypeArgString('');
bool _isTypeArgString<T>(T arg) {