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

Side by Side Diff: tests/language/invocation_mirror_test.dart

Issue 11366152: Update language/invocation_mirror_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « no previous file | 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
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 // InvocationMirror and noSuchMethod testing. 5 // InvocationMirror and noSuchMethod testing.
6 6
7 /** Class with noSuchMethod that returns the mirror */ 7 /** Class with noSuchMethod that returns the mirror */
8 class N { 8 class N {
9 // Storage for the last argument to noSuchMethod. 9 // Storage for the last argument to noSuchMethod.
10 // Needed for setters, which don't evaluate to the return value. 10 // Needed for setters, which don't evaluate to the return value.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 var n = new N(); 77 var n = new N();
78 var c = new C(); 78 var c = new C();
79 79
80 // Missing property/method access. 80 // Missing property/method access.
81 testInvocationMirror(n.bar, 'bar'); 81 testInvocationMirror(n.bar, 'bar');
82 testInvocationMirror((n..bar = 42).last, 'bar=', [42]); 82 testInvocationMirror((n..bar = 42).last, 'bar=', [42]);
83 testInvocationMirror(n.bar(), 'bar', [], {}); 83 testInvocationMirror(n.bar(), 'bar', [], {});
84 testInvocationMirror(n.bar(42), 'bar', [42], {}); 84 testInvocationMirror(n.bar(42), 'bar', [42], {});
85 testInvocationMirror(n.bar(x: 42), 'bar', [], {"x": 42}); 85 testInvocationMirror(n.bar(x: 42), 'bar', [], {"x": 42});
86 testInvocationMirror(n.bar(37, x: 42), 'bar', [37], {"x": 42}); 86 testInvocationMirror(n.bar(37, x: 42), 'bar', [37], {"x": 42});
87 testInvocationMirror((n.bar)(), 'bar', [], {});
88 testInvocationMirror((n.bar)(42), 'bar', [42]);
89 testInvocationMirror((n.bar)(x: 42), 'bar', [], {"x": 42});
90 testInvocationMirror((n.bar)(37, x: 42), 'bar', [37], {"x": 42});
91 87
92 // Missing operator access. 88 // Missing operator access.
93 testInvocationMirror(n + 4, '+', [4], {}); 89 testInvocationMirror(n + 4, '+', [4], {});
94 testInvocationMirror(n - 4, '-', [4], {}); 90 testInvocationMirror(n - 4, '-', [4], {});
95 testInvocationMirror(-n, '-', [], {}); 91 testInvocationMirror(-n, 'unary-', [], {});
96 testInvocationMirror(n[42], '[]', [42], {}); 92 testInvocationMirror(n[42], '[]', [42], {});
97 testInvocationMirror((n..[37] = 42).last, '[]=', [37, 42], {}); 93 testInvocationMirror((n..[37] = 42).last, '[]=', [37, 42], {});
98 94
99 // Calling as function when it's not. 95 // Calling as function when it's not.
100 testInvocationMirror(n(), 'call', [], {}); 96 testInvocationMirror(n(), 'call', [], {});
101 testInvocationMirror(n(42), 'call', [42], {}); 97 testInvocationMirror(n(42), 'call', [42], {});
102 testInvocationMirror(n(x: 42), 'call', [], {"x": 42}); 98 testInvocationMirror(n(x: 42), 'call', [], {"x": 42});
103 testInvocationMirror(n(37, x: 42), 'call', [37], {"x": 42}); 99 testInvocationMirror(n(37, x: 42), 'call', [37], {"x": 42});
104 100
105 // Calling with arguments not matching existing call method. 101 // Calling with arguments not matching existing call method.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 (e) => e is NoSuchMethodError); 141 (e) => e is NoSuchMethodError);
146 Expect.throws(() { var x = c.call; x(37, 42); }, 142 Expect.throws(() { var x = c.call; x(37, 42); },
147 (e) => e is NoSuchMethodError); 143 (e) => e is NoSuchMethodError);
148 } 144 }
149 145
150 // Test the NoSuchMethodError thrown by different incorrect calls. 146 // Test the NoSuchMethodError thrown by different incorrect calls.
151 testNoSuchMethodErrors() { 147 testNoSuchMethodErrors() {
152 test(Function block) { 148 test(Function block) {
153 Expect.throws(block, (e) => e is NoSuchMethodError); 149 Expect.throws(block, (e) => e is NoSuchMethodError);
154 } 150 }
155 151 var n = new N();
156 var o = new Object(); 152 var o = new Object();
157 test(() => o.bar); 153 test(() => o.bar);
158 test(() => o.bar = 42); 154 test(() => o.bar = 42);
159 test(() => o.bar()); 155 test(() => o.bar());
156 test(() => o + 2);
157 test(() => -o);
158 test(() => o[0]);
159 test(() => o[0] = 42);
160 test(() => o());
160 test(() => o.toString = 42); 161 test(() => o.toString = 42);
161 test(() => o.toString(42)); 162 test(() => o.toString(42));
162 test(() => o.toString(x: 37)); 163 test(() => o.toString(x: 37));
163 test(() => o.hashCode = 42); 164 test(() => o.hashCode = 42);
164 test(() => o.hashCode()); // Thrown by int.noSuchMethod. 165 test(() => o.hashCode()); // Thrown by int.noSuchMethod.
165 test(() => o()); 166 test(n.flif); // Extracted method has no noSuchMethod.
166 } 167 }
167 168
168 main() { 169 main() {
169 testInvocationMirrors(); 170 testInvocationMirrors();
170 testNoSuchMethodErrors(); 171 testNoSuchMethodErrors();
171 } 172 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698