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

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/java_junit.dart

Issue 12197019: Drop of generated scanner and example scanner driver. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 library java.junit;
2
3 import 'package:unittest/unittest.dart' hide fail;
4 import 'package:unittest/unittest.dart' as _ut show fail;
5
6
7 class JUnitTestCase {
8 void setUp() {}
9 void tearDown() {}
10 static void fail(String msg) {
11 _ut.fail(msg);
12 }
13 static void assertTrue(bool x) {
14 expect(x, isTrue);
15 }
16 static void assertTrueMsg(String msg, bool x) {
17 expect(x, isTrueMsg(msg));
18 }
19 static void assertFalse(bool x) {
20 expect(x, isFalse);
21 }
22 static void assertFalseMsg(String msg, bool x) {
23 expect(x, isFalseMsg(msg));
24 }
25 static void assertNull(x) {
26 expect(x, isNull);
27 }
28 static void assertNotNull(x) {
29 expect(x, isNotNull);
30 }
31 static void assertEquals(expected, actual) {
32 expect(actual, equals(expected));
33 }
34 static void assertEqualsMsg(String msg, expected, actual) {
35 expect(actual, equalsMsg(msg, expected));
36 }
37 }
38
39 runJUnitTest(testInstance, Function testFunction) {
40 testInstance.setUp();
41 try {
42 testFunction();
43 } finally {
44 testInstance.tearDown();
45 }
46 }
47
48 /**
49 * Returns a matches that matches if the value is not the same instance
50 * as [object] (`!==`).
51 */
52 Matcher notSame(expected) => new _IsNotSameAs(expected);
53
54 class _IsNotSameAs extends BaseMatcher {
55 final _expected;
56 const _IsNotSameAs(this._expected);
57 bool matches(item, MatchState matchState) => !identical(item, _expected);
58 Description describe(Description description) =>
59 description.add('not same instance as ').addDescriptionOf(_expected);
60 }
61
62 Matcher equalsMsg(String msg, expected) => new _EqualsWithMessage(msg, expected) ;
63 class _EqualsWithMessage extends BaseMatcher {
64 final String msg;
65 final expectedValue;
66 const _EqualsWithMessage(this.msg, this.expectedValue);
67 bool matches(item, MatchState matchState) {
68 return item == expectedValue;
69 }
70 Description describe(Description mismatchDescription) {
71 return mismatchDescription.replace(msg);
72 }
73 Description describeMismatch(item, Description mismatchDescription,
74 MatchState matchState, bool verbose) {
75 return mismatchDescription.replace(msg).add(" $item != $expectedValue");
76 }
77 }
78
79 Matcher isTrueMsg(String msg) => new _IsTrueWithMessage(msg);
80 class _IsTrueWithMessage extends BaseMatcher {
81 final String msg;
82 const _IsTrueWithMessage(this.msg);
83 bool matches(item, MatchState matchState) {
84 return item == true;
85 }
86 Description describe(Description mismatchDescription) {
87 return mismatchDescription.replace(msg);
88 }
89 Description describeMismatch(item, Description mismatchDescription,
90 MatchState matchState, bool verbose) {
91 return mismatchDescription.replace(msg).add(" $item is not true");
92 }
93 }
94
95 Matcher isFalseMsg(String msg) => new _IsFalseWithMessage(msg);
96 class _IsFalseWithMessage extends BaseMatcher {
97 final String msg;
98 const _IsFalseWithMessage(this.msg);
99 bool matches(item, MatchState matchState) {
100 return item == false;
101 }
102 Description describe(Description mismatchDescription) {
103 return mismatchDescription.replace(msg);
104 }
105 Description describeMismatch(item, Description mismatchDescription,
106 MatchState matchState, bool verbose) {
107 return mismatchDescription.replace(msg).add(" $item is not false");
108 }
109 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/lib/src/generated/java_engine.dart ('k') | pkg/analyzer-experimental/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698