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

Side by Side Diff: tests/compiler/dart2js_extra/mirrors_declarations_filtering_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 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
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
3 // 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
4 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
5 4
6 // Regression test for the dart2js mirrors implementation that triggers the 5 // Regression test for the dart2js mirrors implementation that triggers the
7 // generation of the declarations of a class in the presence of call stubs 6 // generation of the declarations of a class in the presence of call stubs
8 // and non-reflectable methods. For neither of the latter an instance mirror 7 // and non-reflectable methods. For neither of the latter an instance mirror
9 // should be constructed and they should not be contained in declarations. 8 // should be constructed and they should not be contained in declarations.
10 @MirrorsUsed(metaTargets: "Meta") 9 @MirrorsUsed(metaTargets: "Meta")
11 import "dart:mirrors"; 10 import "dart:mirrors";
12 import "package:expect/expect.dart"; 11 import "package:expect/expect.dart";
13 12
14 class Meta { 13 class Meta {
15 const Meta(); 14 const Meta();
16 } 15 }
17 16
18 class A { 17 class A {
19 @Meta() 18 @Meta()
20 reflectableThing(int a, [int b = 9, int c = 42]) => a + b + c; 19 reflectableThing(int a, [int b = 9, int c = 42]) => a + b + c;
21 nonReflectableThing(int a, [int b = 4, int c = 21]) => a + b + c; 20 nonReflectableThing(int a, [int b = 4, int c = 21]) => a + b + c;
22 } 21 }
23 22
24 tryCall(object, symbol, values, expected) { 23 tryCall(object, symbol, values, expected) {
25 var mirror = reflect(object); 24 var mirror = reflect(object);
26 var result = mirror.invoke(symbol, values).reflectee; 25 var result = mirror.invoke(symbol, values).reflectee;
27 Expect.equals(result, expected); 26 Expect.equals(result, expected);
28 } 27 }
29 28
30 @NoInline() @AssumeDynamic() 29 @NoInline()
30 @AssumeDynamic()
31 hide(x) => x; 31 hide(x) => x;
32 32
33 main() { 33 main() {
34 var a = hide(new A()); 34 var a = hide(new A());
35 // Make sure we statically have some calls to reflectableThing with 1, 2 and 35 // Make sure we statically have some calls to reflectableThing with 1, 2 and
36 // 3 arguments so that stubs are generated. 36 // 3 arguments so that stubs are generated.
37 Expect.equals(1 + 9 + 42, a.reflectableThing(1)); 37 Expect.equals(1 + 9 + 42, a.reflectableThing(1));
38 Expect.equals(1 + 5 + 42, a.reflectableThing(1, 5)); 38 Expect.equals(1 + 5 + 42, a.reflectableThing(1, 5));
39 Expect.equals(1 + 22 + 3, a.reflectableThing(1, 22, 3)); 39 Expect.equals(1 + 22 + 3, a.reflectableThing(1, 22, 3));
40 // Try calling methods through reflection. 40 // Try calling methods through reflection.
41 tryCall(a, #reflectableThing, [1], 1 + 9 + 42); 41 tryCall(a, #reflectableThing, [1], 1 + 9 + 42);
42 tryCall(a, #reflectableThing, [1, 5], 1 + 5 + 42); 42 tryCall(a, #reflectableThing, [1, 5], 1 + 5 + 42);
43 tryCall(a, #reflectableThing, [1, 22, 3], 1 + 22 + 3); 43 tryCall(a, #reflectableThing, [1, 22, 3], 1 + 22 + 3);
44 Expect.throws(() => tryCall(a, #nonReflectableThing, [1], 1 + 4 + 21)); 44 Expect.throws(() => tryCall(a, #nonReflectableThing, [1], 1 + 4 + 21));
45 Expect.throws(() => tryCall(a, #nonReflectableThing, [1, 5], 1 + 5 + 21)); 45 Expect.throws(() => tryCall(a, #nonReflectableThing, [1, 5], 1 + 5 + 21));
46 Expect.throws(() => tryCall(a, #nonReflectableThing, [1, 13, 7], 1 + 13 + 7)); 46 Expect.throws(() => tryCall(a, #nonReflectableThing, [1, 13, 7], 1 + 13 + 7));
47 // Trigger generation of all declarations and check they only contain a 47 // Trigger generation of all declarations and check they only contain a
48 // a single entry. 48 // a single entry.
49 var declarations = reflect(a).type.declarations; 49 var declarations = reflect(a).type.declarations;
50 Expect.equals(1, declarations.keys.length); 50 Expect.equals(1, declarations.keys.length);
51 Expect.equals(#reflectableThing, declarations.keys.first); 51 Expect.equals(#reflectableThing, declarations.keys.first);
52 } 52 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js_extra/mirror_printer_test.dart ('k') | tests/compiler/dart2js_extra/mirrors_used_closure_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698