add SDK mocks
Required for: https://github.com/dart-lang/linter/issues/2969
Change-Id: I74ea56145cf7e0dea2481e945f2e7810c3cffd9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215501
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
index a05f61d..006dde9 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
@@ -48,7 +48,8 @@
Future<T> whenComplete(action());
- static Future<List<T>> wait<T>(Iterable<Future<T>> futures) => throw 0;
+ static Future<List<T>> wait<T>(Iterable<Future<T>> futures,
+ {void cleanUp(T successValue)?}) => throw 0;
}
abstract class FutureOr<T> {}
@@ -162,6 +163,8 @@
}
}
+abstract class IterableMixin<E> implements Iterable<E> { }
+
abstract class LinkedHashMap<K, V> implements Map<K, V> {
external factory LinkedHashMap(
{bool Function(K, K)? equals,
@@ -208,6 +211,12 @@
throw 0;
}
}
+
+abstract class ListMixin<E> implements List<E> { }
+
+abstract class MapMixin<K, V> implements Map<K, V> { }
+
+abstract class SetMixin<E> implements Set<E> { }
''',
)
]);
@@ -234,6 +243,10 @@
const JsonCodec();
String encode(Object? value, {Object? toEncodable(dynamic object)?}) => '';
}
+
+abstract class StringConversionSink { }
+
+abstract class StringConversionSinkMixin implements StringConversionSink { }
''',
)
],
@@ -290,7 +303,12 @@
typedef Comparator<T> = int Function(T a, T b);
-class DateTime extends Object {}
+class DateTime extends Object {
+ external DateTime._now();
+ DateTime.now() : this._now();
+ external bool isBefore(DateTime other);
+ external int get millisecondsSinceEpoch;
+}
class Deprecated extends Object {
final String expires;
@@ -360,6 +378,8 @@
bool get isEven => false;
bool get isNegative;
+ bool get isOdd;
+ int get sign;
int operator &(int other);
int operator -();
@@ -371,8 +391,10 @@
int operator ~();
int abs();
+ int ceil();
int gcd(int other);
String toString();
+ int truncate();
external static int parse(String source,
{int? radix, @deprecated int onError(String source)?});
@@ -389,7 +411,11 @@
Iterator<E> get iterator;
int get length;
- bool contains(Object element);
+ const Iterable();
+
+ const factory Iterable.empty() => EmptyIterable<E>();
+
+ bool contains(Object? element);
Iterable<T> expand<T>(Iterable<T> f(E element));
@@ -410,6 +436,7 @@
Set<E> toSet();
Iterable<E> where(bool test(E element));
+ Iterable<T> whereType<T>();
}
abstract class Iterator<E> {
@@ -436,6 +463,7 @@
Map<int, E> asMap() {}
void clear() {}
int indexOf(Object element);
+ bool remove(Object? value);
E removeLast() {}
noSuchMethod(Invocation invocation) => null;
@@ -463,8 +491,11 @@
V? operator [](Object? key);
void operator []=(K key, V value);
+ void addAll(Map<K, V> other);
Map<RK, RV> cast<RK, RV>();
bool containsKey(Object? key);
+ void forEach(void action(K key, V value));
+ V putIfAbsent(K key, V ifAbsent());
}
class Null extends Object {
@@ -541,7 +572,7 @@
}
abstract class RegExp implements Pattern {
- external factory RegExp(String source);
+ external factory RegExp(String source, {bool unicode = false});
}
abstract class Set<E> implements Iterable<E> {
@@ -895,6 +926,7 @@
"iframe");
String src;
+ set srcdoc(String? value) native;
}
class OptionElement extends HtmlElement {
@@ -997,6 +1029,10 @@
class Symbol {}
+class EmptyIterable<E> implements Iterable<E> {
+ const EmptyIterable();
+}
+
class ExternalName {
final String name;
const ExternalName(this.name);