| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library matcher.mirror_test; | 5 library matcher.mirror_test; |
| 6 | 6 |
| 7 import 'package:matcher/mirror_matchers.dart'; | 7 import 'package:matcher/mirror_matchers.dart'; |
| 8 import 'package:unittest/unittest.dart' show test; | 8 import 'package:unittest/unittest.dart' show test; |
| 9 | 9 |
| 10 import 'test_utils.dart'; | 10 import 'test_utils.dart'; |
| 11 | 11 |
| 12 class C { | 12 class C { |
| 13 var instanceField = 1; | 13 var instanceField = 1; |
| 14 get instanceGetter => 2; | 14 get instanceGetter => 2; |
| 15 static var staticField = 3; | 15 static var staticField = 3; |
| 16 static get staticGetter => 4; | 16 static get staticGetter => 4; |
| 17 } | 17 } |
| 18 | 18 |
| 19 void main() { | 19 void main() { |
| 20 | |
| 21 initUtils(); | 20 initUtils(); |
| 22 | 21 |
| 23 test('hasProperty', () { | 22 test('hasProperty', () { |
| 24 var foo = [3]; | 23 var foo = [3]; |
| 25 shouldPass(foo, hasProperty('length', 1)); | 24 shouldPass(foo, hasProperty('length', 1)); |
| 26 shouldFail(foo, hasProperty('foo'), 'Expected: has property "foo" ' | 25 shouldFail(foo, hasProperty('foo'), 'Expected: has property "foo" ' |
| 27 'Actual: [3] ' | 26 'Actual: [3] ' |
| 28 'Which: has no property named "foo"'); | 27 'Which: has no property named "foo"'); |
| 29 shouldFail(foo, hasProperty('length', 2), | 28 shouldFail(foo, hasProperty('length', 2), |
| 30 'Expected: has property "length" which matches <2> ' | 29 'Expected: has property "length" which matches <2> ' |
| 31 'Actual: [3] ' | 30 'Actual: [3] ' |
| 32 'Which: has property "length" with value <1>'); | 31 'Which: has property "length" with value <1>'); |
| 33 var c = new C(); | 32 var c = new C(); |
| 34 shouldPass(c, hasProperty('instanceField', 1)); | 33 shouldPass(c, hasProperty('instanceField', 1)); |
| 35 shouldPass(c, hasProperty('instanceGetter', 2)); | 34 shouldPass(c, hasProperty('instanceGetter', 2)); |
| 36 shouldFail(c, hasProperty('staticField'), | 35 shouldFail(c, hasProperty('staticField'), |
| 37 'Expected: has property "staticField" ' | 36 'Expected: has property "staticField" ' |
| 38 'Actual: <Instance of \'C\'> ' | 37 'Actual: <Instance of \'C\'> ' |
| 39 'Which: has a member named "staticField",' | 38 'Which: has a member named "staticField",' |
| 40 ' but it is not an instance property'); | 39 ' but it is not an instance property'); |
| 41 shouldFail(c, hasProperty('staticGetter'), | 40 shouldFail(c, hasProperty('staticGetter'), |
| 42 'Expected: has property "staticGetter" ' | 41 'Expected: has property "staticGetter" ' |
| 43 'Actual: <Instance of \'C\'> ' | 42 'Actual: <Instance of \'C\'> ' |
| 44 'Which: has a member named "staticGetter",' | 43 'Which: has a member named "staticGetter",' |
| 45 ' but it is not an instance property'); | 44 ' but it is not an instance property'); |
| 46 }); | 45 }); |
| 47 } | 46 } |
| OLD | NEW |