OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 /// Tests that a static configuration can be loaded in pieces, even with | 5 /// Tests that a static configuration can be loaded in pieces, even with |
6 /// deferred imports. | 6 /// deferred imports. |
7 library smoke.test.static_in_pieces_test; | 7 library smoke.test.static_in_pieces_test; |
8 | 8 |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 import 'package:smoke/smoke.dart' show Declaration, PROPERTY, METHOD; | 10 import 'package:smoke/smoke.dart' show Declaration, PROPERTY, METHOD; |
11 import 'package:smoke/static.dart' show useGeneratedCode, StaticConfiguration; | 11 import 'package:smoke/static.dart' show useGeneratedCode, StaticConfiguration; |
12 import 'piece1.dart' as p1; | 12 import 'piece1.dart' as p1; |
13 import 'piece2.dart' deferred as p2; | 13 import 'piece2.dart' deferred as p2; |
14 import 'common.dart' as smoke_0; | 14 import 'common.dart' as smoke_0; |
15 import 'common.dart' as common show main; | 15 import 'common.dart' as common show main; |
16 | 16 |
17 abstract class _M0 {} // C & A | 17 abstract class _M0 {} // C & A |
18 | 18 |
19 final configuration = new StaticConfiguration( | 19 final configuration = new StaticConfiguration( |
20 checkedMode: false, | 20 checkedMode: false, |
21 getters: { | 21 getters: { |
22 #i: (o) => o.i, | 22 #i: (o) => o.i, |
23 #inc0: (o) => o.inc0, | 23 #inc0: (o) => o.inc0, |
24 #inc1: (o) => o.inc1, | 24 #inc1: (o) => o.inc1, |
25 #inc2: (o) => o.inc2, | 25 #inc2: (o) => o.inc2, |
26 #toString: (o) => o.toString, | 26 #toString: (o) => o.toString, |
27 }, | 27 }, |
28 setters: { | 28 setters: { |
29 #i: (o, v) { o.i = v; }, | 29 #i: (o, v) { |
30 }, | 30 o.i = v; |
| 31 }, |
| 32 }, |
31 parents: { | 33 parents: { |
32 smoke_0.AnnotB: smoke_0.Annot, | 34 smoke_0.AnnotB: smoke_0.Annot, |
33 smoke_0.D: _M0, | 35 smoke_0.D: _M0, |
34 smoke_0.E2: smoke_0.E, | 36 smoke_0.E2: smoke_0.E, |
35 smoke_0.F2: smoke_0.F, | 37 smoke_0.F2: smoke_0.F, |
36 _M0: smoke_0.C, | 38 _M0: smoke_0.C, |
37 }, | 39 }, |
38 declarations: { | 40 declarations: { |
39 smoke_0.A: { | 41 smoke_0.A: { |
40 #i: const Declaration(#i, int), | 42 #i: const Declaration(#i, int), |
41 #inc0: const Declaration(#inc0, Function, kind: METHOD), | 43 #inc0: const Declaration(#inc0, Function, kind: METHOD), |
42 #inc1: const Declaration(#inc1, Function, kind: METHOD), | 44 #inc1: const Declaration(#inc1, Function, kind: METHOD), |
43 #inc2: const Declaration(#inc2, Function, kind: METHOD), | 45 #inc2: const Declaration(#inc2, Function, kind: METHOD), |
44 #j: const Declaration(#j, int), | 46 #j: const Declaration(#j, int), |
45 #j2: const Declaration(#j2, int, kind: PROPERTY), | 47 #j2: const Declaration(#j2, int, kind: PROPERTY), |
46 }, | 48 }, |
47 smoke_0.B: { | 49 smoke_0.B: { |
48 #f: const Declaration(#f, int, isFinal: true), | 50 #f: const Declaration(#f, int, isFinal: true), |
49 #w: const Declaration(#w, int, kind: PROPERTY), | 51 #w: const Declaration(#w, int, kind: PROPERTY), |
50 }, | 52 }, |
51 smoke_0.C: { | 53 smoke_0.C: { |
52 #b: const Declaration(#b, smoke_0.B), | 54 #b: const Declaration(#b, smoke_0.B), |
53 #inc: const Declaration(#inc, Function, kind: METHOD), | 55 #inc: const Declaration(#inc, Function, kind: METHOD), |
54 #x: const Declaration(#x, int), | 56 #x: const Declaration(#x, int), |
55 #y: const Declaration(#y, String), | 57 #y: const Declaration(#y, String), |
56 }, | 58 }, |
57 smoke_0.D: { | 59 smoke_0.D: { |
58 #i2: const Declaration(#i2, int, kind: PROPERTY, isFinal: true), | 60 #i2: const Declaration(#i2, int, kind: PROPERTY, isFinal: true), |
59 #x2: const Declaration(#x2, int, kind: PROPERTY, isFinal: true), | 61 #x2: const Declaration(#x2, int, kind: PROPERTY, isFinal: true), |
60 }, | 62 }, |
61 smoke_0.E: { | 63 smoke_0.E: { |
62 #noSuchMethod: const Declaration(#noSuchMethod, Function, kind: METHOD), | 64 #noSuchMethod: const Declaration(#noSuchMethod, Function, kind: METHOD), |
63 #y: const Declaration(#y, int, kind: PROPERTY, isFinal: true), | 65 #y: const Declaration(#y, int, kind: PROPERTY, isFinal: true), |
64 }, | 66 }, |
65 smoke_0.E2: {}, | 67 smoke_0.E2: {}, |
66 smoke_0.F: { | 68 smoke_0.F: { |
67 #staticMethod: const Declaration(#staticMethod, Function, kind: METHOD,
isStatic: true), | 69 #staticMethod: const Declaration(#staticMethod, Function, |
68 }, | 70 kind: METHOD, isStatic: true), |
69 smoke_0.F2: {}, | 71 }, |
70 smoke_0.G: { | 72 smoke_0.F2: {}, |
71 #b: const Declaration(#b, int, annotations: const [smoke_0.a1]), | 73 smoke_0.G: { |
72 #d: const Declaration(#d, int, annotations: const [smoke_0.a2]), | 74 #b: const Declaration(#b, int, annotations: const [smoke_0.a1]), |
73 }, | 75 #d: const Declaration(#d, int, annotations: const [smoke_0.a2]), |
74 _M0: { | 76 }, |
75 #i: const Declaration(#i, int), | 77 _M0: { |
76 #inc: const Declaration(#inc, Function, kind: METHOD), | 78 #i: const Declaration(#i, int), |
77 #inc0: const Declaration(#inc0, Function, kind: METHOD), | 79 #inc: const Declaration(#inc, Function, kind: METHOD), |
78 #j: const Declaration(#j, int), | 80 #inc0: const Declaration(#inc0, Function, kind: METHOD), |
79 #j2: const Declaration(#j2, int, kind: PROPERTY), | 81 #j: const Declaration(#j, int), |
80 }, | 82 #j2: const Declaration(#j2, int, kind: PROPERTY), |
81 }, | 83 }, |
| 84 }, |
82 staticMethods: {}, | 85 staticMethods: {}, |
83 names: {}); | 86 names: {}); |
84 | 87 |
85 main() { | 88 main() { |
86 useGeneratedCode(configuration); | 89 useGeneratedCode(configuration); |
87 | 90 |
88 expect(configuration.getters[#j], isNull); | 91 expect(configuration.getters[#j], isNull); |
89 | 92 |
90 configuration.addAll(p1.configuration); | 93 configuration.addAll(p1.configuration); |
91 expect(configuration.getters[#j], isNotNull); | 94 expect(configuration.getters[#j], isNotNull); |
92 | 95 |
93 p2.loadLibrary().then((_) { | 96 p2.loadLibrary().then((_) { |
94 expect(configuration.names[#i], isNull); | 97 expect(configuration.names[#i], isNull); |
95 configuration.addAll(p2.configuration); | 98 configuration.addAll(p2.configuration); |
96 expect(configuration.names[#i], 'i'); | 99 expect(configuration.names[#i], 'i'); |
97 common.main(); | 100 common.main(); |
98 }); | 101 }); |
99 } | 102 } |
OLD | NEW |