OLD | NEW |
1 // 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 |
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 library initialize.transformer_test; | 4 library initialize.transformer_test; |
5 | 5 |
6 import 'common.dart'; | 6 import 'common.dart'; |
7 import 'package:initialize/transformer.dart'; | 7 import 'package:initialize/transformer.dart'; |
8 import 'package:unittest/compact_vm_config.dart'; | 8 import 'package:unittest/compact_vm_config.dart'; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 27 matching lines...) Expand all Loading... |
38 @initMethod | 38 @initMethod |
39 foo() {} | 39 foo() {} |
40 ''', | 40 ''', |
41 'bar|lib/bar.dart': ''' | 41 'bar|lib/bar.dart': ''' |
42 @DynamicInit('bar') | 42 @DynamicInit('bar') |
43 @DynamicInit('bar2') | 43 @DynamicInit('bar2') |
44 library bar; | 44 library bar; |
45 | 45 |
46 import 'package:initialize/initialize.dart'; | 46 import 'package:initialize/initialize.dart'; |
47 import 'package:test_initializers/common.dart'; | 47 import 'package:test_initializers/common.dart'; |
| 48 import 'baz.dart'; |
48 | 49 |
49 @DynamicInit('Bar') | 50 @DynamicInit('Bar') |
50 @DynamicInit('Bar2') | 51 @DynamicInit('Bar2') |
51 class Bar {} | 52 class Bar {} |
52 | 53 |
53 @DynamicInit('bar()') | 54 @DynamicInit('bar()') |
54 @initMethod | 55 @initMethod |
55 bar() {} | 56 bar() {} |
56 ''', | 57 ''', |
| 58 'bar|lib/baz.dart': ''' |
| 59 @constInit |
| 60 library baz; |
| 61 |
| 62 import 'package:test_initializers/common.dart'; |
| 63 ''', |
57 // Mock out the Initialize package plus some initializers. | 64 // Mock out the Initialize package plus some initializers. |
58 'initialize|lib/initialize.dart': mockInitialize, | 65 'initialize|lib/initialize.dart': mockInitialize, |
59 'test_initializers|lib/common.dart': commonInitializers, | 66 'test_initializers|lib/common.dart': commonInitializers, |
60 }, { | 67 }, { |
61 'a|web/index.html': ''' | 68 'a|web/index.html': ''' |
62 <html><head></head><body> | 69 <html><head></head><body> |
63 <script type="application/dart" src="index.bootstrap.dart"></script> | 70 <script type="application/dart" src="index.bootstrap.dart"></script> |
64 | 71 |
65 </body></html>'''.replaceAll(' ', ''), | 72 </body></html>'''.replaceAll(' ', ''), |
66 'a|web/index.bootstrap.dart': ''' | 73 'a|web/index.bootstrap.dart': ''' |
67 import 'package:initialize/src/static_loader.dart'; | 74 import 'package:initialize/src/static_loader.dart'; |
| 75 import 'package:initialize/initialize.dart'; |
68 import 'index.dart' as i0; | 76 import 'index.dart' as i0; |
69 import 'package:bar/bar.dart' as i1; | 77 import 'package:bar/baz.dart' as i1; |
70 import 'package:test_initializers/common.dart' as i2; | 78 import 'package:test_initializers/common.dart' as i2; |
71 import 'package:initialize/initialize.dart' as i3; | 79 import 'package:bar/bar.dart' as i3; |
72 import 'foo.dart' as i4; | 80 import 'package:initialize/initialize.dart' as i4; |
| 81 import 'foo.dart' as i5; |
73 | 82 |
74 main() { | 83 main() { |
75 initializers.addAll([ | 84 initializers.addAll([ |
76 new InitEntry(const i2.DynamicInit('bar'), #bar), | 85 new InitEntry(i2.constInit, const LibraryIdentifier(#baz, 'bar', 'ba
z.dart')), |
77 new InitEntry(const i2.DynamicInit('bar2'), #bar), | 86 new InitEntry(const i2.DynamicInit('bar'), const LibraryIdentifier(#
bar, 'bar', 'bar.dart')), |
78 new InitEntry(const i2.DynamicInit('bar()'), i1.bar), | 87 new InitEntry(const i2.DynamicInit('bar2'), const LibraryIdentifier(
#bar, 'bar', 'bar.dart')), |
79 new InitEntry(i3.initMethod, i1.bar), | 88 new InitEntry(const i2.DynamicInit('bar()'), i3.bar), |
80 new InitEntry(const i2.DynamicInit('Bar'), i1.Bar), | 89 new InitEntry(i4.initMethod, i3.bar), |
81 new InitEntry(const i2.DynamicInit('Bar2'), i1.Bar), | 90 new InitEntry(const i2.DynamicInit('Bar'), i3.Bar), |
82 new InitEntry(i2.constInit, #foo), | 91 new InitEntry(const i2.DynamicInit('Bar2'), i3.Bar), |
83 new InitEntry(i3.initMethod, i4.foo), | 92 new InitEntry(i2.constInit, const LibraryIdentifier(#foo, null, 'foo
.dart')), |
84 new InitEntry(i2.constInit, i4.Foo), | 93 new InitEntry(i4.initMethod, i5.foo), |
| 94 new InitEntry(i2.constInit, i5.Foo), |
85 ]); | 95 ]); |
86 | 96 |
87 i0.main(); | 97 i0.main(); |
88 } | 98 } |
89 '''.replaceAll(' ', '') | 99 '''.replaceAll(' ', '') |
90 }); | 100 }, []); |
91 | 101 |
92 testPhases('constructor arguments', [[transformer]], { | 102 testPhases('constructor arguments', [[transformer]], { |
93 'a|web/index.dart': ''' | 103 'a|web/index.dart': ''' |
94 @DynamicInit(foo) | 104 @DynamicInit(foo) |
95 @DynamicInit(Foo.foo) | 105 @DynamicInit(Foo.foo) |
96 @DynamicInit(const [foo, Foo.foo, 'foo']) | 106 @DynamicInit(const [foo, Foo.foo, 'foo']) |
97 @DynamicInit(const {'foo': foo, 'Foo.foo': Foo.foo, 'bar': 'bar'}) | 107 @DynamicInit(const {'foo': foo, 'Foo.foo': Foo.foo, 'bar': 'bar'}) |
98 @DynamicInit('foo') | 108 @DynamicInit('foo') |
99 @DynamicInit(true) | 109 @DynamicInit(true) |
100 @DynamicInit(null) | 110 @DynamicInit(null) |
(...skipping 13 matching lines...) Expand all Loading... |
114 class Foo { | 124 class Foo { |
115 static foo = 'Foo.foo'; | 125 static foo = 'Foo.foo'; |
116 } | 126 } |
117 ''', | 127 ''', |
118 // Mock out the Initialize package plus some initializers. | 128 // Mock out the Initialize package plus some initializers. |
119 'initialize|lib/initialize.dart': mockInitialize, | 129 'initialize|lib/initialize.dart': mockInitialize, |
120 'test_initializers|lib/common.dart': commonInitializers, | 130 'test_initializers|lib/common.dart': commonInitializers, |
121 }, { | 131 }, { |
122 'a|web/index.bootstrap.dart': ''' | 132 'a|web/index.bootstrap.dart': ''' |
123 import 'package:initialize/src/static_loader.dart'; | 133 import 'package:initialize/src/static_loader.dart'; |
| 134 import 'package:initialize/initialize.dart'; |
124 import 'index.dart' as i0; | 135 import 'index.dart' as i0; |
125 import 'package:test_initializers/common.dart' as i1; | 136 import 'package:test_initializers/common.dart' as i1; |
126 import 'foo.dart' as i2; | 137 import 'foo.dart' as i2; |
127 | 138 |
128 main() { | 139 main() { |
129 initializers.addAll([ | 140 initializers.addAll([ |
130 new InitEntry(const i1.DynamicInit(i2.foo), #web_foo), | 141 new InitEntry(const i1.DynamicInit(i2.foo), const LibraryIdentifier(
#web_foo, null, 'index.dart')), |
131 new InitEntry(const i1.DynamicInit(i2.Foo.foo), #web_foo), | 142 new InitEntry(const i1.DynamicInit(i2.Foo.foo), const LibraryIdentif
ier(#web_foo, null, 'index.dart')), |
132 new InitEntry(const i1.DynamicInit(const [i2.foo, i2.Foo.foo, 'foo']
), #web_foo), | 143 new InitEntry(const i1.DynamicInit(const [i2.foo, i2.Foo.foo, 'foo']
), const LibraryIdentifier(#web_foo, null, 'index.dart')), |
133 new InitEntry(const i1.DynamicInit(const {'foo': i2.foo, 'Foo.foo':
i2.Foo.foo, 'bar': 'bar'}), #web_foo), | 144 new InitEntry(const i1.DynamicInit(const {'foo': i2.foo, 'Foo.foo':
i2.Foo.foo, 'bar': 'bar'}), const LibraryIdentifier(#web_foo, null, 'index.dart'
)), |
134 new InitEntry(const i1.DynamicInit('foo'), #web_foo), | 145 new InitEntry(const i1.DynamicInit('foo'), const LibraryIdentifier(#
web_foo, null, 'index.dart')), |
135 new InitEntry(const i1.DynamicInit(true), #web_foo), | 146 new InitEntry(const i1.DynamicInit(true), const LibraryIdentifier(#w
eb_foo, null, 'index.dart')), |
136 new InitEntry(const i1.DynamicInit(null), #web_foo), | 147 new InitEntry(const i1.DynamicInit(null), const LibraryIdentifier(#w
eb_foo, null, 'index.dart')), |
137 new InitEntry(const i1.DynamicInit(1), #web_foo), | 148 new InitEntry(const i1.DynamicInit(1), const LibraryIdentifier(#web_
foo, null, 'index.dart')), |
138 new InitEntry(const i1.DynamicInit(1.1), #web_foo), | 149 new InitEntry(const i1.DynamicInit(1.1), const LibraryIdentifier(#we
b_foo, null, 'index.dart')), |
139 new InitEntry(const i1.NamedArgInit(1, name: 'Bill'), #web_foo), | 150 new InitEntry(const i1.NamedArgInit(1, name: 'Bill'), const LibraryI
dentifier(#web_foo, null, 'index.dart')), |
140 ]); | 151 ]); |
141 | 152 |
142 i0.main(); | 153 i0.main(); |
143 } | 154 } |
144 '''.replaceAll(' ', '') | 155 '''.replaceAll(' ', '') |
145 }); | 156 }, []); |
146 } | 157 } |
OLD | NEW |