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.declarations.values.where( | 45 for (MethodMirror method in cls.methods.values) { |
46 (d) => d is MethodMirror && !d.isConstructor)) { | |
47 Expect.isTrue(method.isRegularMethod); | 46 Expect.isTrue(method.isRegularMethod); |
48 Expect.isTrue(method.isOperator); | 47 Expect.isTrue(method.isOperator); |
49 Expect.isFalse(method.isGetter); | 48 Expect.isFalse(method.isGetter); |
50 Expect.isFalse(method.isSetter); | 49 Expect.isFalse(method.isSetter); |
51 Expect.isFalse(method.isAbstract); | 50 Expect.isFalse(method.isAbstract); |
52 operators[method.simpleName] = method; | 51 operators[method.simpleName] = method; |
53 operatorParameters[method.simpleName] = method.parameters; | 52 operatorParameters[method.simpleName] = method.parameters; |
54 returnTypes[method.simpleName] = method.returnType; | 53 returnTypes[method.simpleName] = method.returnType; |
55 } | 54 } |
56 expect(OPERATORS, operators); | 55 expect(OPERATORS, operators); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 '>=: $FOO, ' | 127 '>=: $FOO, ' |
129 '>>: $FOO, ' | 128 '>>: $FOO, ' |
130 '[]: $FOO, ' | 129 '[]: $FOO, ' |
131 '[]=: $DYNAMIC, ' | 130 '[]=: $DYNAMIC, ' |
132 '^: $FOO, ' | 131 '^: $FOO, ' |
133 'unary-: $FOO, ' | 132 'unary-: $FOO, ' |
134 '|: $FOO, ' | 133 '|: $FOO, ' |
135 '~: $FOO, ' | 134 '~: $FOO, ' |
136 '~/: $FOO' | 135 '~/: $FOO' |
137 '}'; | 136 '}'; |
OLD | NEW |