Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: dart/tests/lib/mirrors/operator_test.dart

Issue 19568005: Implement top-level invoke and operators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r25276 Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tests/lib/mirrors/mirrors_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// Test operators.
6 library test.operator_test;
7
8 import 'dart:mirrors';
9
10 import 'package:expect/expect.dart';
11
12 import 'stringify.dart';
13
14 class Foo {
15 Foo operator ~() {}
16 Foo operator -() {}
17
18 bool operator ==(a) {}
19 Foo operator [](int a) {}
20 Foo operator *(Foo a) {}
21 Foo operator /(Foo a) {}
22 Foo operator %(Foo a) {}
23 Foo operator ~/(Foo a) {}
24 Foo operator +(Foo a) {}
25 Foo operator <<(Foo a) {}
26 Foo operator >>(Foo a) {}
27 Foo operator >=(Foo a) {}
28 Foo operator >(Foo a) {}
29 Foo operator <=(Foo a) {}
30 Foo operator <(Foo a) {}
31 Foo operator &(Foo a) {}
32 Foo operator ^(Foo a) {}
33 Foo operator |(Foo a) {}
34 Foo operator -(Foo a) {}
35
36 // TODO(ahe): use void when dart2js reifies that type.
37 operator []=(int a, Foo b) {}
38 }
39
40 void main() {
41 ClassMirror cls = reflectClass(Foo);
42 var operators = new Map<Symbol, MethodMirror>();
43 var operatorParameters = new Map<Symbol, List>();
44 var returnTypes = new Map<Symbol, Mirror>();
45 for (MethodMirror method in cls.methods.values) {
46 Expect.isTrue(method.isRegularMethod);
47 Expect.isTrue(method.isOperator);
48 Expect.isFalse(method.isGetter);
49 Expect.isFalse(method.isSetter);
50 Expect.isFalse(method.isAbstract);
51 operators[method.simpleName] = method;
52 operatorParameters[method.simpleName] = method.parameters;
53 returnTypes[method.simpleName] = method.returnType;
54 }
55 expect(OPERATORS, operators);
56 expect(PARAMETERS, operatorParameters);
57 expect(RETURN_TYPES, returnTypes);
58 }
59
60 const String OPERATORS = '{'
61 '%: Method(s(%) in s(Foo)), '
62 '&: Method(s(&) in s(Foo)), '
63 '*: Method(s(*) in s(Foo)), '
64 '+: Method(s(+) in s(Foo)), '
65 '-: Method(s(-) in s(Foo)), '
66 '/: Method(s(/) in s(Foo)), '
67 '<: Method(s(<) in s(Foo)), '
68 '<<: Method(s(<<) in s(Foo)), '
69 '<=: Method(s(<=) in s(Foo)), '
70 '==: Method(s(==) in s(Foo)), '
71 '>: Method(s(>) in s(Foo)), '
72 '>=: Method(s(>=) in s(Foo)), '
73 '>>: Method(s(>>) in s(Foo)), '
74 '[]: Method(s([]) in s(Foo)), '
75 '[]=: Method(s([]=) in s(Foo)), '
76 '^: Method(s(^) in s(Foo)), '
77 'unary-: Method(s(unary-) in s(Foo)), '
78 '|: Method(s(|) in s(Foo)), '
79 '~: Method(s(~) in s(Foo)), '
80 '~/: Method(s(~/) in s(Foo))'
81 '}';
82
83 const String DYNAMIC = 'Type(s(dynamic), top-level)';
84
85 const String FOO = 'Class(s(Foo) in s(test.operator_test), top-level)';
86
87 const String INT = 'Class(s(int) in s(dart.core), top-level)';
88
89 const String BOOL = 'Class(s(bool) in s(dart.core), top-level)';
90
91 const String PARAMETERS = '{'
92 '%: [Parameter(s(a) in s(%), type = $FOO)], '
93 '&: [Parameter(s(a) in s(&), type = $FOO)], '
94 '*: [Parameter(s(a) in s(*), type = $FOO)], '
95 '+: [Parameter(s(a) in s(+), type = $FOO)], '
96 '-: [Parameter(s(a) in s(-), type = $FOO)], '
97 '/: [Parameter(s(a) in s(/), type = $FOO)], '
98 '<: [Parameter(s(a) in s(<), type = $FOO)], '
99 '<<: [Parameter(s(a) in s(<<), type = $FOO)], '
100 '<=: [Parameter(s(a) in s(<=), type = $FOO)], '
101 '==: [Parameter(s(a) in s(==), type = $DYNAMIC)], '
102 '>: [Parameter(s(a) in s(>), type = $FOO)], '
103 '>=: [Parameter(s(a) in s(>=), type = $FOO)], '
104 '>>: [Parameter(s(a) in s(>>), type = $FOO)], '
105 '[]: [Parameter(s(a) in s([]), type = $INT)], '
106 '[]=: [Parameter(s(a) in s([]=), type = $INT), '
107 'Parameter(s(b) in s([]=), type = $FOO)], '
108 '^: [Parameter(s(a) in s(^), type = $FOO)], '
109 'unary-: [], '
110 '|: [Parameter(s(a) in s(|), type = $FOO)], '
111 '~: [], '
112 '~/: [Parameter(s(a) in s(~/), type = $FOO)]'
113 '}';
114
115 const String RETURN_TYPES = '{'
116 '%: $FOO, '
117 '&: $FOO, '
118 '*: $FOO, '
119 '+: $FOO, '
120 '-: $FOO, '
121 '/: $FOO, '
122 '<: $FOO, '
123 '<<: $FOO, '
124 '<=: $FOO, '
125 '==: $BOOL, '
126 '>: $FOO, '
127 '>=: $FOO, '
128 '>>: $FOO, '
129 '[]: $FOO, '
130 '[]=: $DYNAMIC, '
131 '^: $FOO, '
132 'unary-: $FOO, '
133 '|: $FOO, '
134 '~: $FOO, '
135 '~/: $FOO'
136 '}';
OLDNEW
« no previous file with comments | « dart/tests/lib/mirrors/mirrors_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698