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

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

Issue 2768073002: Format all multitests (Closed)
Patch Set: Created 3 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
OLDNEW
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 library test.invoke_call_through_getter; 5 library test.invoke_call_through_getter;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 10
11 class FakeFunctionCall { 11 class FakeFunctionCall {
12 call(x, y) => '1 $x $y'; 12 call(x, y) => '1 $x $y';
13 } 13 }
14
14 class FakeFunctionNSM { 15 class FakeFunctionNSM {
15 noSuchMethod(msg) => msg.positionalArguments.join(', '); 16 noSuchMethod(msg) => msg.positionalArguments.join(', ');
16 } 17 }
17 18
18 class C { 19 class C {
19 get fakeFunctionCall => new FakeFunctionCall(); 20 get fakeFunctionCall => new FakeFunctionCall();
20 get fakeFunctionNSM => new FakeFunctionNSM(); 21 get fakeFunctionNSM => new FakeFunctionNSM();
21 get closure => (x, y) => '2 $this $x $y'; 22 get closure => (x, y) => '2 $this $x $y';
22 get closureOpt => (x, y, [z, w]) => '3 $this $x $y $z $w'; 23 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 get closureNamed => (x, y, {z, w}) => '4 $this $x $y $z $w';
(...skipping 12 matching lines...) Expand all
36 Expect.equals('3 C 11 12 13 null', c.closureOpt(11, 12, 13)); 37 Expect.equals('3 C 11 12 13 null', c.closureOpt(11, 12, 13));
37 Expect.equals('4 C 14 15 null 16', c.closureNamed(14, 15, w: 16)); 38 Expect.equals('4 C 14 15 null 16', c.closureNamed(14, 15, w: 16));
38 Expect.equals('DNU', c.doesNotExist(17, 18)); 39 Expect.equals('DNU', c.doesNotExist(17, 18));
39 Expect.throws(() => c.closure('wrong arity'), (e) => e is NoSuchMethodError); 40 Expect.throws(() => c.closure('wrong arity'), (e) => e is NoSuchMethodError);
40 Expect.throws(() => c.notAClosure(), (e) => e is NoSuchMethodError); 41 Expect.throws(() => c.notAClosure(), (e) => e is NoSuchMethodError);
41 } 42 }
42 43
43 testInstanceReflective() { 44 testInstanceReflective() {
44 InstanceMirror im = reflect(new C()); 45 InstanceMirror im = reflect(new C());
45 46
46 Expect.equals('1 5 6', 47 Expect.equals('1 5 6', im.invoke(#fakeFunctionCall, [5, 6]).reflectee);
47 im.invoke(#fakeFunctionCall, [5, 6]).reflectee); 48 Expect.equals('7, 8', im.invoke(#fakeFunctionNSM, [7, 8]).reflectee);
48 Expect.equals('7, 8', 49 Expect.equals('2 C 9 10', im.invoke(#closure, [9, 10]).reflectee);
49 im.invoke(#fakeFunctionNSM, [7, 8]).reflectee); 50 Expect.equals(
50 Expect.equals('2 C 9 10', 51 '3 C 11 12 13 null', im.invoke(#closureOpt, [11, 12, 13]).reflectee);
51 im.invoke(#closure, [9, 10]).reflectee);
52 Expect.equals('3 C 11 12 13 null',
53 im.invoke(#closureOpt, [11, 12, 13]).reflectee);
54 Expect.equals('4 C 14 15 null 16', // // # named: ok 52 Expect.equals('4 C 14 15 null 16', // // # named: ok
55 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // // # named: continued 53 im.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // // # named: continued
56 Expect.equals('DNU', 54 Expect.equals('DNU', im.invoke(#doesNotExist, [17, 18]).reflectee);
57 im.invoke(#doesNotExist, [17, 18]).reflectee);
58 Expect.throws(() => im.invoke(#closure, ['wrong arity']), 55 Expect.throws(() => im.invoke(#closure, ['wrong arity']),
59 (e) => e is NoSuchMethodError); 56 (e) => e is NoSuchMethodError);
60 Expect.throws(() => im.invoke(#notAClosure, []), 57 Expect.throws(
61 (e) => e is NoSuchMethodError); 58 () => im.invoke(#notAClosure, []), (e) => e is NoSuchMethodError);
62 } 59 }
63 60
64 class D { 61 class D {
65 static get fakeFunctionCall => new FakeFunctionCall(); 62 static get fakeFunctionCall => new FakeFunctionCall();
66 static get fakeFunctionNSM => new FakeFunctionNSM(); 63 static get fakeFunctionNSM => new FakeFunctionNSM();
67 static get closure => (x, y) => '2 $x $y'; 64 static get closure => (x, y) => '2 $x $y';
68 static get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w'; 65 static get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w';
69 static get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w'; 66 static get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w';
70 static get notAClosure => 'Not a closure'; 67 static get notAClosure => 'Not a closure';
71 } 68 }
72 69
73 testClassBase() { 70 testClassBase() {
74 Expect.equals('1 5 6', D.fakeFunctionCall(5, 6)); 71 Expect.equals('1 5 6', D.fakeFunctionCall(5, 6));
75 Expect.equals('7, 8', D.fakeFunctionNSM(7, 8)); 72 Expect.equals('7, 8', D.fakeFunctionNSM(7, 8));
76 Expect.equals('2 9 10', D.closure(9, 10)); 73 Expect.equals('2 9 10', D.closure(9, 10));
77 Expect.equals('3 11 12 13 null', D.closureOpt(11, 12, 13)); 74 Expect.equals('3 11 12 13 null', D.closureOpt(11, 12, 13));
78 Expect.equals('4 14 15 null 16', D.closureNamed(14, 15, w: 16)); 75 Expect.equals('4 14 15 null 16', D.closureNamed(14, 15, w: 16));
79 Expect.throws(() => D.closure('wrong arity'), (e) => e is NoSuchMethodError); 76 Expect.throws(() => D.closure('wrong arity'), (e) => e is NoSuchMethodError);
80 } 77 }
81 78
82 testClassReflective() { 79 testClassReflective() {
83 ClassMirror cm = reflectClass(D); 80 ClassMirror cm = reflectClass(D);
84 81
85 Expect.equals('1 5 6', 82 Expect.equals('1 5 6', cm.invoke(#fakeFunctionCall, [5, 6]).reflectee);
86 cm.invoke(#fakeFunctionCall, [5, 6]).reflectee); 83 Expect.equals('7, 8', cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee);
87 Expect.equals('7, 8', 84 Expect.equals('2 9 10', cm.invoke(#closure, [9, 10]).reflectee);
88 cm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); 85 Expect.equals(
89 Expect.equals('2 9 10', 86 '3 11 12 13 null', cm.invoke(#closureOpt, [11, 12, 13]).reflectee);
90 cm.invoke(#closure, [9, 10]).reflectee);
91 Expect.equals('3 11 12 13 null',
92 cm.invoke(#closureOpt, [11, 12, 13]).reflectee);
93 Expect.equals('4 14 15 null 16', // //# named: continued 87 Expect.equals('4 14 15 null 16', // //# named: continued
94 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //# named: continued 88 cm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //# named: continued
95 Expect.throws(() => cm.invoke(#closure, ['wrong arity']), 89 Expect.throws(() => cm.invoke(#closure, ['wrong arity']),
96 (e) => e is NoSuchMethodError); 90 (e) => e is NoSuchMethodError);
97 } 91 }
98 92
99 get fakeFunctionCall => new FakeFunctionCall(); 93 get fakeFunctionCall => new FakeFunctionCall();
100 get fakeFunctionNSM => new FakeFunctionNSM(); 94 get fakeFunctionNSM => new FakeFunctionNSM();
101 get closure => (x, y) => '2 $x $y'; 95 get closure => (x, y) => '2 $x $y';
102 get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w'; 96 get closureOpt => (x, y, [z, w]) => '3 $x $y $z $w';
103 get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w'; 97 get closureNamed => (x, y, {z, w}) => '4 $x $y $z $w';
104 get notAClosure => 'Not a closure'; 98 get notAClosure => 'Not a closure';
105 99
106 testLibraryBase() { 100 testLibraryBase() {
107 Expect.equals('1 5 6', fakeFunctionCall(5, 6)); 101 Expect.equals('1 5 6', fakeFunctionCall(5, 6));
108 Expect.equals('7, 8', fakeFunctionNSM(7, 8)); 102 Expect.equals('7, 8', fakeFunctionNSM(7, 8));
109 Expect.equals('2 9 10', closure(9, 10)); 103 Expect.equals('2 9 10', closure(9, 10));
110 Expect.equals('3 11 12 13 null', closureOpt(11, 12, 13)); 104 Expect.equals('3 11 12 13 null', closureOpt(11, 12, 13));
111 Expect.equals('4 14 15 null 16', closureNamed(14, 15, w: 16)); 105 Expect.equals('4 14 15 null 16', closureNamed(14, 15, w: 16));
112 Expect.throws(() => closure('wrong arity'), (e) => e is NoSuchMethodError); 106 Expect.throws(() => closure('wrong arity'), (e) => e is NoSuchMethodError);
113 } 107 }
114 108
115 testLibraryReflective() { 109 testLibraryReflective() {
116 LibraryMirror lm = reflectClass(D).owner; 110 LibraryMirror lm = reflectClass(D).owner;
117 111
118 Expect.equals('1 5 6', 112 Expect.equals('1 5 6', lm.invoke(#fakeFunctionCall, [5, 6]).reflectee);
119 lm.invoke(#fakeFunctionCall, [5, 6]).reflectee); 113 Expect.equals('7, 8', lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee);
120 Expect.equals('7, 8', 114 Expect.equals('2 9 10', lm.invoke(#closure, [9, 10]).reflectee);
121 lm.invoke(#fakeFunctionNSM, [7, 8]).reflectee); 115 Expect.equals(
122 Expect.equals('2 9 10', 116 '3 11 12 13 null', lm.invoke(#closureOpt, [11, 12, 13]).reflectee);
123 lm.invoke(#closure, [9, 10]).reflectee);
124 Expect.equals('3 11 12 13 null',
125 lm.invoke(#closureOpt, [11, 12, 13]).reflectee);
126 Expect.equals('4 14 15 null 16', // //# named: continued 117 Expect.equals('4 14 15 null 16', // //# named: continued
127 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //# named: continued 118 lm.invoke(#closureNamed, [14, 15], {#w: 16}).reflectee); // //# named: continued
128 Expect.throws(() => lm.invoke(#closure, ['wrong arity']), 119 Expect.throws(() => lm.invoke(#closure, ['wrong arity']),
129 (e) => e is NoSuchMethodError); 120 (e) => e is NoSuchMethodError);
130 } 121 }
131 122
132 main() { 123 main() {
133 // Do not access the getters/closures at the base level in this variant. 124 // Do not access the getters/closures at the base level in this variant.
134 //testInstanceBase(); 125 //testInstanceBase();
135 testInstanceReflective(); 126 testInstanceReflective();
136 //testClassBase(); 127 //testClassBase();
137 testClassReflective(); 128 testClassReflective();
138 //testLibraryBase(); 129 //testLibraryBase();
139 testLibraryReflective(); 130 testLibraryReflective();
140 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698