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

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

Issue 196513004: Clean up ClosureMirror.invoke(#call, ...). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: adapt to alternate implementation of closure.call Created 6 years, 9 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 | « tests/lib/lib.status ('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) 2014, 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 test.invoke_call_on_closure;
6
7 import 'dart:mirrors';
8
9 import 'package:expect/expect.dart';
10
11 class FakeFunctionCall {
12 call(x, y) => '1 $x $y';
13 }
14 class FakeFunctionNSM {
15 noSuchMethod(msg) => msg.positionalArguments.join(', ');
16 }
17
18 class C {
19 get fakeFunctionCall => new FakeFunctionCall();
20 get fakeFunctionNSM => new FakeFunctionNSM();
21 get closure => (x, y) => '2 $this $x $y';
22 get closureOpt => (x, y, [z, w]) => '3 $this $x $y $z $w';
23 get closureNamed => (x, y, {z, w}) => '4 $this $x $y $z $w';
24 tearOff(x, y) => '22 $this $x $y';
25 tearOffOpt(x, y, [z, w]) => '33 $this $x $y $z $w';
26 tearOffNamed(x, y, {z, w}) => '44 $this $x $y $z $w';
27
28 noSuchMethod(msg) => 'DNU';
29
30 toString() => 'C';
31 }
32
33 main() {
34 var c = new C();
35 InstanceMirror im;
36
37 im = reflect(c.fakeFunctionCall);
38 Expect.equals('1 5 6',
39 im.invoke(#call, [5, 6]).reflectee);
40
41 im = reflect(c.fakeFunctionNSM);
42 Expect.equals('7, 8',
43 im.invoke(#call, [7, 8]).reflectee);
44
45 im = reflect(c.closure);
46 Expect.equals('2 C 9 10',
47 im.invoke(#call, [9, 10]).reflectee);
48
49 im = reflect(c.closureOpt);
50 Expect.equals('3 C 11 12 13 null',
51 im.invoke(#call, [11, 12, 13]).reflectee);
52
53 im = reflect(c.closureNamed);
54 Expect.equals('4 C 14 15 null 16',
55 im.invoke(#call, [14, 15], {#w: 16}).reflectee);
56
57 im = reflect(c.tearOff);
58 Expect.equals('22 C 9 10',
59 im.invoke(#call, [9, 10]).reflectee);
60
61 im = reflect(c.tearOffOpt);
62 Expect.equals('33 C 11 12 13 null',
63 im.invoke(#call, [11, 12, 13]).reflectee);
64
65 im = reflect(c.tearOffNamed);
66 Expect.equals('44 C 14 15 null 16',
67 im.invoke(#call, [14, 15], {#w: 16}).reflectee);
68 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698