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

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

Issue 208823005: pkg/matcher (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 6 years, 9 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
« no previous file with comments | « pkg/matcher/test/matchers_minified_test.dart ('k') | pkg/matcher/test/matchers_unminified_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/matcher/test/matchers_test.dart
diff --git a/pkg/unittest/test/matchers_test.dart b/pkg/matcher/test/matchers_test.dart
similarity index 88%
copy from pkg/unittest/test/matchers_test.dart
copy to pkg/matcher/test/matchers_test.dart
index dc2b37aef82a3e4d89a325cdc692e0888a7a8fff..3d75bd9442d2ef5d758cdc758c5ee24c9600bc49 100644
--- a/pkg/unittest/test/matchers_test.dart
+++ b/pkg/matcher/test/matchers_test.dart
@@ -5,7 +5,8 @@
import 'dart:async';
import 'dart:collection';
-import 'package:unittest/unittest.dart';
+import 'package:matcher/matcher.dart';
+import 'package:unittest/unittest.dart' as ut;
import 'test_utils.dart';
@@ -15,44 +16,44 @@ void main() {
// Core matchers
- group('Core matchers', () {
+ ut.group('Core matchers', () {
- test('isTrue', () {
+ ut.test('isTrue', () {
shouldPass(true, isTrue);
shouldFail(false, isTrue, "Expected: true Actual: <false>");
});
- test('isFalse', () {
+ ut.test('isFalse', () {
shouldPass(false, isFalse);
shouldFail(10, isFalse, "Expected: false Actual: <10>");
shouldFail(true, isFalse, "Expected: false Actual: <true>");
});
- test('isNull', () {
+ ut.test('isNull', () {
shouldPass(null, isNull);
shouldFail(false, isNull, "Expected: null Actual: <false>");
});
- test('isNotNull', () {
+ ut.test('isNotNull', () {
shouldPass(false, isNotNull);
shouldFail(null, isNotNull, "Expected: not null Actual: <null>");
});
- test('same', () {
+ ut.test('same', () {
var a = new Map();
var b = new Map();
shouldPass(a, same(a));
shouldFail(b, same(a), "Expected: same instance as {} Actual: {}");
});
- test('equals', () {
+ ut.test('equals', () {
var a = new Map();
var b = new Map();
shouldPass(a, equals(a));
shouldPass(a, equals(b));
});
- test('anything', () {
+ ut.test('anything', () {
var a = new Map();
shouldPass(0, anything);
shouldPass(null, anything);
@@ -60,7 +61,7 @@ void main() {
shouldFail(a, isNot(anything), "Expected: not anything Actual: {}");
});
- test('throws', () {
+ ut.test('throws', () {
shouldFail(doesNotThrow, throws,
matches(
r"Expected: throws"
@@ -74,7 +75,7 @@ void main() {
" Which: is not a Function or Future");
});
- test('throwsA', () {
+ ut.test('throwsA', () {
shouldPass(doesThrow, throwsA(equals('X')));
shouldFail(doesThrow, throwsA(equals('Y')),
matches(
@@ -84,7 +85,7 @@ void main() {
r" Which: threw 'X'"));
});
- test('returnsNormally', () {
+ ut.test('returnsNormally', () {
shouldPass(doesNotThrow, returnsNormally);
shouldFail(doesThrow, returnsNormally,
matches(
@@ -95,7 +96,7 @@ void main() {
});
- test('hasLength', () {
+ ut.test('hasLength', () {
var a = new Map();
var b = new List();
shouldPass(a, hasLength(0));
@@ -121,27 +122,27 @@ void main() {
shouldPass(b, hasLength(2));
});
- test('scalar type mismatch', () {
+ ut.test('scalar type mismatch', () {
shouldFail('error', equals(5.1),
"Expected: <5.1> "
"Actual: 'error'");
});
- test('nested type mismatch', () {
+ ut.test('nested type mismatch', () {
shouldFail(['error'], equals([5.1]),
"Expected: [5.1] "
"Actual: ['error'] "
"Which: was 'error' instead of <5.1> at location [0]");
});
- test('doubly-nested type mismatch', () {
+ ut.test('doubly-nested type mismatch', () {
shouldFail([['error']], equals([[5.1]]),
"Expected: [[5.1]] "
"Actual: [['error']] "
"Which: was 'error' instead of <5.1> at location [0][0]");
});
- test('doubly nested inequality', () {
+ ut.test('doubly nested inequality', () {
var actual1 = [['foo', 'bar'], ['foo'], 3, []];
var expected1 = [['foo', 'bar'], ['foo'], 4, []];
var reason1 = "Expected: [['foo', 'bar'], ['foo'], 4, []] "
@@ -166,9 +167,9 @@ void main() {
});
});
- group('Numeric Matchers', () {
+ ut.group('Numeric Matchers', () {
- test('greaterThan', () {
+ ut.test('greaterThan', () {
shouldPass(10, greaterThan(9));
shouldFail(9, greaterThan(10),
"Expected: a value greater than <10> "
@@ -176,7 +177,7 @@ void main() {
"Which: is not a value greater than <10>");
});
- test('greaterThanOrEqualTo', () {
+ ut.test('greaterThanOrEqualTo', () {
shouldPass(10, greaterThanOrEqualTo(10));
shouldFail(9, greaterThanOrEqualTo(10),
"Expected: a value greater than or equal to <10> "
@@ -184,7 +185,7 @@ void main() {
"Which: is not a value greater than or equal to <10>");
});
- test('lessThan', () {
+ ut.test('lessThan', () {
shouldFail(10, lessThan(9),
"Expected: a value less than <9> "
"Actual: <10> "
@@ -192,7 +193,7 @@ void main() {
shouldPass(9, lessThan(10));
});
- test('lessThanOrEqualTo', () {
+ ut.test('lessThanOrEqualTo', () {
shouldPass(10, lessThanOrEqualTo(10));
shouldFail(11, lessThanOrEqualTo(10),
"Expected: a value less than or equal to <10> "
@@ -200,7 +201,7 @@ void main() {
"Which: is not a value less than or equal to <10>");
});
- test('isZero', () {
+ ut.test('isZero', () {
shouldPass(0, isZero);
shouldFail(1, isZero,
"Expected: a value equal to <0> "
@@ -208,7 +209,7 @@ void main() {
"Which: is not a value equal to <0>");
});
- test('isNonZero', () {
+ ut.test('isNonZero', () {
shouldFail(0, isNonZero,
"Expected: a value not equal to <0> "
"Actual: <0> "
@@ -216,7 +217,7 @@ void main() {
shouldPass(1, isNonZero);
});
- test('isPositive', () {
+ ut.test('isPositive', () {
shouldFail(-1, isPositive,
"Expected: a positive value "
"Actual: <-1> "
@@ -228,7 +229,7 @@ void main() {
shouldPass(1, isPositive);
});
- test('isNegative', () {
+ ut.test('isNegative', () {
shouldPass(-1, isNegative);
shouldFail(0, isNegative,
"Expected: a negative value "
@@ -236,7 +237,7 @@ void main() {
"Which: is not a negative value");
});
- test('isNonPositive', () {
+ ut.test('isNonPositive', () {
shouldPass(-1, isNonPositive);
shouldPass(0, isNonPositive);
shouldFail(1, isNonPositive,
@@ -245,7 +246,7 @@ void main() {
"Which: is not a non-positive value");
});
- test('isNonNegative', () {
+ ut.test('isNonNegative', () {
shouldPass(1, isNonNegative);
shouldPass(0, isNonNegative);
shouldFail(-1, isNonNegative,
@@ -254,7 +255,7 @@ void main() {
"Which: is not a non-negative value");
});
- test('closeTo', () {
+ ut.test('closeTo', () {
shouldPass(0, closeTo(0, 1));
shouldPass(-1, closeTo(0, 1));
shouldPass(1, closeTo(0, 1));
@@ -268,7 +269,7 @@ void main() {
"Which: differs by <1.001>");
});
- test('inInclusiveRange', () {
+ ut.test('inInclusiveRange', () {
shouldFail(-1, inInclusiveRange(0,2),
"Expected: be in range from 0 (inclusive) to 2 (inclusive) "
"Actual: <-1>");
@@ -280,7 +281,7 @@ void main() {
"Actual: <3>");
});
- test('inExclusiveRange', () {
+ ut.test('inExclusiveRange', () {
shouldFail(0, inExclusiveRange(0,2),
"Expected: be in range from 0 (exclusive) to 2 (exclusive) "
"Actual: <0>");
@@ -290,7 +291,7 @@ void main() {
"Actual: <2>");
});
- test('inOpenClosedRange', () {
+ ut.test('inOpenClosedRange', () {
shouldFail(0, inOpenClosedRange(0,2),
"Expected: be in range from 0 (exclusive) to 2 (inclusive) "
"Actual: <0>");
@@ -298,7 +299,7 @@ void main() {
shouldPass(2, inOpenClosedRange(0,2));
});
- test('inClosedOpenRange', () {
+ ut.test('inClosedOpenRange', () {
shouldPass(0, inClosedOpenRange(0,2));
shouldPass(1, inClosedOpenRange(0,2));
shouldFail(2, inClosedOpenRange(0,2),
@@ -307,9 +308,9 @@ void main() {
});
});
- group('String Matchers', () {
+ ut.group('String Matchers', () {
- test('isEmpty', () {
+ ut.test('isEmpty', () {
shouldPass('', isEmpty);
shouldFail(null, isEmpty,
"Expected: empty Actual: <null>");
@@ -318,13 +319,13 @@ void main() {
shouldFail('a', isEmpty, "Expected: empty Actual: 'a'");
});
- test('equalsIgnoringCase', () {
+ ut.test('equalsIgnoringCase', () {
shouldPass('hello', equalsIgnoringCase('HELLO'));
shouldFail('hi', equalsIgnoringCase('HELLO'),
"Expected: 'HELLO' ignoring case Actual: 'hi'");
});
- test('equalsIgnoringWhitespace', () {
+ ut.test('equalsIgnoringWhitespace', () {
shouldPass(' hello world ', equalsIgnoringWhitespace('hello world'));
shouldFail(' helloworld ', equalsIgnoringWhitespace('hello world'),
"Expected: 'hello world' ignoring whitespace "
@@ -332,7 +333,7 @@ void main() {
"Which: is 'helloworld' with whitespace compressed");
});
- test('startsWith', () {
+ ut.test('startsWith', () {
shouldPass('hello', startsWith(''));
shouldPass('hello', startsWith('hell'));
shouldPass('hello', startsWith('hello'));
@@ -341,7 +342,7 @@ void main() {
"Actual: 'hello'");
});
- test('endsWith', () {
+ ut.test('endsWith', () {
shouldPass('hello', endsWith(''));
shouldPass('hello', endsWith('lo'));
shouldPass('hello', endsWith('hello'));
@@ -350,7 +351,7 @@ void main() {
"Actual: 'hello'");
});
- test('contains', () {
+ ut.test('contains', () {
shouldPass('hello', contains(''));
shouldPass('hello', contains('h'));
shouldPass('hello', contains('o'));
@@ -360,7 +361,7 @@ void main() {
"Expected: contains ' ' Actual: 'hello'");
});
- test('stringContainsInOrder', () {
+ ut.test('stringContainsInOrder', () {
shouldPass('goodbye cruel world', stringContainsInOrder(['']));
shouldPass('goodbye cruel world', stringContainsInOrder(['goodbye']));
shouldPass('goodbye cruel world', stringContainsInOrder(['cruel']));
@@ -379,7 +380,7 @@ void main() {
"Actual: 'goodbye cruel world'");
});
- test('matches', () {
+ ut.test('matches', () {
shouldPass('c0d', matches('[a-z][0-9][a-z]'));
shouldPass('c0d', matches(new RegExp('[a-z][0-9][a-z]')));
shouldFail('cOd', matches('[a-z][0-9][a-z]'),
@@ -387,21 +388,21 @@ void main() {
});
});
- group('Iterable Matchers', () {
+ ut.group('Iterable Matchers', () {
- test('isEmpty', () {
+ ut.test('isEmpty', () {
shouldPass([], isEmpty);
shouldFail([1], isEmpty, "Expected: empty Actual: [1]");
});
- test('contains', () {
+ ut.test('contains', () {
var d = [1, 2];
shouldPass(d, contains(1));
shouldFail(d, contains(0), "Expected: contains <0> "
"Actual: [1, 2]");
});
- test('equals with matcher element', () {
+ ut.test('equals with matcher element', () {
var d = ['foo', 'bar'];
shouldPass(d, equals(['foo', startsWith('ba')]));
shouldFail(d, equals(['foo', endsWith('ba')]),
@@ -410,13 +411,13 @@ void main() {
"Which: does not match a string ending with 'ba' at location [1]");
});
- test('isIn', () {
+ ut.test('isIn', () {
var d = [1, 2];
shouldPass(1, isIn(d));
shouldFail(0, isIn(d), "Expected: is in [1, 2] Actual: <0>");
});
- test('everyElement', () {
+ ut.test('everyElement', () {
var d = [1, 2];
var e = [1, 1, 1];
shouldFail(d, everyElement(1),
@@ -426,7 +427,7 @@ void main() {
shouldPass(e, everyElement(1));
});
- test('nested everyElement', () {
+ ut.test('nested everyElement', () {
var d = [['foo', 'bar'], ['foo'], []];
var e = [['foo', 'bar'], ['foo'], 3, []];
shouldPass(d, everyElement(anyOf(isEmpty, contains('foo'))));
@@ -458,7 +459,7 @@ void main() {
"at index 2");
});
- test('anyElement', () {
+ ut.test('anyElement', () {
var d = [1, 2];
var e = [1, 1, 1];
shouldPass(d, anyElement(2));
@@ -466,7 +467,7 @@ void main() {
"Expected: some element <2> Actual: [1, 1, 1]");
});
- test('orderedEquals', () {
+ ut.test('orderedEquals', () {
shouldPass([null], orderedEquals([null]));
var d = [1, 2];
shouldPass(d, orderedEquals([1, 2]));
@@ -476,7 +477,7 @@ void main() {
"Which: was <1> instead of <2> at location [0]");
});
- test('unorderedEquals', () {
+ ut.test('unorderedEquals', () {
var d = [1, 2];
shouldPass(d, unorderedEquals([2, 1]));
shouldFail(d, unorderedEquals([1]),
@@ -493,7 +494,7 @@ void main() {
"Which: has no match for <3> at index 0");
});
- test('unorderedMatchess', () {
+ ut.test('unorderedMatchess', () {
var d = [1, 2];
shouldPass(d, unorderedMatches([2, 1]));
shouldPass(d, unorderedMatches([greaterThan(1), greaterThan(0)]));
@@ -516,7 +517,7 @@ void main() {
"Which: has no match for a value greater than <3> at index 0");
});
- test('pairwise compare', () {
+ ut.test('pairwise compare', () {
var c = [1, 2];
var d = [1, 2, 3];
var e = [1, 4, 9];
@@ -542,9 +543,9 @@ void main() {
});
});
- group('Map Matchers', () {
+ ut.group('Map Matchers', () {
- test('isEmpty', () {
+ ut.test('isEmpty', () {
var a = new Map();
shouldPass({}, isEmpty);
shouldPass(a, isEmpty);
@@ -553,7 +554,7 @@ void main() {
"Actual: {'foo': 'bar'}");
});
- test('equals', () {
+ ut.test('equals', () {
var a = new Map();
a['foo'] = 'bar';
var b = new Map();
@@ -567,7 +568,7 @@ void main() {
"Which: is missing map key 'bar'");
});
- test('equals with different lengths', () {
+ ut.test('equals with different lengths', () {
var a = new LinkedHashMap();
a['foo'] = 'bar';
var b = new LinkedHashMap();
@@ -602,7 +603,7 @@ void main() {
"Which: has different length and is missing map key 'foo'");
});
- test('equals with matcher value', () {
+ ut.test('equals with matcher value', () {
var a = new Map();
a['foo'] = 'bar';
shouldPass(a, equals({'foo': startsWith('ba')}));
@@ -613,7 +614,7 @@ void main() {
"at location ['foo']");
});
- test('contains', () {
+ ut.test('contains', () {
var a = new Map();
a['foo'] = 'bar';
var b = new Map();
@@ -625,7 +626,7 @@ void main() {
"Which: is not a string, map or iterable");
});
- test('containsValue', () {
+ ut.test('containsValue', () {
var a = new Map();
a['foo'] = 'bar';
shouldPass(a, containsValue('bar'));
@@ -634,7 +635,7 @@ void main() {
"Actual: {'foo': 'bar'}");
});
- test('containsPair', () {
+ ut.test('containsPair', () {
var a = new Map();
a['foo'] = 'bar';
shouldPass(a, containsPair('foo', 'bar'));
@@ -649,7 +650,7 @@ void main() {
"Which: doesn't contain key 'fo'");
});
- test('hasLength', () {
+ ut.test('hasLength', () {
var a = new Map();
a['foo'] = 'bar';
var b = new Map();
@@ -661,15 +662,15 @@ void main() {
});
});
- group('Operator Matchers', () {
+ ut.group('Operator Matchers', () {
- test('anyOf', () {
+ ut.test('anyOf', () {
shouldFail(0, anyOf([equals(1), equals(2)]),
"Expected: (<1> or <2>) Actual: <0>");
shouldPass(1, anyOf([equals(1), equals(2)]));
});
- test('allOf', () {
+ ut.test('allOf', () {
shouldPass(1, allOf([lessThan(10), greaterThan(0)]));
shouldFail(-1, allOf([lessThan(10), greaterThan(0)]),
"Expected: (a value less than <10> and a value greater than <0>) "
@@ -678,9 +679,9 @@ void main() {
});
});
- group('Future Matchers', () {
+ ut.group('Future Matchers', () {
- test('completes - unexpected error', () {
+ ut.test('completes - unexpected error', () {
var completer = new Completer();
completer.completeError('X');
shouldFail(completer.future, completes,
@@ -689,13 +690,13 @@ void main() {
isAsync: true);
});
- test('completes - successfully', () {
+ ut.test('completes - successfully', () {
var completer = new Completer();
completer.complete('1');
shouldPass(completer.future, completes, isAsync: true);
});
- test('throws - unexpected to see normal completion', () {
+ ut.test('throws - unexpected to see normal completion', () {
var completer = new Completer();
completer.complete('1');
shouldFail(completer.future, throws,
@@ -703,20 +704,20 @@ void main() {
isAsync: true);
});
- test('throws - expected to see exception', () {
+ ut.test('throws - expected to see exception', () {
var completer = new Completer();
completer.completeError('X');
shouldPass(completer.future, throws, isAsync: true);
});
- test('throws - expected to see exception thrown later on', () {
+ ut.test('throws - expected to see exception thrown later on', () {
var completer = new Completer();
var chained = completer.future.then((_) { throw 'X'; });
shouldPass(chained, throws, isAsync: true);
completer.complete('1');
});
- test('throwsA - unexpected normal completion', () {
+ ut.test('throwsA - unexpected normal completion', () {
var completer = new Completer();
completer.complete('1');
shouldFail(completer.future, throwsA(equals('X')),
@@ -724,13 +725,13 @@ void main() {
isAsync: true);
});
- test('throwsA - correct error', () {
+ ut.test('throwsA - correct error', () {
var completer = new Completer();
completer.completeError('X');
shouldPass(completer.future, throwsA(equals('X')), isAsync: true);
});
- test('throwsA - wrong error', () {
+ ut.test('throwsA - wrong error', () {
var completer = new Completer();
completer.completeError('X');
shouldFail(completer.future, throwsA(equals('Y')),
@@ -741,29 +742,29 @@ void main() {
});
});
- group('Predicate Matchers', () {
- test('isInstanceOf', () {
+ ut.group('Predicate Matchers', () {
+ ut.test('isInstanceOf', () {
shouldFail(0, predicate((x) => x is String, "an instance of String"),
"Expected: an instance of String Actual: <0>");
shouldPass('cow', predicate((x) => x is String, "an instance of String"));
});
});
- group('exception/error matchers', () {
+ ut.group('exception/error matchers', () {
// TODO(gram): extend this to more types; for now this is just
// the types being added in this CL.
// TODO: enable this test when it works.
// See issue 12052.
- skip_test('throwsCyclicInitializationError', () {
+ ut.skip_test('throwsCyclicInitializationError', () {
expect(() => new Bicycle(), throwsCyclicInitializationError);
});
- test('throwsAbstractClassInstantiationError', () {
+ ut.test('throwsAbstractClassInstantiationError', () {
expect(() => new Abstraction(), throwsAbstractClassInstantiationError);
});
- test('throwsConcurrentModificationError', () {
+ ut.test('throwsConcurrentModificationError', () {
expect(() {
var a = { 'foo': 'bar' };
for (var k in a.keys) {
@@ -772,11 +773,11 @@ void main() {
}, throwsConcurrentModificationError);
});
- test('throwsNullThrownError', () {
+ ut.test('throwsNullThrownError', () {
expect(() => throw null, throwsNullThrownError);
});
- test('throwsFallThroughError', () {
+ ut.test('throwsFallThroughError', () {
expect(() {
var a = 0;
switch (a) {
« no previous file with comments | « pkg/matcher/test/matchers_minified_test.dart ('k') | pkg/matcher/test/matchers_unminified_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698