Skip to content

Commit 32cd04c

Browse files
committed
pkg/unittest: dartfmt
[email protected] Review URL: https://codereview.chromium.org//208593004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@34268 260f80e4-7a28-3924-810f-c04153c831b5
1 parent f13a5b7 commit 32cd04c

7 files changed

+47
-69
lines changed

pkg/unittest/lib/html_individual_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class HtmlIndividualConfiguration extends htmlconfig.HtmlConfiguration {
2828
.where((p) => p.startsWith('group='))
2929
.toList();
3030

31-
if(!groups.isEmpty) {
32-
if(groups.length > 1) {
31+
if (!groups.isEmpty) {
32+
if (groups.length > 1) {
3333
throw new ArgumentError('More than one "group" parameter provided.');
3434
}
3535

pkg/unittest/lib/src/core_matchers.dart

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class _Empty extends Matcher {
2121
return false;
2222
}
2323
}
24-
Description describe(Description description) =>
25-
description.add('empty');
24+
Description describe(Description description) => description.add('empty');
2625
}
2726

2827
/** A matcher that matches any null value. */
@@ -34,15 +33,13 @@ const Matcher isNotNull = const _IsNotNull();
3433
class _IsNull extends Matcher {
3534
const _IsNull();
3635
bool matches(item, Map matchState) => item == null;
37-
Description describe(Description description) =>
38-
description.add('null');
36+
Description describe(Description description) => description.add('null');
3937
}
4038

4139
class _IsNotNull extends Matcher {
4240
const _IsNotNull();
4341
bool matches(item, Map matchState) => item != null;
44-
Description describe(Description description) =>
45-
description.add('not null');
42+
Description describe(Description description) => description.add('not null');
4643
}
4744

4845
/** A matcher that matches the Boolean value true. */
@@ -54,15 +51,13 @@ const Matcher isFalse = const _IsFalse();
5451
class _IsTrue extends Matcher {
5552
const _IsTrue();
5653
bool matches(item, Map matchState) => item == true;
57-
Description describe(Description description) =>
58-
description.add('true');
54+
Description describe(Description description) => description.add('true');
5955
}
6056

6157
class _IsFalse extends Matcher {
6258
const _IsFalse();
6359
bool matches(item, Map matchState) => item == false;
64-
Description describe(Description description) =>
65-
description.add('false');
60+
Description describe(Description description) => description.add('false');
6661
}
6762

6863
/**
@@ -101,15 +96,15 @@ class _DeepMatcher extends Matcher {
10196
final int _limit;
10297
var count;
10398

104-
_DeepMatcher(this._expected, [limit = 1000]) : this._limit = limit;
99+
_DeepMatcher(this._expected, [limit = 1000]): this._limit = limit;
105100

106101
// Returns a pair (reason, location)
107102
List _compareIterables(expected, actual, matcher, depth, location) {
108103
if (actual is! Iterable) return ['is not Iterable', location];
109104

110105
var expectedIterator = expected.iterator;
111106
var actualIterator = actual.iterator;
112-
for (var index = 0;; index++) {
107+
for (var index = 0; ; index++) {
113108
// Advance in lockstep.
114109
var expectedNext = expectedIterator.moveNext();
115110
var actualNext = actualIterator.moveNext();
@@ -324,8 +319,7 @@ const Matcher anything = const _IsAnything();
324319
class _IsAnything extends Matcher {
325320
const _IsAnything();
326321
bool matches(item, Map matchState) => true;
327-
Description describe(Description description) =>
328-
description.add('anything');
322+
Description describe(Description description) => description.add('anything');
329323
}
330324

331325
/**
@@ -352,7 +346,7 @@ class _IsAnything extends Matcher {
352346
*/
353347
class isInstanceOf<T> extends Matcher {
354348
final String _name;
355-
const isInstanceOf([name = 'specified type']) : this._name = name;
349+
const isInstanceOf([name = 'specified type']): this._name = name;
356350
bool matches(obj, Map matchState) => obj is T;
357351
// The description here is lame :-(
358352
Description describe(Description description) =>
@@ -405,8 +399,7 @@ const Matcher returnsNormally = const _ReturnsNormally();
405399
class Throws extends Matcher {
406400
final Matcher _matcher;
407401

408-
const Throws([Matcher matcher]) :
409-
this._matcher = matcher;
402+
const Throws([Matcher matcher]): this._matcher = matcher;
410403

411404
bool matches(item, Map matchState) {
412405
if (item is! Function && item is! Future) return false;
@@ -523,19 +516,17 @@ class _ReturnsNormally extends Matcher {
523516
abstract class TypeMatcher extends Matcher {
524517
final String _name;
525518
const TypeMatcher(this._name);
526-
Description describe(Description description) =>
527-
description.add(_name);
519+
Description describe(Description description) => description.add(_name);
528520
}
529521

530522
/** A matcher for FormatExceptions. */
531523
const isFormatException = const _FormatException();
532524

533525
/** A matcher for functions that throw FormatException. */
534-
const Matcher throwsFormatException =
535-
const Throws(isFormatException);
526+
const Matcher throwsFormatException = const Throws(isFormatException);
536527

537528
class _FormatException extends TypeMatcher {
538-
const _FormatException() : super("FormatException");
529+
const _FormatException(): super("FormatException");
539530
bool matches(item, Map matchState) => item is FormatException;
540531
}
541532

@@ -546,55 +537,51 @@ const isException = const _Exception();
546537
const Matcher throwsException = const Throws(isException);
547538

548539
class _Exception extends TypeMatcher {
549-
const _Exception() : super("Exception");
540+
const _Exception(): super("Exception");
550541
bool matches(item, Map matchState) => item is Exception;
551542
}
552543

553544
/** A matcher for ArgumentErrors. */
554545
const isArgumentError = const _ArgumentError();
555546

556547
/** A matcher for functions that throw ArgumentError. */
557-
const Matcher throwsArgumentError =
558-
const Throws(isArgumentError);
548+
const Matcher throwsArgumentError = const Throws(isArgumentError);
559549

560550
class _ArgumentError extends TypeMatcher {
561-
const _ArgumentError() : super("ArgumentError");
551+
const _ArgumentError(): super("ArgumentError");
562552
bool matches(item, Map matchState) => item is ArgumentError;
563553
}
564554

565555
/** A matcher for RangeErrors. */
566556
const isRangeError = const _RangeError();
567557

568558
/** A matcher for functions that throw RangeError. */
569-
const Matcher throwsRangeError =
570-
const Throws(isRangeError);
559+
const Matcher throwsRangeError = const Throws(isRangeError);
571560

572561
class _RangeError extends TypeMatcher {
573-
const _RangeError() : super("RangeError");
562+
const _RangeError(): super("RangeError");
574563
bool matches(item, Map matchState) => item is RangeError;
575564
}
576565

577566
/** A matcher for NoSuchMethodErrors. */
578567
const isNoSuchMethodError = const _NoSuchMethodError();
579568

580569
/** A matcher for functions that throw NoSuchMethodError. */
581-
const Matcher throwsNoSuchMethodError =
582-
const Throws(isNoSuchMethodError);
570+
const Matcher throwsNoSuchMethodError = const Throws(isNoSuchMethodError);
583571

584572
class _NoSuchMethodError extends TypeMatcher {
585-
const _NoSuchMethodError() : super("NoSuchMethodError");
573+
const _NoSuchMethodError(): super("NoSuchMethodError");
586574
bool matches(item, Map matchState) => item is NoSuchMethodError;
587575
}
588576

589577
/** A matcher for UnimplementedErrors. */
590578
const isUnimplementedError = const _UnimplementedError();
591579

592580
/** A matcher for functions that throw Exception. */
593-
const Matcher throwsUnimplementedError =
594-
const Throws(isUnimplementedError);
581+
const Matcher throwsUnimplementedError = const Throws(isUnimplementedError);
595582

596583
class _UnimplementedError extends TypeMatcher {
597-
const _UnimplementedError() : super("UnimplementedError");
584+
const _UnimplementedError(): super("UnimplementedError");
598585
bool matches(item, Map matchState) => item is UnimplementedError;
599586
}
600587

@@ -605,44 +592,40 @@ const isUnsupportedError = const _UnsupportedError();
605592
const Matcher throwsUnsupportedError = const Throws(isUnsupportedError);
606593

607594
class _UnsupportedError extends TypeMatcher {
608-
const _UnsupportedError() :
609-
super("UnsupportedError");
595+
const _UnsupportedError(): super("UnsupportedError");
610596
bool matches(item, Map matchState) => item is UnsupportedError;
611597
}
612598

613599
/** A matcher for StateErrors. */
614600
const isStateError = const _StateError();
615601

616602
/** A matcher for functions that throw StateError. */
617-
const Matcher throwsStateError =
618-
const Throws(isStateError);
603+
const Matcher throwsStateError = const Throws(isStateError);
619604

620605
class _StateError extends TypeMatcher {
621-
const _StateError() : super("StateError");
606+
const _StateError(): super("StateError");
622607
bool matches(item, Map matchState) => item is StateError;
623608
}
624609

625610
/** A matcher for FallThroughError. */
626611
const isFallThroughError = const _FallThroughError();
627612

628613
/** A matcher for functions that throw FallThroughError. */
629-
const Matcher throwsFallThroughError =
630-
const Throws(isFallThroughError);
614+
const Matcher throwsFallThroughError = const Throws(isFallThroughError);
631615

632616
class _FallThroughError extends TypeMatcher {
633-
const _FallThroughError() : super("FallThroughError");
617+
const _FallThroughError(): super("FallThroughError");
634618
bool matches(item, Map matchState) => item is FallThroughError;
635619
}
636620

637621
/** A matcher for NullThrownError. */
638622
const isNullThrownError = const _NullThrownError();
639623

640624
/** A matcher for functions that throw NullThrownError. */
641-
const Matcher throwsNullThrownError =
642-
const Throws(isNullThrownError);
625+
const Matcher throwsNullThrownError = const Throws(isNullThrownError);
643626

644627
class _NullThrownError extends TypeMatcher {
645-
const _NullThrownError() : super("NullThrownError");
628+
const _NullThrownError(): super("NullThrownError");
646629
bool matches(item, Map matchState) => item is NullThrownError;
647630
}
648631

@@ -654,7 +637,7 @@ const Matcher throwsConcurrentModificationError =
654637
const Throws(isConcurrentModificationError);
655638

656639
class _ConcurrentModificationError extends TypeMatcher {
657-
const _ConcurrentModificationError() : super("ConcurrentModificationError");
640+
const _ConcurrentModificationError(): super("ConcurrentModificationError");
658641
bool matches(item, Map matchState) => item is ConcurrentModificationError;
659642
}
660643

@@ -680,36 +663,35 @@ const Matcher throwsCyclicInitializationError =
680663
const Throws(isCyclicInitializationError);
681664

682665
class _CyclicInitializationError extends TypeMatcher {
683-
const _CyclicInitializationError() : super("CyclicInitializationError");
666+
const _CyclicInitializationError(): super("CyclicInitializationError");
684667
bool matches(item, Map matchState) => item is CyclicInitializationError;
685668
}
686669

687670
/** A matcher for Map types. */
688671
const isMap = const _IsMap();
689672

690673
class _IsMap extends TypeMatcher {
691-
const _IsMap() : super("Map");
674+
const _IsMap(): super("Map");
692675
bool matches(item, Map matchState) => item is Map;
693676
}
694677

695678
/** A matcher for List types. */
696679
const isList = const _IsList();
697680

698681
class _IsList extends TypeMatcher {
699-
const _IsList() : super("List");
682+
const _IsList(): super("List");
700683
bool matches(item, Map matchState) => item is List;
701684
}
702685

703686
/**
704687
* Returns a matcher that matches if an object has a length property
705688
* that matches [matcher].
706689
*/
707-
Matcher hasLength(matcher) =>
708-
new _HasLength(wrapMatcher(matcher));
690+
Matcher hasLength(matcher) => new _HasLength(wrapMatcher(matcher));
709691

710692
class _HasLength extends Matcher {
711693
final Matcher _matcher;
712-
const _HasLength([Matcher matcher = null]) : this._matcher = matcher;
694+
const _HasLength([Matcher matcher = null]): this._matcher = matcher;
713695

714696
bool matches(item, Map matchState) {
715697
try {
@@ -820,7 +802,7 @@ class _In extends Matcher {
820802
*
821803
* expect(v, predicate((x) => ((x % 2) == 0), "is even"))
822804
*/
823-
Matcher predicate(Function f, [description ='satisfies function']) =>
805+
Matcher predicate(Function f, [description = 'satisfies function']) =>
824806
new _Predicate(f, description);
825807

826808
class _Predicate extends Matcher {

pkg/unittest/lib/src/interfaces.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ abstract class Description {
4141
* This is used to add a description of an [Iterable] [list],
4242
* with appropriate [start] and [end] markers and inter-element [separator].
4343
*/
44-
Description addAll(String start, String separator, String end,
45-
Iterable list);
44+
Description addAll(String start, String separator, String end, Iterable list);
4645
}
4746

4847
/**

pkg/unittest/lib/src/iterable_matchers.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ abstract class _IterableMatcher extends Matcher {
156156
*
157157
* Note that this is `O(n^2)` and so should only be used on small objects.
158158
*/
159-
Matcher unorderedMatches(Iterable expected) =>
160-
new _UnorderedMatches(expected);
159+
Matcher unorderedMatches(Iterable expected) => new _UnorderedMatches(expected);
161160

162161
class _UnorderedMatches extends Matcher {
163162
final List<Matcher> _expected;
@@ -166,7 +165,7 @@ class _UnorderedMatches extends Matcher {
166165
: _expected = expected.map(wrapMatcher).toList();
167166

168167
String _test(item) {
169-
if (item is !Iterable) return 'not iterable';
168+
if (item is! Iterable) return 'not iterable';
170169
item = item.toList();
171170

172171
// Check the lengths are the same.

pkg/unittest/lib/src/operator_matchers.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ class _IsNot extends Matcher {
1414

1515
const _IsNot(Matcher this._matcher);
1616

17-
bool matches(item, Map matchState) =>
18-
!_matcher.matches(item, matchState);
17+
bool matches(item, Map matchState) => !_matcher.matches(item, matchState);
1918

2019
Description describe(Description description) =>
2120
description.add('not ').addDescriptionOf(_matcher);

pkg/unittest/lib/src/simple_configuration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class SimpleConfiguration extends Configuration {
5656
* The constructor sets up a failure handler for [expect] that redirects
5757
* [expect] failures to [onExpectFailure].
5858
*/
59-
SimpleConfiguration() : super.blank() {
59+
SimpleConfiguration(): super.blank() {
6060
configureExpectFailureHandler(new _ExpectFailureHandler(this));
6161
}
6262

pkg/unittest/lib/unittest.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,13 @@ void test(String spec, TestFunction body) {
269269
ensureInitialized();
270270
if (!_soloTestSeen || _soloNestingLevel > 0) {
271271
var testcase = new TestCase._internal(testCases.length + 1, _fullSpec(spec),
272-
body);
272+
body);
273273
_testCases.add(testcase);
274274
}
275275
}
276276

277277
/** Convenience function for skipping a test. */
278-
void skip_test(String spec, TestFunction body){}
278+
void skip_test(String spec, TestFunction body) {}
279279

280280
/**
281281
* Creates a new test case with the given description and body. The
@@ -671,8 +671,7 @@ void _ensureInitialized(bool configAutoStart) {
671671
}
672672

673673
/** Select a solo test by ID. */
674-
void setSoloTest(int id) =>
675-
_testCases.retainWhere((t) => t.id == id);
674+
void setSoloTest(int id) => _testCases.retainWhere((t) => t.id == id);
676675

677676
/** Enable/disable a test by ID. */
678677
void _setTestEnabledState(int testId, bool state) {
@@ -713,7 +712,7 @@ bool formatStacks = true;
713712
bool filterStacks = true;
714713

715714
void _requireNotRunning() {
716-
if(_currentTestCaseIndex != -1) {
715+
if (_currentTestCaseIndex != -1) {
717716
throw new StateError('Not allowed when tests are running.');
718717
}
719718
}

0 commit comments

Comments
 (0)