Skip to content

Commit a288ff9

Browse files
authored
Fix newly enforced package:pedantic lints (flutter#13)
- annotate_overrides - prefer_single_quotes
1 parent 4b36dfb commit a288ff9

File tree

7 files changed

+54
-45
lines changed

7 files changed

+54
-45
lines changed

lib/clock.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ export 'src/clock.dart';
1818
export 'src/default.dart';
1919

2020
/// Returns current time.
21-
@Deprecated("Pass around an instance of Clock instead.")
21+
@Deprecated('Pass around an instance of Clock instead.')
2222
typedef TimeFunction = DateTime Function();
2323

2424
/// Returns the current system time.
25-
@Deprecated("Use new DateTime.now() instead.")
25+
@Deprecated('Use new DateTime.now() instead.')
2626
DateTime systemTime() => DateTime.now();
2727

2828
/// Returns the current time as reported by [clock].
29-
@Deprecated("Use clock.now() instead.")
29+
@Deprecated('Use clock.now() instead.')
3030
DateTime get now => clock.now();
3131

3232
/// Returns a stopwatch that uses the current time as reported by [clock].
33-
@Deprecated("Use clock.stopwatch() instead.")
33+
@Deprecated('Use clock.stopwatch() instead.')
3434
Stopwatch getStopwatch() => clock.stopwatch();

lib/src/clock.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,6 @@ class Clock {
177177
Stopwatch stopwatch() => ClockStopwatch(this);
178178

179179
/// Returns a new stopwatch that uses the current time as reported by `this`.
180-
@Deprecated("Use stopwatch() instead.")
180+
@Deprecated('Use stopwatch() instead.')
181181
Stopwatch getStopwatch() => stopwatch();
182182
}

lib/src/default.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ T withClock<T>(Clock clock, T Function() callback,
4242
{@deprecated bool isFinal = false}) {
4343
if ((Zone.current[_isFinalKey] ?? false) == true) {
4444
throw StateError(
45-
"Cannot call withClock() within a call to withClock(isFinal = true).");
45+
'Cannot call withClock() within a call to withClock(isFinal = true).');
4646
}
4747

4848
return runZoned(callback,

lib/src/stopwatch.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,34 @@ class ClockStopwatch implements Stopwatch {
3838

3939
ClockStopwatch(this._clock);
4040

41+
@override
4142
int get frequency => _frequency;
43+
@override
4244
int get elapsedTicks => (elapsedMicroseconds * frequency) ~/ 1000000;
45+
@override
4346
Duration get elapsed => Duration(microseconds: elapsedMicroseconds);
47+
@override
4448
int get elapsedMilliseconds => elapsedMicroseconds ~/ 1000;
49+
@override
4550
bool get isRunning => _start != null;
4651

52+
@override
4753
int get elapsedMicroseconds =>
4854
_elapsed +
4955
(_start == null ? 0 : _clock.now().difference(_start).inMicroseconds);
5056

57+
@override
5158
void start() {
5259
_start ??= _clock.now();
5360
}
5461

62+
@override
5563
void stop() {
5664
_elapsed = elapsedMicroseconds;
5765
_start = null;
5866
}
5967

68+
@override
6069
void reset() {
6170
_elapsed = 0;
6271
if (_start != null) _start = _clock.now();

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: clock
2-
version: 1.0.1
2+
version: 1.0.2-dev
33
description: A fakeable wrapper for dart:core clock APIs
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/clock

test/default_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import 'package:test/test.dart';
2121
import 'utils.dart';
2222

2323
void main() {
24-
test("the default clock returns the system time", () {
24+
test('the default clock returns the system time', () {
2525
expect(DateTime.now().difference(clock.now()).inMilliseconds.abs(),
2626
lessThan(100));
2727
});
2828

29-
group("withClock()", () {
30-
group("overrides the clock", () {
31-
test("synchronously", () {
29+
group('withClock()', () {
30+
group('overrides the clock', () {
31+
test('synchronously', () {
3232
var time = date(1990, 11, 8);
3333
withClock(Clock(() => time), () {
3434
expect(clock.now(), equals(time));
@@ -37,7 +37,7 @@ void main() {
3737
});
3838
});
3939

40-
test("asynchronously", () {
40+
test('asynchronously', () {
4141
var time = date(1990, 11, 8);
4242
withClock(Clock.fixed(time), () {
4343
expect(Future(() async {
@@ -46,7 +46,7 @@ void main() {
4646
});
4747
});
4848

49-
test("within another withClock() call", () {
49+
test('within another withClock() call', () {
5050
var outerTime = date(1990, 11, 8);
5151
withClock(Clock.fixed(outerTime), () {
5252
expect(clock.now(), equals(outerTime));

test/stopwatch_test.dart

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ import 'package:test/test.dart';
1919
import 'utils.dart';
2020

2121
void main() {
22-
test("returns the system frequency", () {
22+
test('returns the system frequency', () {
2323
expect(fixed(1990, 11, 8).stopwatch().frequency,
2424
equals(Stopwatch().frequency));
2525
});
2626

27-
group("before it starts", () {
27+
group('before it starts', () {
2828
Stopwatch stopwatch;
2929
setUp(() {
3030
stopwatch = clock.stopwatch();
3131
});
3232

33-
test("is not running", () => expect(stopwatch.isRunning, isFalse));
33+
test('is not running', () => expect(stopwatch.isRunning, isFalse));
3434

35-
test("stop() does nothing", () {
35+
test('stop() does nothing', () {
3636
stopwatch.stop();
3737
expect(stopwatch.isRunning, isFalse);
3838
expect(stopwatch.elapsed, equals(Duration.zero));
3939
});
4040

41-
group("reports no elapsed", () {
42-
test("duration", () => expect(stopwatch.elapsed, equals(Duration.zero)));
43-
test("ticks", () => expect(stopwatch.elapsedTicks, isZero));
44-
test("microseconds", () => expect(stopwatch.elapsedMicroseconds, isZero));
45-
test("milliseconds", () => expect(stopwatch.elapsedMilliseconds, isZero));
41+
group('reports no elapsed', () {
42+
test('duration', () => expect(stopwatch.elapsed, equals(Duration.zero)));
43+
test('ticks', () => expect(stopwatch.elapsedTicks, isZero));
44+
test('microseconds', () => expect(stopwatch.elapsedMicroseconds, isZero));
45+
test('milliseconds', () => expect(stopwatch.elapsedMilliseconds, isZero));
4646
});
4747
});
4848

49-
group("when 12345μs have elapsed", () {
49+
group('when 12345μs have elapsed', () {
5050
DateTime time;
5151
Clock clock;
5252
Stopwatch stopwatch;
@@ -57,64 +57,64 @@ void main() {
5757
time = clock.microsFromNow(12345);
5858
});
5959

60-
group("and the stopwatch is active", () {
61-
test("is running", () {
60+
group('and the stopwatch is active', () {
61+
test('is running', () {
6262
expect(stopwatch.isRunning, isTrue);
6363
});
6464

65-
test("reports more elapsed time", () {
65+
test('reports more elapsed time', () {
6666
time = clock.microsFromNow(54321);
6767
expect(stopwatch.elapsedMicroseconds, equals(66666));
6868
});
6969

70-
test("start does nothing", () {
70+
test('start does nothing', () {
7171
stopwatch.start();
7272
expect(stopwatch.isRunning, isTrue);
7373
expect(stopwatch.elapsedMicroseconds, equals(12345));
7474
});
7575

76-
group("reset()", () {
76+
group('reset()', () {
7777
setUp(() {
7878
stopwatch.reset();
7979
});
8080

81-
test("sets the elapsed time to zero", () {
81+
test('sets the elapsed time to zero', () {
8282
expect(stopwatch.elapsed, equals(Duration.zero));
8383
});
8484

85-
test("reports more elapsed time", () {
85+
test('reports more elapsed time', () {
8686
time = clock.microsFromNow(54321);
8787
expect(stopwatch.elapsedMicroseconds, equals(54321));
8888
});
8989
});
9090

91-
group("reports elapsed", () {
92-
test("duration", () {
91+
group('reports elapsed', () {
92+
test('duration', () {
9393
expect(
9494
stopwatch.elapsed, equals(const Duration(microseconds: 12345)));
9595
});
9696

97-
test("ticks", () {
97+
test('ticks', () {
9898
expect(stopwatch.elapsedTicks,
9999
equals((Stopwatch().frequency * 12345) ~/ 1000000));
100100
});
101101

102-
test("microseconds", () {
102+
test('microseconds', () {
103103
expect(stopwatch.elapsedMicroseconds, equals(12345));
104104
});
105105

106-
test("milliseconds", () {
106+
test('milliseconds', () {
107107
expect(stopwatch.elapsedMilliseconds, equals(12));
108108
});
109109
});
110110
});
111111

112-
group("and the stopwatch is inactive, reports that as", () {
112+
group('and the stopwatch is inactive, reports that as', () {
113113
setUp(() {
114114
stopwatch.stop();
115115
});
116116

117-
test("is not running", () {
117+
test('is not running', () {
118118
expect(stopwatch.isRunning, isFalse);
119119
});
120120

@@ -123,19 +123,19 @@ void main() {
123123
expect(stopwatch.elapsedMicroseconds, equals(12345));
124124
});
125125

126-
test("start starts reporting more elapsed time", () {
126+
test('start starts reporting more elapsed time', () {
127127
stopwatch.start();
128128
expect(stopwatch.isRunning, isTrue);
129129
time = clock.microsFromNow(54321);
130130
expect(stopwatch.elapsedMicroseconds, equals(66666));
131131
});
132132

133-
group("reset()", () {
133+
group('reset()', () {
134134
setUp(() {
135135
stopwatch.reset();
136136
});
137137

138-
test("sets the elapsed time to zero", () {
138+
test('sets the elapsed time to zero', () {
139139
expect(stopwatch.elapsed, equals(Duration.zero));
140140
});
141141

@@ -145,22 +145,22 @@ void main() {
145145
});
146146
});
147147

148-
group("reports elapsed", () {
149-
test("duration", () {
148+
group('reports elapsed', () {
149+
test('duration', () {
150150
expect(
151151
stopwatch.elapsed, equals(const Duration(microseconds: 12345)));
152152
});
153153

154-
test("ticks", () {
154+
test('ticks', () {
155155
expect(stopwatch.elapsedTicks,
156156
equals((Stopwatch().frequency * 12345) ~/ 1000000));
157157
});
158158

159-
test("microseconds", () {
159+
test('microseconds', () {
160160
expect(stopwatch.elapsedMicroseconds, equals(12345));
161161
});
162162

163-
test("milliseconds", () {
163+
test('milliseconds', () {
164164
expect(stopwatch.elapsedMilliseconds, equals(12));
165165
});
166166
});

0 commit comments

Comments
 (0)