Skip to content

Commit

Permalink
Update to the latest lints, require Dart 3.1, prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Nov 16, 2023
1 parent dc3eb65 commit ecc62f6
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [3.0.0, dev]
sdk: [3.1.0, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
Expand All @@ -59,7 +59,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [3.0.0, dev]
sdk: [3.1.0, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## 5.4.3-wip
## 5.4.3

* Require analyzer 5.12.0, allow analyzer version 6.x;
* Add example of writing a class to mock function objects.
* Add support for the `build_extensions` build.yaml option
* Require Dart >= 3.0.0.
* Require Dart >=3.1.0.
* **Potentially breaking** Changed default `String` value returned by nice
mocks' unstubbed method to include some useful info. This could break the
tests that relied on getting an empty `String` from unstubbed methods.
Expand Down
18 changes: 6 additions & 12 deletions lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,9 @@ class _MockTargetGatherer {
case 'GenerateMocks':
mockTargets
.addAll(_mockTargetsFromGenerateMocks(annotation, entryLib));
break;
case 'GenerateNiceMocks':
mockTargets.addAll(
_mockTargetsFromGenerateNiceMocks(annotation, entryLib));
break;
}
}
}
Expand Down Expand Up @@ -2404,16 +2402,12 @@ extension on TypeSystem {
extension on int {
String get ordinal {
final remainder = this % 10;
switch (remainder) {
case 1:
return '${this}st';
case 2:
return '${this}nd';
case 3:
return '${this}rd';
default:
return '${this}th';
}
return switch (remainder) {
1 => '${this}st',
2 => '${this}nd',
3 => '${this}rd',
_ => '${this}th'
};
}
}

Expand Down
30 changes: 15 additions & 15 deletions lib/src/dummies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,22 @@ typedef DummyBuilder<T> = T Function(Object parent, Invocation invocation);
Map<Type, DummyBuilder> _dummyBuilders = {};

Map<Type, DummyBuilder> _defaultDummyBuilders = {
bool: (_, _i) => false,
int: (_, _i) => _dummyInt,
num: (_, _i) => _dummyInt,
double: (_, _i) => _dummyDouble,
bool: (_, __) => false,
int: (_, __) => _dummyInt,
num: (_, __) => _dummyInt,
double: (_, __) => _dummyDouble,
String: _dummyString,
Int8List: (_, _i) => Int8List(0),
Int16List: (_, _i) => Int16List(0),
Int32List: (_, _i) => Int32List(0),
Int64List: (_, _i) => Int64List(0),
Uint8List: (_, _i) => Uint8List(0),
Uint16List: (_, _i) => Uint16List(0),
Uint32List: (_, _i) => Uint32List(0),
Uint64List: (_, _i) => Uint64List(0),
Float32List: (_, _i) => Float32List(0),
Float64List: (_, _i) => Float64List(0),
ByteData: (_, _i) => ByteData(0),
Int8List: (_, __) => Int8List(0),
Int16List: (_, __) => Int16List(0),
Int32List: (_, __) => Int32List(0),
Int64List: (_, __) => Int64List(0),
Uint8List: (_, __) => Uint8List(0),
Uint16List: (_, __) => Uint16List(0),
Uint32List: (_, __) => Uint32List(0),
Uint64List: (_, __) => Uint64List(0),
Float32List: (_, __) => Float32List(0),
Float64List: (_, __) => Float64List(0),
ByteData: (_, __) => ByteData(0),
...platformDummies,
};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class SmartFake {
// make Analyzer happy, if we fake classes that override `==` to
// accept `Object?` or `dynamic` (most notably [Interceptor]).
@override
// ignore: non_nullable_equals_parameter
// ignore: non_nullable_equals_parameter, hash_and_equals
bool operator ==(Object? other) => identical(this, other);

@override
Expand Down
16 changes: 8 additions & 8 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: mockito
version: 5.4.3-wip
version: 5.4.3
description: >-
A mock framework inspired by Mockito with APIs for Fakes, Mocks,
behavior verification, and stubbing.
repository: https://github.com/dart-lang/mockito

environment:
sdk: '>=3.0.0 <4.0.0'
sdk: ^3.1.0

dependencies:
analyzer: '>=5.12.0 <7.0.0'
build: '>=1.3.0 <3.0.0'
build: ^2.0.0
code_builder: ^4.5.0
collection: ^1.15.0
dart_style: '>=1.3.6 <3.0.0'
dart_style: ^2.0.0
matcher: ^0.12.15
meta: ^1.3.0
path: ^1.8.0
source_gen: '>=0.9.6 <2.0.0'
source_gen: ^1.0.0
test_api: '>=0.2.1 <0.7.0'

dev_dependencies:
build_runner: ^2.0.0
build_test: ^2.0.0
build_web_compilers: '>=3.0.0 <5.0.0'
http: '>=0.13.0 <2.0.0'
lints: ^2.0.0
package_config: '>=1.9.3 <3.0.0'
http: ^1.0.0
lints: ^3.0.0
package_config: ^2.0.0
test: ^1.16.0
2 changes: 2 additions & 0 deletions test/end2end/foo.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: library_private_types_in_public_api

import 'foo_sub.dart';

class Foo<T> {
Expand Down
1 change: 1 addition & 0 deletions test/end2end/generated_mocks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'generated_mocks_test.mocks.dart';
#$hasDollarInName,
},
),
// ignore: deprecated_member_use_from_same_package
MockSpec<HasPrivate>(mixingIn: [HasPrivateMixin]),
])
@GenerateNiceMocks(
Expand Down

0 comments on commit ecc62f6

Please sign in to comment.