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

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

Issue 21085010: Added hasProperty matcher. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
===================================================================
--- pkg/unittest/test/matchers_test.dart (revision 25630)
+++ pkg/unittest/test/matchers_test.dart (working copy)
@@ -203,7 +203,7 @@
test('isZero', () {
shouldPass(0, isZero);
- shouldFail(1, isZero,
+ shouldFail(1, isZero,
"Expected: a value equal to <0> "
"Actual: <1> "
"Which: is not a value equal to <0>");
@@ -222,7 +222,7 @@
"Expected: a positive value "
"Actual: <-1> "
"Which: is not a positive value");
- shouldFail(0, isPositive,
+ shouldFail(0, isPositive,
"Expected: a positive value "
"Actual: <0> "
"Which: is not a positive value");
@@ -428,7 +428,7 @@
"Which: has value ['foo', 'bar'] which has value 'bar' "
"which is different. Expected: foo Actual: bar ^ "
"Differ at offset 0 at index 1 at index 0");
- shouldFail(d, everyElement(allOf(hasLength(greaterThan(0)),
+ shouldFail(d, everyElement(allOf(hasLength(greaterThan(0)),
contains('foo'))),
"Expected: every element((an object with length of a value "
"greater than <0> and contains 'foo')) "
@@ -745,6 +745,19 @@
}
}, throwsFallThroughError);
});
+
+ test('hasProperty', () {
+ var foo = [3];
+ expect(foo, hasProperty('length', 1));
+ expect(() => expect(foo, hasProperty('foo')),
+ throwsA(predicate((x) => x is TestFailure &&
+ x.toString().contains('No property named foo'))));
+ expect(() => expect(foo, hasProperty('length', 2)),
+ throwsA(predicate((x) => x is TestFailure &&
+ x.toString().contains(
+ 'has property length with value <1>'))));
+
+ });
});
}
@@ -759,7 +772,7 @@
print(foo);
}
}
-
+
abstract class Abstraction {
void norealization();
}
« pkg/unittest/lib/src/core_matchers.dart ('K') | « pkg/unittest/lib/src/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698