| OLD | NEW |
| 1 library java.junit; | 1 library java.junit; |
| 2 | 2 |
| 3 import 'package:unittest/unittest.dart' hide fail; | 3 import 'package:unittest/unittest.dart' hide fail; |
| 4 import 'package:unittest/unittest.dart' as _ut show fail; | 4 import 'package:unittest/unittest.dart' as _ut show fail; |
| 5 | 5 |
| 6 | 6 |
| 7 class JUnitTestCase { | 7 class JUnitTestCase { |
| 8 void setUp() {} | 8 void setUp() {} |
| 9 void tearDown() {} | 9 void tearDown() {} |
| 10 static void fail(String msg) { | 10 static void fail(String msg) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } finally { | 49 } finally { |
| 50 testInstance.tearDown(); | 50 testInstance.tearDown(); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Returns a matches that matches if the value is not the same instance as "obje
ct" (`!==`). | 55 * Returns a matches that matches if the value is not the same instance as "obje
ct" (`!==`). |
| 56 */ | 56 */ |
| 57 Matcher notSame(expected) => new _IsNotSameAs(expected); | 57 Matcher notSame(expected) => new _IsNotSameAs(expected); |
| 58 | 58 |
| 59 class _IsNotSameAs extends Matcher { | 59 class _IsNotSameAs extends BaseMatcher { |
| 60 final _expected; | 60 final _expected; |
| 61 const _IsNotSameAs(this._expected); | 61 const _IsNotSameAs(this._expected); |
| 62 bool matches(item, Map matchState) => !identical(item, _expected); | 62 bool matches(item, Map matchState) => !identical(item, _expected); |
| 63 Description describe(Description description) => | 63 Description describe(Description description) => |
| 64 description.add('not same instance as ').addDescriptionOf(_expected); | 64 description.add('not same instance as ').addDescriptionOf(_expected); |
| 65 } | 65 } |
| 66 | 66 |
| 67 Matcher equalsMsg(String msg, expected) => new _EqualsWithMessage(msg, expected)
; | 67 Matcher equalsMsg(String msg, expected) => new _EqualsWithMessage(msg, expected)
; |
| 68 class _EqualsWithMessage extends Matcher { | 68 class _EqualsWithMessage extends BaseMatcher { |
| 69 final String msg; | 69 final String msg; |
| 70 final expectedValue; | 70 final expectedValue; |
| 71 const _EqualsWithMessage(this.msg, this.expectedValue); | 71 const _EqualsWithMessage(this.msg, this.expectedValue); |
| 72 bool matches(item, Map matchState) { | 72 bool matches(item, Map matchState) { |
| 73 return item == expectedValue; | 73 return item == expectedValue; |
| 74 } | 74 } |
| 75 Description describe(Description mismatchDescription) { | 75 Description describe(Description mismatchDescription) { |
| 76 return mismatchDescription.replace(msg); | 76 return mismatchDescription.replace(msg); |
| 77 } | 77 } |
| 78 Description describeMismatch(item, Description mismatchDescription, | |
| 79 Map matchState, bool verbose) { | |
| 80 return mismatchDescription.replace(msg).add(" $item != $expectedValue"); | |
| 81 } | |
| 82 } | 78 } |
| 83 | 79 |
| 84 Matcher isTrueMsg(String msg) => new _IsTrueWithMessage(msg); | 80 Matcher isTrueMsg(String msg) => new _IsTrueWithMessage(msg); |
| 85 class _IsTrueWithMessage extends Matcher { | 81 class _IsTrueWithMessage extends BaseMatcher { |
| 86 final String msg; | 82 final String msg; |
| 87 const _IsTrueWithMessage(this.msg); | 83 const _IsTrueWithMessage(this.msg); |
| 88 bool matches(item, Map matchState) { | 84 bool matches(item, Map matchState) { |
| 89 return item == true; | 85 return item == true; |
| 90 } | 86 } |
| 91 Description describe(Description mismatchDescription) { | 87 Description describe(Description mismatchDescription) { |
| 92 return mismatchDescription.replace(msg); | 88 return mismatchDescription.replace(msg); |
| 93 } | 89 } |
| 94 Description describeMismatch(item, Description mismatchDescription, | |
| 95 Map matchState, bool verbose) { | |
| 96 return mismatchDescription.replace(msg).add(" $item is not true"); | |
| 97 } | |
| 98 } | 90 } |
| 99 | 91 |
| 100 Matcher isFalseMsg(String msg) => new _IsFalseWithMessage(msg); | 92 Matcher isFalseMsg(String msg) => new _IsFalseWithMessage(msg); |
| 101 class _IsFalseWithMessage extends Matcher { | 93 class _IsFalseWithMessage extends BaseMatcher { |
| 102 final String msg; | 94 final String msg; |
| 103 const _IsFalseWithMessage(this.msg); | 95 const _IsFalseWithMessage(this.msg); |
| 104 bool matches(item, Map matchState) { | 96 bool matches(item, Map matchState) { |
| 105 return item == false; | 97 return item == false; |
| 106 } | 98 } |
| 107 Description describe(Description mismatchDescription) { | 99 Description describe(Description mismatchDescription) { |
| 108 return mismatchDescription.replace(msg); | 100 return mismatchDescription.replace(msg); |
| 109 } | 101 } |
| 110 Description describeMismatch(item, Description mismatchDescription, | |
| 111 Map matchState, bool verbose) { | |
| 112 return mismatchDescription.replace(msg).add(" $item is not false"); | |
| 113 } | |
| 114 } | 102 } |
| 115 | 103 |
| 116 Matcher isNotNullMsg(String msg) => new _IsNotNullWithMessage(msg); | 104 Matcher isNotNullMsg(String msg) => new _IsNotNullWithMessage(msg); |
| 117 class _IsNotNullWithMessage extends Matcher { | 105 class _IsNotNullWithMessage extends BaseMatcher { |
| 118 final String msg; | 106 final String msg; |
| 119 const _IsNotNullWithMessage(this.msg); | 107 const _IsNotNullWithMessage(this.msg); |
| 120 bool matches(item, Map matchState) { | 108 bool matches(item, Map matchState) { |
| 121 return item != null; | 109 return item != null; |
| 122 } | 110 } |
| 123 Description describe(Description mismatchDescription) { | 111 Description describe(Description mismatchDescription) { |
| 124 return mismatchDescription.replace(msg); | 112 return mismatchDescription.replace(msg); |
| 125 } | 113 } |
| 126 Description describeMismatch(item, Description mismatchDescription, | |
| 127 Map matchState, bool verbose) { | |
| 128 return mismatchDescription.replace(msg).add(" $item is null"); | |
| 129 } | |
| 130 } | 114 } |
| OLD | NEW |