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