OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test operators. | 5 /// Test operators. |
6 library test.operator_test; | 6 library test.operator_test; |
7 | 7 |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 | 9 |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 // TODO(ahe): use void when dart2js reifies that type. | 36 // TODO(ahe): use void when dart2js reifies that type. |
37 operator []=(int a, Foo b) {} | 37 operator []=(int a, Foo b) {} |
38 } | 38 } |
39 | 39 |
40 void main() { | 40 void main() { |
41 ClassMirror cls = reflectClass(Foo); | 41 ClassMirror cls = reflectClass(Foo); |
42 var operators = new Map<Symbol, MethodMirror>(); | 42 var operators = new Map<Symbol, MethodMirror>(); |
43 var operatorParameters = new Map<Symbol, List>(); | 43 var operatorParameters = new Map<Symbol, List>(); |
44 var returnTypes = new Map<Symbol, Mirror>(); | 44 var returnTypes = new Map<Symbol, Mirror>(); |
45 for (MethodMirror method in cls.methods.values) { | 45 for (MethodMirror method in cls.declarations.values.where( |
| 46 (d) => d is MethodMirror && !d.isConstructor)) { |
46 Expect.isTrue(method.isRegularMethod); | 47 Expect.isTrue(method.isRegularMethod); |
47 Expect.isTrue(method.isOperator); | 48 Expect.isTrue(method.isOperator); |
48 Expect.isFalse(method.isGetter); | 49 Expect.isFalse(method.isGetter); |
49 Expect.isFalse(method.isSetter); | 50 Expect.isFalse(method.isSetter); |
50 Expect.isFalse(method.isAbstract); | 51 Expect.isFalse(method.isAbstract); |
51 operators[method.simpleName] = method; | 52 operators[method.simpleName] = method; |
52 operatorParameters[method.simpleName] = method.parameters; | 53 operatorParameters[method.simpleName] = method.parameters; |
53 returnTypes[method.simpleName] = method.returnType; | 54 returnTypes[method.simpleName] = method.returnType; |
54 } | 55 } |
55 expect(OPERATORS, operators); | 56 expect(OPERATORS, operators); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 '>=: $FOO, ' | 128 '>=: $FOO, ' |
128 '>>: $FOO, ' | 129 '>>: $FOO, ' |
129 '[]: $FOO, ' | 130 '[]: $FOO, ' |
130 '[]=: $DYNAMIC, ' | 131 '[]=: $DYNAMIC, ' |
131 '^: $FOO, ' | 132 '^: $FOO, ' |
132 'unary-: $FOO, ' | 133 'unary-: $FOO, ' |
133 '|: $FOO, ' | 134 '|: $FOO, ' |
134 '~: $FOO, ' | 135 '~: $FOO, ' |
135 '~/: $FOO' | 136 '~/: $FOO' |
136 '}'; | 137 '}'; |
OLD | NEW |