OLD | NEW |
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 polymer.test.build.script_compactor_test; | 5 library polymer.test.build.script_compactor_test; |
6 | 6 |
7 import 'package:code_transformers/tests.dart' show testingDartSdkDirectory; | 7 import 'package:code_transformers/tests.dart' show testingDartSdkDirectory; |
8 import 'package:polymer/src/build/common.dart'; | 8 import 'package:polymer/src/build/common.dart'; |
9 import 'package:polymer/src/build/script_compactor.dart'; | 9 import 'package:polymer/src/build/script_compactor.dart'; |
10 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS; | 10 import 'package:smoke/codegen/generator.dart' show DEFAULT_IMPORTS; |
(...skipping 13 matching lines...) Expand all Loading... |
24 initializerTests(phases) { | 24 initializerTests(phases) { |
25 testPhases('no changes', phases, { | 25 testPhases('no changes', phases, { |
26 'a|web/test.html': '<!DOCTYPE html><html></html>', | 26 'a|web/test.html': '<!DOCTYPE html><html></html>', |
27 'a|web/test.html.scriptUrls': '[]', | 27 'a|web/test.html.scriptUrls': '[]', |
28 }, { | 28 }, { |
29 'a|web/test.html': '<!DOCTYPE html><html></html>', | 29 'a|web/test.html': '<!DOCTYPE html><html></html>', |
30 }); | 30 }); |
31 | 31 |
32 testPhases('no changes outside web/', phases, { | 32 testPhases('no changes outside web/', phases, { |
33 'a|lib/test.html': | 33 'a|lib/test.html': |
34 '<!DOCTYPE html><html><head>' | 34 '<!DOCTYPE html><html><head>', |
35 '<script type="application/dart" src="a.dart"></script>', | 35 'a|lib/test.html.scriptUrls': '[["a","lib/a.dart"]]', |
36 }, { | 36 }, { |
37 'a|lib/test.html': | 37 'a|lib/test.html': |
38 '<!DOCTYPE html><html><head>' | 38 '<!DOCTYPE html><html><head>', |
39 '<script type="application/dart" src="a.dart"></script>', | 39 'a|lib/test.html.scriptUrls': '[["a","lib/a.dart"]]', |
40 }); | 40 }); |
41 | 41 |
42 testPhases('single script', phases, { | 42 testPhases('single script', phases, { |
43 'a|web/test.html': | 43 'a|web/test.html': |
44 '<!DOCTYPE html><html><head>' | 44 '<!DOCTYPE html><html><head>', |
45 '<script type="application/dart" src="a.dart"></script>', | 45 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
46 'a|web/test.html.scriptUrls': '[]', | |
47 'a|web/a.dart': | 46 'a|web/a.dart': |
48 'library a;\n' | 47 'library a;\n' |
49 'import "package:polymer/polymer.dart";\n' | 48 'import "package:polymer/polymer.dart";\n' |
50 'main(){}', | 49 '@initMethod main(){}', |
51 }, { | 50 }, { |
52 'a|web/test.html': | 51 'a|web/test.html': |
53 '<!DOCTYPE html><html><head>' | 52 '<!DOCTYPE html><html><head></head><body>' |
54 '<script type="application/dart" ' | 53 '<script type="application/dart" ' |
55 'src="test.html_bootstrap.dart"></script>' | 54 'src="test.html_bootstrap.dart"></script>' |
56 '</head><body></body></html>', | 55 '</body></html>', |
57 | 56 |
58 'a|web/test.html_bootstrap.dart': | 57 'a|web/test.html_bootstrap.dart': |
59 '''$MAIN_HEADER | 58 '''$MAIN_HEADER |
60 import 'a.dart' as i0; | 59 import 'a.dart' as i0; |
61 ${DEFAULT_IMPORTS.join('\n')} | 60 ${DEFAULT_IMPORTS.join('\n')} |
62 | 61 |
63 void main() { | 62 void main() { |
64 useGeneratedCode(new StaticConfiguration( | 63 useGeneratedCode(new StaticConfiguration( |
65 checkedMode: false)); | 64 checkedMode: false)); |
66 configureForDeployment([ | 65 startPolymer([ |
| 66 i0.main, |
67 ]); | 67 ]); |
68 i0.main(); | |
69 } | 68 } |
70 '''.replaceAll('\n ', '\n'), | 69 '''.replaceAll('\n ', '\n'), |
71 'a|web/a.dart': | 70 'a|web/a.dart': |
72 'library a;\n' | 71 'library a;\n' |
73 'import "package:polymer/polymer.dart";\n' | 72 'import "package:polymer/polymer.dart";\n' |
74 'main(){}', | 73 '@initMethod main(){}', |
75 }); | 74 }); |
76 | 75 |
77 testPhases('simple initialization', phases, { | 76 testPhases('simple initialization', phases, { |
78 'a|web/test.html': | 77 'a|web/test.html': |
79 '<!DOCTYPE html><html><head>' | 78 '<!DOCTYPE html><html><head>', |
80 '<script type="application/dart" src="a.dart"></script>', | 79 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
81 'a|web/test.html.scriptUrls': '[]', | |
82 'a|web/a.dart': | 80 'a|web/a.dart': |
83 'library a;\n' | 81 'library a;\n' |
84 'import "package:polymer/polymer.dart";\n' | 82 'import "package:polymer/polymer.dart";\n' |
85 '@CustomTag("x-foo")\n' | 83 '@CustomTag("x-foo")\n' |
86 'class XFoo extends PolymerElement {\n' | 84 'class XFoo extends PolymerElement {\n' |
87 '}\n' | 85 '}\n' |
88 'main(){}', | 86 '@initMethod main(){}', |
89 }, { | 87 }, { |
90 'a|web/test.html_bootstrap.dart': | 88 'a|web/test.html_bootstrap.dart': |
91 '''$MAIN_HEADER | 89 '''$MAIN_HEADER |
92 import 'a.dart' as i0; | 90 import 'a.dart' as i0; |
93 ${DEFAULT_IMPORTS.join('\n')} | 91 ${DEFAULT_IMPORTS.join('\n')} |
94 import 'a.dart' as smoke_0; | 92 import 'a.dart' as smoke_0; |
95 import 'package:polymer/polymer.dart' as smoke_1; | 93 import 'package:polymer/polymer.dart' as smoke_1; |
96 | 94 |
97 void main() { | 95 void main() { |
98 useGeneratedCode(new StaticConfiguration( | 96 useGeneratedCode(new StaticConfiguration( |
99 checkedMode: false, | 97 checkedMode: false, |
100 parents: { | 98 parents: { |
101 smoke_0.XFoo: smoke_1.PolymerElement, | 99 smoke_0.XFoo: smoke_1.PolymerElement, |
102 }, | 100 }, |
103 declarations: { | 101 declarations: { |
104 smoke_0.XFoo: const {}, | 102 smoke_0.XFoo: const {}, |
105 })); | 103 })); |
106 configureForDeployment([ | 104 startPolymer([ |
| 105 i0.main, |
107 () => Polymer.register(\'x-foo\', i0.XFoo), | 106 () => Polymer.register(\'x-foo\', i0.XFoo), |
108 ]); | 107 ]); |
109 i0.main(); | |
110 } | 108 } |
111 '''.replaceAll('\n ', '\n'), | 109 '''.replaceAll('\n ', '\n'), |
112 }); | 110 }); |
113 | 111 |
114 testPhases('use const expressions', phases, { | 112 testPhases('use const expressions', phases, { |
115 'a|web/test.html': | 113 'a|web/test.html': |
116 '<!DOCTYPE html><html><head>' | 114 '<!DOCTYPE html><html><head>', |
117 '<script type="application/dart" src="a.dart"></script>', | 115 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
118 'a|web/test.html.scriptUrls': '[]', | |
119 'a|web/b.dart': | 116 'a|web/b.dart': |
120 'library a;\n' | 117 'library a;\n' |
121 'const x = "x";\n', | 118 'const x = "x";\n', |
122 'a|web/c.dart': | 119 'a|web/c.dart': |
123 'part of a;\n' | 120 'part of a;\n' |
124 'const dash = "-";\n', | 121 'const dash = "-";\n', |
125 'a|web/a.dart': | 122 'a|web/a.dart': |
126 'library a;\n' | 123 'library a;\n' |
127 'import "package:polymer/polymer.dart";\n' | 124 'import "package:polymer/polymer.dart";\n' |
128 'import "b.dart";\n' | 125 'import "b.dart";\n' |
129 'part "c.dart";\n' | 126 'part "c.dart";\n' |
130 'const letterO = "o";\n' | 127 'const letterO = "o";\n' |
131 '@CustomTag("\$x\${dash}f\${letterO}o2")\n' | 128 '@CustomTag("\$x\${dash}f\${letterO}o2")\n' |
132 'class XFoo extends PolymerElement {\n' | 129 'class XFoo extends PolymerElement {\n' |
133 '}\n' | 130 '}\n', |
134 'main(){}', | |
135 }, { | 131 }, { |
136 'a|web/test.html_bootstrap.dart': | 132 'a|web/test.html_bootstrap.dart': |
137 '''$MAIN_HEADER | 133 '''$MAIN_HEADER |
138 import 'a.dart' as i0; | 134 import 'a.dart' as i0; |
139 ${DEFAULT_IMPORTS.join('\n')} | 135 ${DEFAULT_IMPORTS.join('\n')} |
140 import 'a.dart' as smoke_0; | 136 import 'a.dart' as smoke_0; |
141 import 'package:polymer/polymer.dart' as smoke_1; | 137 import 'package:polymer/polymer.dart' as smoke_1; |
142 | 138 |
143 void main() { | 139 void main() { |
144 useGeneratedCode(new StaticConfiguration( | 140 useGeneratedCode(new StaticConfiguration( |
145 checkedMode: false, | 141 checkedMode: false, |
146 parents: { | 142 parents: { |
147 smoke_0.XFoo: smoke_1.PolymerElement, | 143 smoke_0.XFoo: smoke_1.PolymerElement, |
148 }, | 144 }, |
149 declarations: { | 145 declarations: { |
150 smoke_0.XFoo: const {}, | 146 smoke_0.XFoo: const {}, |
151 })); | 147 })); |
152 configureForDeployment([ | 148 startPolymer([ |
153 () => Polymer.register(\'x-foo2\', i0.XFoo), | 149 () => Polymer.register(\'x-foo2\', i0.XFoo), |
154 ]); | 150 ]); |
155 i0.main(); | |
156 } | 151 } |
157 '''.replaceAll('\n ', '\n'), | 152 '''.replaceAll('\n ', '\n'), |
158 }); | 153 }); |
159 | 154 |
160 testPhases('invalid const expression', phases, { | 155 testPhases('invalid const expression', phases, { |
161 'a|web/test.html': | 156 'a|web/test.html': |
162 '<!DOCTYPE html><html><head>' | 157 '<!DOCTYPE html><html><head>', |
163 '<script type="application/dart" src="a.dart"></script>', | 158 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
164 'a|web/test.html.scriptUrls': '[]', | |
165 'a|web/a.dart': | 159 'a|web/a.dart': |
166 'library a;\n' | 160 'library a;\n' |
167 'import "package:polymer/polymer.dart";\n' | 161 'import "package:polymer/polymer.dart";\n' |
168 '@CustomTag("\${x}-foo")\n' // invalid, x is not defined | 162 '@CustomTag("\${x}-foo")\n' // invalid, x is not defined |
169 'class XFoo extends PolymerElement {\n' | 163 'class XFoo extends PolymerElement {\n' |
170 '}\n' | 164 '}\n' |
171 'main(){}', | 165 'main(){}', |
172 }, {}, [ | 166 }, {}, [ |
173 'warning: The parameter to @CustomTag seems to be invalid. ' | 167 'warning: The parameter to @CustomTag seems to be invalid. ' |
174 '(web/a.dart 2 11)', | 168 '(web/a.dart 2 11)', |
175 ]); | 169 ]); |
176 | 170 |
177 testPhases('several scripts', phases, { | 171 testPhases('several scripts', phases, { |
178 'a|web/test.html': | 172 'a|web/test.html': |
179 '<!DOCTYPE html><html><head>' | 173 '<!DOCTYPE html><html><head>' |
180 '</head><body><div>' | 174 '</head><body><div></div>', |
181 '<script type="application/dart" src="d.dart"></script>' | |
182 '</div>', | |
183 'a|web/test.html.scriptUrls': | 175 'a|web/test.html.scriptUrls': |
184 '[["a", "web/a.dart"],["a", "web/b.dart"],["a", "web/c.dart"]]', | 176 '[["a", "web/a.dart"],["a", "web/b.dart"],["a", "web/c.dart"],' |
| 177 '["a", "web/d.dart"]]', |
185 'a|web/d.dart': | 178 'a|web/d.dart': |
186 'library d;\n' | 179 'library d;\n' |
187 'import "package:polymer/polymer.dart";\n' | 180 'import "package:polymer/polymer.dart";\n' |
188 'main(){}\n@initMethod mD(){}', | 181 '@initMethod main(){}\n@initMethod mD(){}', |
189 | 182 |
190 'a|web/a.dart': | 183 'a|web/a.dart': |
191 'import "package:polymer/polymer.dart";\n' | 184 'import "package:polymer/polymer.dart";\n' |
192 '@initMethod mA(){}\n', | 185 '@initMethod mA(){}\n', |
193 | 186 |
194 'a|web/b.dart': | 187 'a|web/b.dart': |
195 'import "package:polymer/polymer.dart";\n' | 188 'import "package:polymer/polymer.dart";\n' |
196 'export "e.dart";\n' | 189 'export "e.dart";\n' |
197 'export "f.dart" show XF1, mF1;\n' | 190 'export "f.dart" show XF1, mF1;\n' |
198 'export "g.dart" hide XG1, mG1;\n' | 191 'export "g.dart" hide XG1, mG1;\n' |
(...skipping 28 matching lines...) Expand all Loading... |
227 '@initMethod mG2(){}\n', | 220 '@initMethod mG2(){}\n', |
228 | 221 |
229 'a|web/h.dart': | 222 'a|web/h.dart': |
230 'import "package:polymer/polymer.dart";\n' | 223 'import "package:polymer/polymer.dart";\n' |
231 '@CustomTag("x-h1") class XH1 extends PolymerElement {}\n' | 224 '@CustomTag("x-h1") class XH1 extends PolymerElement {}\n' |
232 '@initMethod mH1(){}\n' | 225 '@initMethod mH1(){}\n' |
233 '@CustomTag("x-h2") class XH2 extends PolymerElement {}\n' | 226 '@CustomTag("x-h2") class XH2 extends PolymerElement {}\n' |
234 '@initMethod mH2(){}\n', | 227 '@initMethod mH2(){}\n', |
235 }, { | 228 }, { |
236 'a|web/test.html': | 229 'a|web/test.html': |
237 '<!DOCTYPE html><html><head></head><body><div>' | 230 '<!DOCTYPE html><html><head></head><body><div></div>' |
238 '<script type="application/dart" src="test.html_bootstrap.dart">' | 231 '<script type="application/dart" src="test.html_bootstrap.dart">' |
239 '</script>' | 232 '</script>' |
240 '</div>' | |
241 '</body></html>', | 233 '</body></html>', |
242 | 234 |
243 'a|web/test.html_bootstrap.dart': | 235 'a|web/test.html_bootstrap.dart': |
244 '''$MAIN_HEADER | 236 '''$MAIN_HEADER |
245 import 'a.dart' as i0; | 237 import 'a.dart' as i0; |
246 import 'b.dart' as i1; | 238 import 'b.dart' as i1; |
247 import 'c.dart' as i2; | 239 import 'c.dart' as i2; |
248 import 'd.dart' as i3; | 240 import 'd.dart' as i3; |
249 ${DEFAULT_IMPORTS.join('\n')} | 241 ${DEFAULT_IMPORTS.join('\n')} |
250 import 'e.dart' as smoke_0; | 242 import 'e.dart' as smoke_0; |
(...skipping 15 matching lines...) Expand all Loading... |
266 smoke_4.XH1: smoke_1.PolymerElement, | 258 smoke_4.XH1: smoke_1.PolymerElement, |
267 }, | 259 }, |
268 declarations: { | 260 declarations: { |
269 smoke_5.XC1: const {}, | 261 smoke_5.XC1: const {}, |
270 smoke_5.XC2: const {}, | 262 smoke_5.XC2: const {}, |
271 smoke_0.XE: const {}, | 263 smoke_0.XE: const {}, |
272 smoke_2.XF1: const {}, | 264 smoke_2.XF1: const {}, |
273 smoke_3.XG2: const {}, | 265 smoke_3.XG2: const {}, |
274 smoke_4.XH1: const {}, | 266 smoke_4.XH1: const {}, |
275 })); | 267 })); |
276 configureForDeployment([ | 268 startPolymer([ |
277 i0.mA, | 269 i0.mA, |
278 i1.mB, | 270 i1.mB, |
279 i1.mE, | 271 i1.mE, |
280 i1.mF1, | 272 i1.mF1, |
281 i1.mG2, | 273 i1.mG2, |
282 () => Polymer.register('x-e', i1.XE), | 274 () => Polymer.register('x-e', i1.XE), |
283 () => Polymer.register('x-f1', i1.XF1), | 275 () => Polymer.register('x-f1', i1.XF1), |
284 () => Polymer.register('x-g2', i1.XG2), | 276 () => Polymer.register('x-g2', i1.XG2), |
285 () => Polymer.register('x-h1', i1.XH1), | 277 () => Polymer.register('x-h1', i1.XH1), |
286 () => Polymer.register('x-c1', i2.XC1), | 278 () => Polymer.register('x-c1', i2.XC1), |
287 () => Polymer.register('x-c2', i2.XC2), | 279 () => Polymer.register('x-c2', i2.XC2), |
| 280 i3.main, |
288 i3.mD, | 281 i3.mD, |
289 ]); | 282 ]); |
290 i3.main(); | |
291 } | 283 } |
292 '''.replaceAll('\n ', '\n'), | 284 '''.replaceAll('\n ', '\n'), |
293 }, null); | 285 }, null); |
294 } | 286 } |
295 | 287 |
296 codegenTests(phases) { | 288 codegenTests(phases) { |
297 testPhases('bindings', phases, { | 289 testPhases('bindings', phases, { |
298 'a|web/test.html': | 290 'a|web/test.html': |
299 '<!DOCTYPE html><html><body>' | 291 '<!DOCTYPE html><html><body>' |
300 '<polymer-element name="foo-bar"><template>' | 292 '<polymer-element name="foo-bar"><template>' |
301 '<div>{{a.node}}</div>' | 293 '<div>{{a.node}}</div>' |
302 '<div>{{anotherNode}}</div>' | 294 '<div>{{anotherNode}}</div>' |
303 '<div class="{{an.attribute}}"></div>' | 295 '<div class="{{an.attribute}}"></div>' |
304 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' | 296 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' |
305 '<div data-attribute="{{anotherAttribute}}"></div>' | 297 '<div data-attribute="{{anotherAttribute}}"></div>' |
306 // input and custom-element attributes are treated as 2-way bindings: | 298 // input and custom-element attributes are treated as 2-way bindings: |
307 '<input value="{{this.is.twoWay}}">' | 299 '<input value="{{this.is.twoWay}}">' |
308 '<something-else my-attribute="{{here.too}}"></something-else>' | 300 '<something-else my-attribute="{{here.too}}"></something-else>' |
309 '<div on-click="{{methodName}}"></div>' | 301 '<div on-click="{{methodName}}"></div>' |
310 '<div on-click="{{@read.method}}"></div>' | 302 '<div on-click="{{@read.method}}"></div>' |
311 '</template></polymer-element>' | 303 '</template></polymer-element>', |
312 '<script type="application/dart" src="a.dart"></script>', | 304 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
313 'a|web/test.html.scriptUrls': '[]', | |
314 'a|web/a.dart': | 305 'a|web/a.dart': |
315 'library a;\n' | 306 'library a;\n' |
316 'import "package:polymer/polymer.dart";\n' | 307 'import "package:polymer/polymer.dart";\n' |
317 'main(){}', | 308 '@initMethod main(){}', |
318 }, { | 309 }, { |
319 'a|web/test.html_bootstrap.dart': | 310 'a|web/test.html_bootstrap.dart': |
320 '''$MAIN_HEADER | 311 '''$MAIN_HEADER |
321 import 'a.dart' as i0; | 312 import 'a.dart' as i0; |
322 ${DEFAULT_IMPORTS.join('\n')} | 313 ${DEFAULT_IMPORTS.join('\n')} |
323 | 314 |
324 void main() { | 315 void main() { |
325 useGeneratedCode(new StaticConfiguration( | 316 useGeneratedCode(new StaticConfiguration( |
326 checkedMode: false, | 317 checkedMode: false, |
327 getters: { | 318 getters: { |
(...skipping 25 matching lines...) Expand all Loading... |
353 #here: r'here', | 344 #here: r'here', |
354 #is: r'is', | 345 #is: r'is', |
355 #method: r'method', | 346 #method: r'method', |
356 #methodName: r'methodName', | 347 #methodName: r'methodName', |
357 #node: r'node', | 348 #node: r'node', |
358 #read: r'read', | 349 #read: r'read', |
359 #too: r'too', | 350 #too: r'too', |
360 #twoWay: r'twoWay', | 351 #twoWay: r'twoWay', |
361 #within: r'within', | 352 #within: r'within', |
362 })); | 353 })); |
363 configureForDeployment([ | 354 startPolymer([ |
| 355 i0.main, |
364 ]); | 356 ]); |
365 i0.main(); | |
366 } | 357 } |
367 '''.replaceAll('\n ', '\n'), | 358 '''.replaceAll('\n ', '\n'), |
368 'a|web/a.dart': | 359 'a|web/a.dart': |
369 'library a;\n' | 360 'library a;\n' |
370 'import "package:polymer/polymer.dart";\n' | 361 'import "package:polymer/polymer.dart";\n' |
371 'main(){}', | 362 '@initMethod main(){}', |
372 }); | 363 }); |
373 | 364 |
374 final field1Details = "annotations: const [smoke_1.published]"; | 365 final field1Details = "annotations: const [smoke_1.published]"; |
375 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; | 366 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; |
376 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; | 367 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; |
377 final prop3Details = | 368 final prop3Details = |
378 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; | 369 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; |
379 testPhases('published via annotation', phases, { | 370 testPhases('published via annotation', phases, { |
380 'a|web/test.html': | 371 'a|web/test.html': |
381 '<!DOCTYPE html><html><body>' | 372 '<!DOCTYPE html><html><body>', |
382 '<script type="application/dart" src="a.dart"></script>', | 373 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
383 'a|web/test.html.scriptUrls': '[]', | |
384 'a|web/a.dart': | 374 'a|web/a.dart': |
385 'library a;\n' | 375 'library a;\n' |
386 'import "package:polymer/polymer.dart";\n' | 376 'import "package:polymer/polymer.dart";\n' |
387 '@CustomTag("x-foo")\n' | 377 '@CustomTag("x-foo")\n' |
388 'class XFoo extends PolymerElement {\n' | 378 'class XFoo extends PolymerElement {\n' |
389 ' @published int field1;\n' | 379 ' @published int field1;\n' |
390 ' int field2;\n' | 380 ' int field2;\n' |
391 ' @published final int field3;\n' | 381 ' @published final int field3;\n' |
392 ' final int field4;\n' | 382 ' final int field4;\n' |
393 ' @published int get prop1 => 1;\n' | 383 ' @published int get prop1 => 1;\n' |
394 ' set prop1(int x) {};\n' | 384 ' set prop1(int x) {};\n' |
395 ' int get prop2 => 2;\n' | 385 ' int get prop2 => 2;\n' |
396 ' set prop2(int x) {};\n' | 386 ' set prop2(int x) {};\n' |
397 ' @published int get prop3 => 3;\n' | 387 ' @published int get prop3 => 3;\n' |
398 ' int get prop4 => 4;\n' | 388 ' int get prop4 => 4;\n' |
399 ' @published int method1() => 1;\n' | 389 ' @published int method1() => 1;\n' |
400 ' int method2() => 2;\n' | 390 ' int method2() => 2;\n' |
401 '}\n' | 391 '}\n', |
402 'main(){}', | |
403 }, { | 392 }, { |
404 'a|web/test.html_bootstrap.dart': | 393 'a|web/test.html_bootstrap.dart': |
405 '''$MAIN_HEADER | 394 '''$MAIN_HEADER |
406 import 'a.dart' as i0; | 395 import 'a.dart' as i0; |
407 ${DEFAULT_IMPORTS.join('\n')} | 396 ${DEFAULT_IMPORTS.join('\n')} |
408 import 'a.dart' as smoke_0; | 397 import 'a.dart' as smoke_0; |
409 import 'package:polymer/polymer.dart' as smoke_1; | 398 import 'package:polymer/polymer.dart' as smoke_1; |
410 | 399 |
411 void main() { | 400 void main() { |
412 useGeneratedCode(new StaticConfiguration( | 401 useGeneratedCode(new StaticConfiguration( |
(...skipping 18 matching lines...) Expand all Loading... |
431 #prop1: const Declaration(#prop1, int, $prop1Details), | 420 #prop1: const Declaration(#prop1, int, $prop1Details), |
432 #prop3: const Declaration(#prop3, int, $prop3Details), | 421 #prop3: const Declaration(#prop3, int, $prop3Details), |
433 }, | 422 }, |
434 }, | 423 }, |
435 names: { | 424 names: { |
436 #field1: r'field1', | 425 #field1: r'field1', |
437 #field3: r'field3', | 426 #field3: r'field3', |
438 #prop1: r'prop1', | 427 #prop1: r'prop1', |
439 #prop3: r'prop3', | 428 #prop3: r'prop3', |
440 })); | 429 })); |
441 configureForDeployment([ | 430 startPolymer([ |
442 () => Polymer.register(\'x-foo\', i0.XFoo), | 431 () => Polymer.register(\'x-foo\', i0.XFoo), |
443 ]); | 432 ]); |
444 i0.main(); | |
445 } | 433 } |
446 '''.replaceAll('\n ', '\n'), | 434 '''.replaceAll('\n ', '\n'), |
447 }); | 435 }); |
448 | 436 |
449 testPhases('published via attributes', phases, { | 437 testPhases('published via attributes', phases, { |
450 'a|web/test.html': | 438 'a|web/test.html': |
451 '<!DOCTYPE html><html><body>' | 439 '<!DOCTYPE html><html><body>' |
452 '<polymer-element name="x-foo" attributes="field1,prop2">' | 440 '<polymer-element name="x-foo" attributes="field1,prop2">' |
453 '</polymer-element>' | 441 '</polymer-element>', |
454 '<script type="application/dart" src="a.dart"></script>', | 442 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
455 'a|web/test.html.scriptUrls': '[]', | |
456 'a|web/a.dart': | 443 'a|web/a.dart': |
457 'library a;\n' | 444 'library a;\n' |
458 'import "package:polymer/polymer.dart";\n' | 445 'import "package:polymer/polymer.dart";\n' |
459 '@CustomTag("x-foo")\n' | 446 '@CustomTag("x-foo")\n' |
460 'class XFoo extends PolymerElement {\n' | 447 'class XFoo extends PolymerElement {\n' |
461 ' int field1;\n' | 448 ' int field1;\n' |
462 ' int field2;\n' | 449 ' int field2;\n' |
463 ' int get prop1 => 1;\n' | 450 ' int get prop1 => 1;\n' |
464 ' set prop1(int x) {};\n' | 451 ' set prop1(int x) {};\n' |
465 ' int get prop2 => 2;\n' | 452 ' int get prop2 => 2;\n' |
466 ' set prop2(int x) {};\n' | 453 ' set prop2(int x) {};\n' |
467 '}\n' | 454 '}\n', |
468 'main(){}', | |
469 }, { | 455 }, { |
470 'a|web/test.html_bootstrap.dart': | 456 'a|web/test.html_bootstrap.dart': |
471 '''$MAIN_HEADER | 457 '''$MAIN_HEADER |
472 import 'a.dart' as i0; | 458 import 'a.dart' as i0; |
473 ${DEFAULT_IMPORTS.join('\n')} | 459 ${DEFAULT_IMPORTS.join('\n')} |
474 import 'a.dart' as smoke_0; | 460 import 'a.dart' as smoke_0; |
475 import 'package:polymer/polymer.dart' as smoke_1; | 461 import 'package:polymer/polymer.dart' as smoke_1; |
476 | 462 |
477 void main() { | 463 void main() { |
478 useGeneratedCode(new StaticConfiguration( | 464 useGeneratedCode(new StaticConfiguration( |
(...skipping 12 matching lines...) Expand all Loading... |
491 declarations: { | 477 declarations: { |
492 smoke_0.XFoo: { | 478 smoke_0.XFoo: { |
493 #field1: const Declaration(#field1, int), | 479 #field1: const Declaration(#field1, int), |
494 #prop2: const Declaration(#prop2, int, kind: PROPERTY), | 480 #prop2: const Declaration(#prop2, int, kind: PROPERTY), |
495 }, | 481 }, |
496 }, | 482 }, |
497 names: { | 483 names: { |
498 #field1: r'field1', | 484 #field1: r'field1', |
499 #prop2: r'prop2', | 485 #prop2: r'prop2', |
500 })); | 486 })); |
501 configureForDeployment([ | 487 startPolymer([ |
502 () => Polymer.register(\'x-foo\', i0.XFoo), | 488 () => Polymer.register(\'x-foo\', i0.XFoo), |
503 ]); | 489 ]); |
504 i0.main(); | |
505 } | 490 } |
506 '''.replaceAll('\n ', '\n'), | 491 '''.replaceAll('\n ', '\n'), |
507 }); | 492 }); |
508 | 493 |
509 final fooDetails = | 494 final fooDetails = |
510 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; | 495 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; |
511 final xChangedDetails = "Function, kind: METHOD"; | 496 final xChangedDetails = "Function, kind: METHOD"; |
512 testPhases('ObserveProperty and *Changed methods', phases, { | 497 testPhases('ObserveProperty and *Changed methods', phases, { |
513 'a|web/test.html': | 498 'a|web/test.html': |
514 '<!DOCTYPE html><html><body>' | 499 '<!DOCTYPE html><html><body>' |
515 '</polymer-element>' | 500 '</polymer-element>', |
516 '<script type="application/dart" src="a.dart"></script>', | 501 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
517 'a|web/test.html.scriptUrls': '[]', | |
518 'a|web/a.dart': | 502 'a|web/a.dart': |
519 'library a;\n' | 503 'library a;\n' |
520 'import "package:polymer/polymer.dart";\n' | 504 'import "package:polymer/polymer.dart";\n' |
521 '@CustomTag("x-foo")\n' | 505 '@CustomTag("x-foo")\n' |
522 'class XFoo extends PolymerElement {\n' | 506 'class XFoo extends PolymerElement {\n' |
523 ' int x;\n' | 507 ' int x;\n' |
524 ' void xChanged() {}\n' | 508 ' void xChanged() {}\n' |
525 ' void attributeChanged() {}\n' // should be excluded | 509 ' void attributeChanged() {}\n' // should be excluded |
526 ' @ObserveProperty("x")' | 510 ' @ObserveProperty("x")' |
527 ' void foo() {}\n' | 511 ' void foo() {}\n' |
528 '}\n' | 512 '}\n', |
529 'main(){}', | |
530 }, { | 513 }, { |
531 'a|web/test.html_bootstrap.dart': | 514 'a|web/test.html_bootstrap.dart': |
532 '''$MAIN_HEADER | 515 '''$MAIN_HEADER |
533 import 'a.dart' as i0; | 516 import 'a.dart' as i0; |
534 ${DEFAULT_IMPORTS.join('\n')} | 517 ${DEFAULT_IMPORTS.join('\n')} |
535 import 'a.dart' as smoke_0; | 518 import 'a.dart' as smoke_0; |
536 import 'package:polymer/polymer.dart' as smoke_1; | 519 import 'package:polymer/polymer.dart' as smoke_1; |
537 | 520 |
538 void main() { | 521 void main() { |
539 useGeneratedCode(new StaticConfiguration( | 522 useGeneratedCode(new StaticConfiguration( |
540 checkedMode: false, | 523 checkedMode: false, |
541 getters: { | 524 getters: { |
542 #foo: (o) => o.foo, | 525 #foo: (o) => o.foo, |
543 #xChanged: (o) => o.xChanged, | 526 #xChanged: (o) => o.xChanged, |
544 }, | 527 }, |
545 parents: { | 528 parents: { |
546 smoke_0.XFoo: smoke_1.PolymerElement, | 529 smoke_0.XFoo: smoke_1.PolymerElement, |
547 }, | 530 }, |
548 declarations: { | 531 declarations: { |
549 smoke_0.XFoo: { | 532 smoke_0.XFoo: { |
550 #foo: const Declaration(#foo, Function, $fooDetails), | 533 #foo: const Declaration(#foo, Function, $fooDetails), |
551 #xChanged: const Declaration(#xChanged, $xChangedDetails), | 534 #xChanged: const Declaration(#xChanged, $xChangedDetails), |
552 }, | 535 }, |
553 }, | 536 }, |
554 names: { | 537 names: { |
555 #foo: r'foo', | 538 #foo: r'foo', |
556 #xChanged: r'xChanged', | 539 #xChanged: r'xChanged', |
557 })); | 540 })); |
558 configureForDeployment([ | 541 startPolymer([ |
559 () => Polymer.register(\'x-foo\', i0.XFoo), | 542 () => Polymer.register(\'x-foo\', i0.XFoo), |
560 ]); | 543 ]); |
561 i0.main(); | |
562 } | 544 } |
563 '''.replaceAll('\n ', '\n'), | 545 '''.replaceAll('\n ', '\n'), |
564 }); | 546 }); |
565 | 547 |
566 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; | 548 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; |
567 testPhases('register callback is included', phases, { | 549 testPhases('register callback is included', phases, { |
568 'a|web/test.html': | 550 'a|web/test.html': |
569 '<!DOCTYPE html><html><body>' | 551 '<!DOCTYPE html><html><body>' |
570 '</polymer-element>' | 552 '</polymer-element>', |
571 '<script type="application/dart" src="a.dart"></script>', | 553 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
572 'a|web/test.html.scriptUrls': '[]', | |
573 'a|web/a.dart': | 554 'a|web/a.dart': |
574 'library a;\n' | 555 'library a;\n' |
575 'import "package:polymer/polymer.dart";\n' | 556 'import "package:polymer/polymer.dart";\n' |
576 '@CustomTag("x-foo")\n' | 557 '@CustomTag("x-foo")\n' |
577 'class XFoo extends PolymerElement {\n' | 558 'class XFoo extends PolymerElement {\n' |
578 ' static registerCallback() {};\n' | 559 ' static registerCallback() {};\n' |
579 ' static foo() {};\n' | 560 ' static foo() {};\n' |
580 '}\n' | 561 '}\n', |
581 'main(){}', | |
582 }, { | 562 }, { |
583 'a|web/test.html_bootstrap.dart': | 563 'a|web/test.html_bootstrap.dart': |
584 '''$MAIN_HEADER | 564 '''$MAIN_HEADER |
585 import 'a.dart' as i0; | 565 import 'a.dart' as i0; |
586 ${DEFAULT_IMPORTS.join('\n')} | 566 ${DEFAULT_IMPORTS.join('\n')} |
587 import 'a.dart' as smoke_0; | 567 import 'a.dart' as smoke_0; |
588 import 'package:polymer/polymer.dart' as smoke_1; | 568 import 'package:polymer/polymer.dart' as smoke_1; |
589 | 569 |
590 void main() { | 570 void main() { |
591 useGeneratedCode(new StaticConfiguration( | 571 useGeneratedCode(new StaticConfiguration( |
592 checkedMode: false, | 572 checkedMode: false, |
593 parents: { | 573 parents: { |
594 smoke_0.XFoo: smoke_1.PolymerElement, | 574 smoke_0.XFoo: smoke_1.PolymerElement, |
595 }, | 575 }, |
596 declarations: { | 576 declarations: { |
597 smoke_0.XFoo: { | 577 smoke_0.XFoo: { |
598 #registerCallback: const Declaration($rcDetails), | 578 #registerCallback: const Declaration($rcDetails), |
599 }, | 579 }, |
600 }, | 580 }, |
601 staticMethods: { | 581 staticMethods: { |
602 smoke_0.XFoo: { | 582 smoke_0.XFoo: { |
603 #registerCallback: smoke_0.XFoo.registerCallback, | 583 #registerCallback: smoke_0.XFoo.registerCallback, |
604 }, | 584 }, |
605 }, | 585 }, |
606 names: { | 586 names: { |
607 #registerCallback: r'registerCallback', | 587 #registerCallback: r'registerCallback', |
608 })); | 588 })); |
609 configureForDeployment([ | 589 startPolymer([ |
610 () => Polymer.register(\'x-foo\', i0.XFoo), | 590 () => Polymer.register(\'x-foo\', i0.XFoo), |
611 ]); | 591 ]); |
612 i0.main(); | |
613 } | 592 } |
614 '''.replaceAll('\n ', '\n'), | 593 '''.replaceAll('\n ', '\n'), |
615 }); | 594 }); |
616 } | 595 } |
OLD | NEW |