Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: pkg/unittest/test/matchers_test.dart

Issue 15492003: Split out unittest tests whose behavior differs in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/unittest/test/matchers_test.dart
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/unittest/test/matchers_test.dart
index 277641ac9849b78ca535212af8d3817fa48899e6..be2d99299af8d216d0b8288612a16ad07403e13c 100644
--- a/pkg/unittest/test/matchers_test.dart
+++ b/pkg/unittest/test/matchers_test.dart
@@ -2,77 +2,11 @@
// 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.
-library unittestTests;
-import 'package:unittest/unittest.dart';
import 'dart:async';
-import 'dart:collection';
-part 'test_utils.dart';
-
-doesNotThrow() {}
-doesThrow() { throw 'X'; }
-
-class PrefixMatcher extends BaseMatcher {
- final String _prefix;
- const PrefixMatcher(this._prefix);
- bool matches(item, MatchState matchState) {
- return item is String &&
- (collapseWhitespace(item)).startsWith(collapseWhitespace(_prefix));
- }
-
- Description describe(Description description) =>
- description.add('a string starting with ').
- addDescriptionOf(collapseWhitespace(_prefix)).
- add(' ignoring whitespace');
-}
-
-class Widget {
- int price;
-}
-
-class HasPrice extends CustomMatcher {
- HasPrice(matcher) :
- super("Widget with a price that is", "price", matcher);
- featureValueOf(actual) => actual.price;
-}
-
-class SimpleIterable extends IterableBase {
- int count;
- SimpleIterable(this.count);
-
- bool contains(int val) => count < val ? false : true;
-
- bool any(bool f(element)) {
- for(var i = 0; i <= count; i++) {
- if(f(i)) return true;
- }
- return false;
- }
-
- String toString() => "<[$count]>";
-
- Iterator get iterator {
- return new SimpleIterator(count);
- }
-}
-class SimpleIterator implements Iterator {
- int _count;
- int _current;
-
- SimpleIterator(this._count);
-
- bool moveNext() {
- if (_count > 0) {
- _current = _count;
- _count--;
- return true;
- }
- _current = null;
- return false;
- }
+import 'package:unittest/unittest.dart';
- get current => _current;
-}
+import 'test_utils.dart';
void main() {
@@ -147,89 +81,6 @@ void main() {
r"from Function 'doesThrow': static\.)?>"));
});
- test('throwsFormatException', () {
- shouldPass(() { throw new FormatException(''); },
- throwsFormatException);
- shouldFail(() { throw new Exception(); },
- throwsFormatException,
- matches(
- r"Expected: throws an exception which matches FormatException +"
- r"But: exception \?:<Exception> does not match FormatException\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsArgumentError', () {
- shouldPass(() { throw new ArgumentError(''); },
- throwsArgumentError);
- shouldFail(() { throw new Exception(); },
- throwsArgumentError,
- matches(
- r"Expected: throws an exception which matches ArgumentError +"
- r"But: exception \?:<Exception> does not match "
- r"ArgumentError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsRangeError', () {
- shouldPass(() { throw new RangeError(0); },
- throwsRangeError);
- shouldFail(() { throw new Exception(); },
- throwsRangeError,
- matches(
- r"Expected: throws an exception which matches RangeError +"
- r"But: exception \?:<Exception> does not match RangeError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsNoSuchMethodError', () {
- shouldPass(() { throw new NoSuchMethodError(null, '', null, null); },
- throwsNoSuchMethodError);
- shouldFail(() { throw new Exception(); },
- throwsNoSuchMethodError,
- matches(
- r"Expected: throws an exception which matches NoSuchMethodError +"
- r"But: exception \?:<Exception> does not match "
- r"NoSuchMethodError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsUnimplementedError', () {
- shouldPass(() { throw new UnimplementedError(''); },
- throwsUnimplementedError);
- shouldFail(() { throw new Exception(); },
- throwsUnimplementedError,
- matches(
- r"Expected: throws an exception which matches "
- r"UnimplementedError +"
- r"But: exception \?:<Exception> does not match "
- r"UnimplementedError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsUnsupportedError', () {
- shouldPass(() { throw new UnsupportedError(''); },
- throwsUnsupportedError);
- shouldFail(() { throw new Exception(); },
- throwsUnsupportedError,
- matches(
- r"Expected: throws an exception which matches UnsupportedError +"
- r"But: exception \?:<Exception> does not match "
- r"UnsupportedError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
- test('throwsStateError', () {
- shouldPass(() { throw new StateError(''); },
- throwsStateError);
- shouldFail(() { throw new Exception(); },
- throwsStateError,
- matches(
- r"Expected: throws an exception which matches StateError +"
- r"But: exception \?:<Exception> does not match "
- r"StateError\."
- r"Actual: <Closure(: \(dynamic\) => dynamic)?>"));
- });
-
test('returnsNormally', () {
shouldPass(doesNotThrow, returnsNormally);
shouldFail(doesThrow, returnsNormally,
@@ -482,23 +333,6 @@ void main() {
});
group('Iterable Matchers', () {
- test('isEmpty', () {
- var d = new SimpleIterable(0);
- var e = new SimpleIterable(1);
- shouldPass(d, isEmpty);
- shouldFail(e, isEmpty, "Expected: empty But: was SimpleIterable:[1].");
- });
-
- test('contains', () {
- var d = new SimpleIterable(3);
- shouldPass(d, contains(2));
- shouldFail(d, contains(5),
- "Expected: contains <5> "
- "But: was SimpleIterable:[3, 2, 1].");
- });
- });
-
- group('Iterable Matchers', () {
test('isEmpty', () {
shouldPass([], isEmpty);
@@ -774,18 +608,5 @@ void main() {
shouldPass('cow', predicate((x) => x is String, "an instance of String"));
});
});
-
- group('Feature Matchers', () {
- test("Feature Matcher", () {
- var w = new Widget();
- w.price = 10;
- shouldPass(w, new HasPrice(10));
- shouldPass(w, new HasPrice(greaterThan(0)));
- shouldFail(w, new HasPrice(greaterThan(10)),
- "Expected: Widget with a price that is a value greater than <10> "
- "But: price was <10>. "
- "Actual: <Instance of 'Widget'>");
- });
- });
}

Powered by Google App Engine
This is Rietveld 408576698