| OLD | NEW |
| 1 library unittest; | 1 library unittest; |
| 2 | 2 |
| 3 import 'package:unittest/unittest.dart'; | 3 import 'package:unittest/unittest.dart'; |
| 4 import 'package:di/mirrors.dart'; | 4 import 'package:di/mirrors.dart'; |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 export 'package:unittest/unittest.dart'; | 7 export 'package:unittest/unittest.dart'; |
| 8 | 8 |
| 9 // Jasmine-like syntax for unittest. | 9 // Jasmine-like syntax for unittest. |
| 10 void describe(String spec, TestFunction body) => group(spec, body); | 10 void describe(String spec, TestFunction body) => group(spec, body); |
| 11 void ddescribe(String spec, TestFunction body) => solo_group(spec, body); | 11 void ddescribe(String spec, TestFunction body) => solo_group(spec, body); |
| 12 void xdescribe(String spec, TestFunction body) {} | 12 void xdescribe(String spec, TestFunction body) {} |
| 13 void it(String spec, TestFunction body) => test(spec, body); | 13 void it(String spec, TestFunction body) => test(spec, body); |
| 14 void xit(String spec, TestFunction body) {} | 14 void xit(String spec, TestFunction body) {} |
| 15 void iit(String spec, TestFunction body) => solo_test(spec, body); | 15 void iit(String spec, TestFunction body) => solo_test(spec, body); |
| 16 | 16 |
| 17 Matcher toEqual(expected) => equals(expected); | 17 Matcher toEqual(expected) => equals(expected); |
| 18 Matcher toContain(expected) => contains(expected); | 18 Matcher toContain(expected) => contains(expected); |
| 19 Matcher toBe(expected) => same(expected); | 19 Matcher toBe(expected) => same(expected); |
| 20 Matcher instanceOf(Type t) => new IsInstanceOfTypeMatcher(t); | 20 Matcher instanceOf(Type t) => new IsInstanceOfTypeMatcher(t); |
| 21 | 21 |
| 22 Matcher toThrow(Type exceptionClass, [message]) => message == null | 22 Matcher toThrow(Type exceptionClass, String message) => |
| 23 ? new ThrowsMatcher(instanceOf(exceptionClass)) | 23 new ThrowsMatcher(new ComplexExceptionMatcher( |
| 24 : new ThrowsMatcher(new ComplexExceptionMatcher( | 24 instanceOf(exceptionClass), toContain(message))); |
| 25 instanceOf(exceptionClass), | |
| 26 message is Matcher ? message : toContain(message))); | |
| 27 | 25 |
| 28 Matcher not(Matcher matcher) => new NegateMatcher(matcher); | 26 Matcher not(Matcher matcher) => new NegateMatcher(matcher); |
| 29 | 27 |
| 30 | 28 |
| 31 class NegateMatcher extends Matcher { | 29 class NegateMatcher extends Matcher { |
| 32 final Matcher _matcher; | 30 final Matcher _matcher; |
| 33 | 31 |
| 34 const NegateMatcher(this._matcher); | 32 const NegateMatcher(this._matcher); |
| 35 | 33 |
| 36 bool matches(obj, Map ms) => !_matcher.matches(obj, ms); | 34 bool matches(obj, Map ms) => !_matcher.matches(obj, ms); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Type t; | 99 Type t; |
| 102 | 100 |
| 103 IsInstanceOfTypeMatcher(this.t); | 101 IsInstanceOfTypeMatcher(this.t); |
| 104 | 102 |
| 105 bool matches(obj, Map matchState) => | 103 bool matches(obj, Map matchState) => |
| 106 reflect(obj).type.qualifiedName == reflectClass(t).qualifiedName; | 104 reflect(obj).type.qualifiedName == reflectClass(t).qualifiedName; |
| 107 | 105 |
| 108 Description describe(Description description) => | 106 Description describe(Description description) => |
| 109 description.add('an instance of ${t.toString()}'); | 107 description.add('an instance of ${t.toString()}'); |
| 110 } | 108 } |
| OLD | NEW |