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; |
11 import 'package:unittest/compact_vm_config.dart'; | 11 import 'package:unittest/compact_vm_config.dart'; |
12 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
13 | 13 |
14 import 'common.dart'; | 14 import 'common.dart'; |
15 | 15 |
16 void main() { | 16 void main() { |
17 useCompactVMConfiguration(); | 17 useCompactVMConfiguration(); |
18 var phases = [[new ScriptCompactor(new TransformOptions(), | 18 var phases = [[new ScriptCompactor(new TransformOptions(), |
19 sdkDir: testingDartSdkDirectory)]]; | 19 sdkDir: testingDartSdkDirectory)]]; |
20 group('initializers', () => initializerTests(phases)); | 20 group('initializers', () => initializerTests(phases)); |
| 21 group('experimental', () => initializerTestsExperimental(phases)); |
21 group('codegen', () => codegenTests(phases)); | 22 group('codegen', () => codegenTests(phases)); |
22 } | 23 } |
23 | 24 |
24 initializerTests(phases) { | 25 initializerTests(phases) { |
25 testPhases('no changes', phases, { | 26 testPhases('no changes', phases, { |
26 'a|web/test.html': '<!DOCTYPE html><html></html>', | 27 'a|web/test.html': '<!DOCTYPE html><html></html>', |
27 'a|web/test.html.scriptUrls': '[]', | 28 'a|web/test.html._data': EMPTY_DATA, |
28 }, { | 29 }, { |
29 'a|web/test.html': '<!DOCTYPE html><html></html>', | 30 'a|web/test.html': '<!DOCTYPE html><html></html>', |
30 }); | 31 }); |
31 | 32 |
32 testPhases('no changes outside web/', phases, { | 33 testPhases('no changes outside web/', phases, { |
33 'a|lib/test.html': | 34 'a|lib/test.html': |
34 '<!DOCTYPE html><html><head>', | 35 '<!DOCTYPE html><html><head>', |
35 'a|lib/test.html.scriptUrls': '[["a","lib/a.dart"]]', | 36 'a|lib/test.html._data': expectedData(['lib/a.dart']), |
36 }, { | 37 }, { |
37 'a|lib/test.html': | 38 'a|lib/test.html': |
38 '<!DOCTYPE html><html><head>', | 39 '<!DOCTYPE html><html><head>', |
39 'a|lib/test.html.scriptUrls': '[["a","lib/a.dart"]]', | 40 'a|lib/test.html._data': expectedData(['lib/a.dart']), |
40 }); | 41 }); |
41 | 42 |
42 testPhases('single script', phases, { | 43 testPhases('single script', phases, { |
43 'a|web/test.html': | 44 'a|web/test.html': |
44 '<!DOCTYPE html><html><head>', | 45 '<!DOCTYPE html><html><head>', |
45 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 46 'a|web/test.html._data': expectedData(['web/a.dart']), |
46 'a|web/a.dart': | 47 'a|web/a.dart': |
47 'library a;\n' | 48 'library a;\n' |
48 'import "package:polymer/polymer.dart";\n' | 49 'import "package:polymer/polymer.dart";\n' |
| 50 'main(){}', |
| 51 }, { |
| 52 'a|web/test.html': |
| 53 '<!DOCTYPE html><html><head></head><body>' |
| 54 '<script type="application/dart" ' |
| 55 'src="test.html_bootstrap.dart"></script>' |
| 56 '</body></html>', |
| 57 |
| 58 'a|web/test.html_bootstrap.dart': |
| 59 '''$MAIN_HEADER |
| 60 import 'a.dart' as i0; |
| 61 ${DEFAULT_IMPORTS.join('\n')} |
| 62 |
| 63 void main() { |
| 64 useGeneratedCode(new StaticConfiguration( |
| 65 checkedMode: false)); |
| 66 configureForDeployment([]); |
| 67 i0.main(); |
| 68 } |
| 69 '''.replaceAll('\n ', '\n'), |
| 70 'a|web/a.dart': |
| 71 'library a;\n' |
| 72 'import "package:polymer/polymer.dart";\n' |
| 73 'main(){}', |
| 74 }); |
| 75 |
| 76 testPhases('simple initialization', phases, { |
| 77 'a|web/test.html': |
| 78 '<!DOCTYPE html><html><head>', |
| 79 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 80 'a|web/a.dart': |
| 81 'library a;\n' |
| 82 'import "package:polymer/polymer.dart";\n' |
| 83 '@CustomTag("x-foo")\n' |
| 84 'class XFoo extends PolymerElement {\n' |
| 85 '}\n' |
| 86 'main(){}', |
| 87 }, { |
| 88 'a|web/test.html_bootstrap.dart': |
| 89 '''$MAIN_HEADER |
| 90 import 'a.dart' as i0; |
| 91 ${DEFAULT_IMPORTS.join('\n')} |
| 92 import 'a.dart' as smoke_0; |
| 93 import 'package:polymer/polymer.dart' as smoke_1; |
| 94 |
| 95 void main() { |
| 96 useGeneratedCode(new StaticConfiguration( |
| 97 checkedMode: false, |
| 98 parents: { |
| 99 smoke_0.XFoo: smoke_1.PolymerElement, |
| 100 }, |
| 101 declarations: { |
| 102 smoke_0.XFoo: const {}, |
| 103 })); |
| 104 configureForDeployment([ |
| 105 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 106 ]); |
| 107 i0.main(); |
| 108 } |
| 109 '''.replaceAll('\n ', '\n'), |
| 110 }); |
| 111 |
| 112 testPhases('use const expressions', phases, { |
| 113 'a|web/test.html': |
| 114 '<!DOCTYPE html><html><head>', |
| 115 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 116 'a|web/b.dart': |
| 117 'library a;\n' |
| 118 'const x = "x";\n', |
| 119 'a|web/c.dart': |
| 120 'part of a;\n' |
| 121 'const dash = "-";\n', |
| 122 'a|web/a.dart': |
| 123 'library a;\n' |
| 124 'import "package:polymer/polymer.dart";\n' |
| 125 'import "b.dart";\n' |
| 126 'part "c.dart";\n' |
| 127 'const letterO = "o";\n' |
| 128 '@CustomTag("\$x\${dash}f\${letterO}o2")\n' |
| 129 'class XFoo extends PolymerElement {\n' |
| 130 '}\n', |
| 131 }, { |
| 132 'a|web/test.html_bootstrap.dart': |
| 133 '''$MAIN_HEADER |
| 134 import 'a.dart' as i0; |
| 135 ${DEFAULT_IMPORTS.join('\n')} |
| 136 import 'a.dart' as smoke_0; |
| 137 import 'package:polymer/polymer.dart' as smoke_1; |
| 138 |
| 139 void main() { |
| 140 useGeneratedCode(new StaticConfiguration( |
| 141 checkedMode: false, |
| 142 parents: { |
| 143 smoke_0.XFoo: smoke_1.PolymerElement, |
| 144 }, |
| 145 declarations: { |
| 146 smoke_0.XFoo: const {}, |
| 147 })); |
| 148 configureForDeployment([ |
| 149 () => Polymer.register(\'x-foo2\', i0.XFoo), |
| 150 ]); |
| 151 i0.main(); |
| 152 } |
| 153 '''.replaceAll('\n ', '\n'), |
| 154 }); |
| 155 |
| 156 testPhases('invalid const expression', phases, { |
| 157 'a|web/test.html': |
| 158 '<!DOCTYPE html><html><head>', |
| 159 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 160 'a|web/a.dart': |
| 161 'library a;\n' |
| 162 'import "package:polymer/polymer.dart";\n' |
| 163 '@CustomTag("\${x}-foo")\n' // invalid, x is not defined |
| 164 'class XFoo extends PolymerElement {\n' |
| 165 '}\n' |
| 166 'main(){}', |
| 167 }, { |
| 168 'a|web/test.html_bootstrap.dart': |
| 169 '''$MAIN_HEADER |
| 170 import 'a.dart' as i0; |
| 171 ${DEFAULT_IMPORTS.join('\n')} |
| 172 import 'a.dart' as smoke_0; |
| 173 import 'package:polymer/polymer.dart' as smoke_1; |
| 174 |
| 175 void main() { |
| 176 useGeneratedCode(new StaticConfiguration( |
| 177 checkedMode: false, |
| 178 parents: { |
| 179 smoke_0.XFoo: smoke_1.PolymerElement, |
| 180 }, |
| 181 declarations: { |
| 182 smoke_0.XFoo: const {}, |
| 183 })); |
| 184 configureForDeployment([]); |
| 185 i0.main(); |
| 186 } |
| 187 '''.replaceAll('\n ', '\n'), |
| 188 |
| 189 }, [ |
| 190 'warning: The parameter to @CustomTag seems to be invalid. ' |
| 191 '(web/a.dart 2 11)', |
| 192 ]); |
| 193 |
| 194 testPhases('no polymer import (no warning, but no crash either)', phases, { |
| 195 'a|web/test.html': |
| 196 '<!DOCTYPE html><html><head>', |
| 197 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 198 'a|web/a.dart': |
| 199 'library a;\n' |
| 200 'import "package:polymer/polymer.broken.import.dart";\n' |
| 201 '@CustomTag("x-foo")\n' |
| 202 'class XFoo extends PolymerElement {\n' |
| 203 '}\n' |
| 204 'main(){}', |
| 205 }, { |
| 206 'a|web/test.html_bootstrap.dart': |
| 207 '''$MAIN_HEADER |
| 208 import 'a.dart' as i0; |
| 209 ${DEFAULT_IMPORTS.join('\n')} |
| 210 |
| 211 void main() { |
| 212 useGeneratedCode(new StaticConfiguration( |
| 213 checkedMode: false)); |
| 214 configureForDeployment([]); |
| 215 i0.main(); |
| 216 } |
| 217 '''.replaceAll('\n ', '\n'), |
| 218 |
| 219 }, []); |
| 220 |
| 221 testPhases('several scripts', phases, { |
| 222 'a|web/test.html': |
| 223 '<!DOCTYPE html><html><head>' |
| 224 '</head><body><div></div>', |
| 225 'a|web/test.html._data': |
| 226 expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart', 'web/d.dart'])
, |
| 227 'a|web/d.dart': |
| 228 'library d;\n' |
| 229 'import "package:polymer/polymer.dart";\n' |
| 230 'main(){}\n@initMethod mD(){}', |
| 231 |
| 232 'a|web/a.dart': |
| 233 'import "package:polymer/polymer.dart";\n' |
| 234 '@initMethod mA(){}\n', |
| 235 |
| 236 'a|web/b.dart': |
| 237 'import "package:polymer/polymer.dart";\n' |
| 238 'export "e.dart";\n' |
| 239 'export "f.dart" show XF1, mF1;\n' |
| 240 'export "g.dart" hide XG1, mG1;\n' |
| 241 'export "h.dart" show XH1, mH1 hide mH1, mH2;\n' |
| 242 '@initMethod mB(){}\n', |
| 243 |
| 244 'a|web/c.dart': |
| 245 'import "package:polymer/polymer.dart";\n' |
| 246 'part "c_part.dart";\n' |
| 247 '@CustomTag("x-c1") class XC1 extends PolymerElement {}\n', |
| 248 |
| 249 'a|web/c_part.dart': |
| 250 '@CustomTag("x-c2") class XC2 extends PolymerElement {}\n', |
| 251 |
| 252 'a|web/e.dart': |
| 253 'import "package:polymer/polymer.dart";\n' |
| 254 '@CustomTag("x-e") class XE extends PolymerElement {}\n' |
| 255 '@initMethod mE(){}\n', |
| 256 |
| 257 'a|web/f.dart': |
| 258 'import "package:polymer/polymer.dart";\n' |
| 259 '@CustomTag("x-f1") class XF1 extends PolymerElement {}\n' |
| 260 '@initMethod mF1(){}\n' |
| 261 '@CustomTag("x-f2") class XF2 extends PolymerElement {}\n' |
| 262 '@initMethod mF2(){}\n', |
| 263 |
| 264 'a|web/g.dart': |
| 265 'import "package:polymer/polymer.dart";\n' |
| 266 '@CustomTag("x-g1") class XG1 extends PolymerElement {}\n' |
| 267 '@initMethod mG1(){}\n' |
| 268 '@CustomTag("x-g2") class XG2 extends PolymerElement {}\n' |
| 269 '@initMethod mG2(){}\n', |
| 270 |
| 271 'a|web/h.dart': |
| 272 'import "package:polymer/polymer.dart";\n' |
| 273 '@CustomTag("x-h1") class XH1 extends PolymerElement {}\n' |
| 274 '@initMethod mH1(){}\n' |
| 275 '@CustomTag("x-h2") class XH2 extends PolymerElement {}\n' |
| 276 '@initMethod mH2(){}\n', |
| 277 }, { |
| 278 'a|web/test.html': |
| 279 '<!DOCTYPE html><html><head></head><body><div></div>' |
| 280 '<script type="application/dart" src="test.html_bootstrap.dart">' |
| 281 '</script>' |
| 282 '</body></html>', |
| 283 |
| 284 'a|web/test.html_bootstrap.dart': |
| 285 '''$MAIN_HEADER |
| 286 import 'a.dart' as i0; |
| 287 import 'b.dart' as i1; |
| 288 import 'c.dart' as i2; |
| 289 import 'd.dart' as i3; |
| 290 ${DEFAULT_IMPORTS.join('\n')} |
| 291 import 'e.dart' as smoke_0; |
| 292 import 'package:polymer/polymer.dart' as smoke_1; |
| 293 import 'f.dart' as smoke_2; |
| 294 import 'g.dart' as smoke_3; |
| 295 import 'h.dart' as smoke_4; |
| 296 import 'c.dart' as smoke_5; |
| 297 |
| 298 void main() { |
| 299 useGeneratedCode(new StaticConfiguration( |
| 300 checkedMode: false, |
| 301 parents: { |
| 302 smoke_5.XC1: smoke_1.PolymerElement, |
| 303 smoke_5.XC2: smoke_1.PolymerElement, |
| 304 smoke_0.XE: smoke_1.PolymerElement, |
| 305 smoke_2.XF1: smoke_1.PolymerElement, |
| 306 smoke_3.XG2: smoke_1.PolymerElement, |
| 307 smoke_4.XH1: smoke_1.PolymerElement, |
| 308 }, |
| 309 declarations: { |
| 310 smoke_5.XC1: const {}, |
| 311 smoke_5.XC2: const {}, |
| 312 smoke_0.XE: const {}, |
| 313 smoke_2.XF1: const {}, |
| 314 smoke_3.XG2: const {}, |
| 315 smoke_4.XH1: const {}, |
| 316 })); |
| 317 configureForDeployment([ |
| 318 i0.mA, |
| 319 i1.mB, |
| 320 i1.mE, |
| 321 i1.mF1, |
| 322 i1.mG2, |
| 323 () => Polymer.register('x-e', i1.XE), |
| 324 () => Polymer.register('x-f1', i1.XF1), |
| 325 () => Polymer.register('x-g2', i1.XG2), |
| 326 () => Polymer.register('x-h1', i1.XH1), |
| 327 () => Polymer.register('x-c1', i2.XC1), |
| 328 () => Polymer.register('x-c2', i2.XC2), |
| 329 i3.mD, |
| 330 ]); |
| 331 i3.main(); |
| 332 } |
| 333 '''.replaceAll('\n ', '\n'), |
| 334 }, null); |
| 335 } |
| 336 |
| 337 initializerTestsExperimental(phases) { |
| 338 testPhases('no changes', phases, { |
| 339 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 340 'a|web/test.html._data': EMPTY_DATA, |
| 341 }, { |
| 342 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 343 }); |
| 344 |
| 345 testPhases('no changes outside web/', phases, { |
| 346 'a|lib/test.html': |
| 347 '<!DOCTYPE html><html><head>', |
| 348 'a|lib/test.html._data': expectedData(['lib/a.dart'], experimental: true), |
| 349 }, { |
| 350 'a|lib/test.html': |
| 351 '<!DOCTYPE html><html><head>', |
| 352 'a|lib/test.html._data': expectedData(['lib/a.dart'], experimental: true), |
| 353 }); |
| 354 |
| 355 testPhases('single script', phases, { |
| 356 'a|web/test.html': |
| 357 '<!DOCTYPE html><html><head>', |
| 358 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true), |
| 359 'a|web/a.dart': |
| 360 'library a;\n' |
| 361 'import "package:polymer/polymer.dart";\n' |
49 '@initMethod main(){}', | 362 '@initMethod main(){}', |
50 }, { | 363 }, { |
51 'a|web/test.html': | 364 'a|web/test.html': |
52 '<!DOCTYPE html><html><head></head><body>' | 365 '<!DOCTYPE html><html><head></head><body>' |
53 '<script type="application/dart" ' | 366 '<script type="application/dart" ' |
54 'src="test.html_bootstrap.dart"></script>' | 367 'src="test.html_bootstrap.dart"></script>' |
55 '</body></html>', | 368 '</body></html>', |
56 | 369 |
57 'a|web/test.html_bootstrap.dart': | 370 'a|web/test.html_bootstrap.dart': |
58 '''$MAIN_HEADER | 371 '''$MAIN_HEADER |
(...skipping 10 matching lines...) Expand all Loading... |
69 '''.replaceAll('\n ', '\n'), | 382 '''.replaceAll('\n ', '\n'), |
70 'a|web/a.dart': | 383 'a|web/a.dart': |
71 'library a;\n' | 384 'library a;\n' |
72 'import "package:polymer/polymer.dart";\n' | 385 'import "package:polymer/polymer.dart";\n' |
73 '@initMethod main(){}', | 386 '@initMethod main(){}', |
74 }); | 387 }); |
75 | 388 |
76 testPhases('simple initialization', phases, { | 389 testPhases('simple initialization', phases, { |
77 'a|web/test.html': | 390 'a|web/test.html': |
78 '<!DOCTYPE html><html><head>', | 391 '<!DOCTYPE html><html><head>', |
79 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 392 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true), |
80 'a|web/a.dart': | 393 'a|web/a.dart': |
81 'library a;\n' | 394 'library a;\n' |
82 'import "package:polymer/polymer.dart";\n' | 395 'import "package:polymer/polymer.dart";\n' |
83 '@CustomTag("x-foo")\n' | 396 '@CustomTag("x-foo")\n' |
84 'class XFoo extends PolymerElement {\n' | 397 'class XFoo extends PolymerElement {\n' |
85 '}\n' | 398 '}\n' |
86 '@initMethod main(){}', | 399 '@initMethod main(){}', |
87 }, { | 400 }, { |
88 'a|web/test.html_bootstrap.dart': | 401 'a|web/test.html_bootstrap.dart': |
89 '''$MAIN_HEADER | 402 '''$MAIN_HEADER |
(...skipping 15 matching lines...) Expand all Loading... |
105 i0.main, | 418 i0.main, |
106 () => Polymer.register(\'x-foo\', i0.XFoo), | 419 () => Polymer.register(\'x-foo\', i0.XFoo), |
107 ]); | 420 ]); |
108 } | 421 } |
109 '''.replaceAll('\n ', '\n'), | 422 '''.replaceAll('\n ', '\n'), |
110 }); | 423 }); |
111 | 424 |
112 testPhases('use const expressions', phases, { | 425 testPhases('use const expressions', phases, { |
113 'a|web/test.html': | 426 'a|web/test.html': |
114 '<!DOCTYPE html><html><head>', | 427 '<!DOCTYPE html><html><head>', |
115 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 428 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true), |
116 'a|web/b.dart': | 429 'a|web/b.dart': |
117 'library a;\n' | 430 'library a;\n' |
118 'const x = "x";\n', | 431 'const x = "x";\n', |
119 'a|web/c.dart': | 432 'a|web/c.dart': |
120 'part of a;\n' | 433 'part of a;\n' |
121 'const dash = "-";\n', | 434 'const dash = "-";\n', |
122 'a|web/a.dart': | 435 'a|web/a.dart': |
123 'library a;\n' | 436 'library a;\n' |
124 'import "package:polymer/polymer.dart";\n' | 437 'import "package:polymer/polymer.dart";\n' |
125 'import "b.dart";\n' | 438 'import "b.dart";\n' |
(...skipping 22 matching lines...) Expand all Loading... |
148 startPolymer([ | 461 startPolymer([ |
149 () => Polymer.register(\'x-foo2\', i0.XFoo), | 462 () => Polymer.register(\'x-foo2\', i0.XFoo), |
150 ]); | 463 ]); |
151 } | 464 } |
152 '''.replaceAll('\n ', '\n'), | 465 '''.replaceAll('\n ', '\n'), |
153 }); | 466 }); |
154 | 467 |
155 testPhases('invalid const expression', phases, { | 468 testPhases('invalid const expression', phases, { |
156 'a|web/test.html': | 469 'a|web/test.html': |
157 '<!DOCTYPE html><html><head>', | 470 '<!DOCTYPE html><html><head>', |
158 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 471 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true), |
159 'a|web/a.dart': | 472 'a|web/a.dart': |
160 'library a;\n' | 473 'library a;\n' |
161 'import "package:polymer/polymer.dart";\n' | 474 'import "package:polymer/polymer.dart";\n' |
162 '@CustomTag("\${x}-foo")\n' // invalid, x is not defined | 475 '@CustomTag("\${x}-foo")\n' // invalid, x is not defined |
163 'class XFoo extends PolymerElement {\n' | 476 'class XFoo extends PolymerElement {\n' |
164 '}\n' | 477 '}\n' |
165 'main(){}', | 478 'main(){}', |
166 }, { | 479 }, { |
167 'a|web/test.html_bootstrap.dart': | 480 'a|web/test.html_bootstrap.dart': |
168 '''$MAIN_HEADER | 481 '''$MAIN_HEADER |
(...skipping 17 matching lines...) Expand all Loading... |
186 | 499 |
187 }, [ | 500 }, [ |
188 'warning: The parameter to @CustomTag seems to be invalid. ' | 501 'warning: The parameter to @CustomTag seems to be invalid. ' |
189 '(web/a.dart 2 11)', | 502 '(web/a.dart 2 11)', |
190 'warning: $NO_INITIALIZERS_ERROR', | 503 'warning: $NO_INITIALIZERS_ERROR', |
191 ]); | 504 ]); |
192 | 505 |
193 testPhases('no polymer import (no warning, but no crash either)', phases, { | 506 testPhases('no polymer import (no warning, but no crash either)', phases, { |
194 'a|web/test.html': | 507 'a|web/test.html': |
195 '<!DOCTYPE html><html><head>', | 508 '<!DOCTYPE html><html><head>', |
196 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 509 'a|web/test.html._data': expectedData(['web/a.dart'], experimental: true), |
197 'a|web/a.dart': | 510 'a|web/a.dart': |
198 'library a;\n' | 511 'library a;\n' |
199 'import "package:polymer/polymer.broken.import.dart";\n' | 512 'import "package:polymer/polymer.broken.import.dart";\n' |
200 '@CustomTag("x-foo")\n' | 513 '@CustomTag("x-foo")\n' |
201 'class XFoo extends PolymerElement {\n' | 514 'class XFoo extends PolymerElement {\n' |
202 '}\n' | 515 '}\n' |
203 'main(){}', | 516 'main(){}', |
204 }, { | 517 }, { |
205 'a|web/test.html_bootstrap.dart': | 518 'a|web/test.html_bootstrap.dart': |
206 '''$MAIN_HEADER | 519 '''$MAIN_HEADER |
207 import 'a.dart' as i0; | 520 import 'a.dart' as i0; |
208 ${DEFAULT_IMPORTS.join('\n')} | 521 ${DEFAULT_IMPORTS.join('\n')} |
209 | 522 |
210 void main() { | 523 void main() { |
211 useGeneratedCode(new StaticConfiguration( | 524 useGeneratedCode(new StaticConfiguration( |
212 checkedMode: false)); | 525 checkedMode: false)); |
213 startPolymer([]); | 526 startPolymer([]); |
214 } | 527 } |
215 '''.replaceAll('\n ', '\n'), | 528 '''.replaceAll('\n ', '\n'), |
216 | 529 |
217 }, [ | 530 }, [ |
218 'warning: $NO_INITIALIZERS_ERROR', | 531 'warning: $NO_INITIALIZERS_ERROR', |
219 ]); | 532 ]); |
220 | 533 |
221 testPhases('several scripts', phases, { | 534 testPhases('several scripts', phases, { |
222 'a|web/test.html': | 535 'a|web/test.html': |
223 '<!DOCTYPE html><html><head>' | 536 '<!DOCTYPE html><html><head>' |
224 '</head><body><div></div>', | 537 '</head><body><div></div>', |
225 'a|web/test.html.scriptUrls': | 538 'a|web/test.html._data': |
226 '[["a", "web/a.dart"],["a", "web/b.dart"],["a", "web/c.dart"],' | 539 expectedData(['web/a.dart', 'web/b.dart', 'web/c.dart', 'web/d.dart'],
experimental: true), |
227 '["a", "web/d.dart"]]', | |
228 'a|web/d.dart': | 540 'a|web/d.dart': |
229 'library d;\n' | 541 'library d;\n' |
230 'import "package:polymer/polymer.dart";\n' | 542 'import "package:polymer/polymer.dart";\n' |
231 '@initMethod main(){}\n@initMethod mD(){}', | 543 '@initMethod main(){}\n@initMethod mD(){}', |
232 | 544 |
233 'a|web/a.dart': | 545 'a|web/a.dart': |
234 'import "package:polymer/polymer.dart";\n' | 546 'import "package:polymer/polymer.dart";\n' |
235 '@initMethod mA(){}\n', | 547 '@initMethod mA(){}\n', |
236 | 548 |
237 'a|web/b.dart': | 549 'a|web/b.dart': |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 '<div class="{{an.attribute}}"></div>' | 659 '<div class="{{an.attribute}}"></div>' |
348 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' | 660 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' |
349 '<div data-attribute="{{anotherAttribute}}"></div>' | 661 '<div data-attribute="{{anotherAttribute}}"></div>' |
350 // input and custom-element attributes are treated as 2-way bindings: | 662 // input and custom-element attributes are treated as 2-way bindings: |
351 '<input value="{{this.is.twoWay}}">' | 663 '<input value="{{this.is.twoWay}}">' |
352 '<input value="{{this.is.twoWayInt | intToStringTransformer}}">' | 664 '<input value="{{this.is.twoWayInt | intToStringTransformer}}">' |
353 '<something-else my-attribute="{{here.too}}"></something-else>' | 665 '<something-else my-attribute="{{here.too}}"></something-else>' |
354 '<div on-click="{{methodName}}"></div>' | 666 '<div on-click="{{methodName}}"></div>' |
355 '<div on-click="{{@read.method}}"></div>' | 667 '<div on-click="{{@read.method}}"></div>' |
356 '</template></polymer-element>', | 668 '</template></polymer-element>', |
357 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 669 'a|web/test.html._data': expectedData(['web/a.dart']), |
358 'a|web/a.dart': | 670 'a|web/a.dart': |
359 'library a;\n' | 671 'library a;\n' |
360 'import "package:polymer/polymer.dart";\n' | 672 'import "package:polymer/polymer.dart";\n' |
361 '@initMethod main(){}', | 673 'main(){}', |
362 }, { | 674 }, { |
363 'a|web/test.html_bootstrap.dart': | 675 'a|web/test.html_bootstrap.dart': |
364 '''$MAIN_HEADER | 676 '''$MAIN_HEADER |
365 import 'a.dart' as i0; | 677 import 'a.dart' as i0; |
366 ${DEFAULT_IMPORTS.join('\n')} | 678 ${DEFAULT_IMPORTS.join('\n')} |
367 | 679 |
368 void main() { | 680 void main() { |
369 useGeneratedCode(new StaticConfiguration( | 681 useGeneratedCode(new StaticConfiguration( |
370 checkedMode: false, | 682 checkedMode: false, |
371 getters: { | 683 getters: { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 #is: r'is', | 718 #is: r'is', |
407 #method: r'method', | 719 #method: r'method', |
408 #methodName: r'methodName', | 720 #methodName: r'methodName', |
409 #node: r'node', | 721 #node: r'node', |
410 #read: r'read', | 722 #read: r'read', |
411 #too: r'too', | 723 #too: r'too', |
412 #twoWay: r'twoWay', | 724 #twoWay: r'twoWay', |
413 #twoWayInt: r'twoWayInt', | 725 #twoWayInt: r'twoWayInt', |
414 #within: r'within', | 726 #within: r'within', |
415 })); | 727 })); |
416 startPolymer([ | 728 configureForDeployment([]); |
417 i0.main, | 729 i0.main(); |
418 ]); | |
419 } | 730 } |
420 '''.replaceAll('\n ', '\n'), | 731 '''.replaceAll('\n ', '\n'), |
421 'a|web/a.dart': | 732 'a|web/a.dart': |
422 'library a;\n' | 733 'library a;\n' |
423 'import "package:polymer/polymer.dart";\n' | 734 'import "package:polymer/polymer.dart";\n' |
424 '@initMethod main(){}', | 735 'main(){}', |
425 }); | 736 }); |
426 | 737 |
427 final field1Details = "annotations: const [smoke_1.published]"; | 738 final field1Details = "annotations: const [smoke_1.published]"; |
428 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; | 739 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; |
429 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; | 740 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; |
430 final prop3Details = | 741 final prop3Details = |
431 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; | 742 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; |
432 testPhases('published via annotation', phases, { | 743 testPhases('published via annotation', phases, { |
433 'a|web/test.html': | 744 'a|web/test.html': |
434 '<!DOCTYPE html><html><body>', | 745 '<!DOCTYPE html><html><body>', |
435 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 746 'a|web/test.html._data': expectedData(['web/a.dart']), |
436 'a|web/a.dart': | 747 'a|web/a.dart': |
437 'library a;\n' | 748 'library a;\n' |
438 'import "package:polymer/polymer.dart";\n' | 749 'import "package:polymer/polymer.dart";\n' |
439 '@CustomTag("x-foo")\n' | 750 '@CustomTag("x-foo")\n' |
440 'class XFoo extends PolymerElement {\n' | 751 'class XFoo extends PolymerElement {\n' |
441 ' @published int field1;\n' | 752 ' @published int field1;\n' |
442 ' int field2;\n' | 753 ' int field2;\n' |
443 ' @published final int field3;\n' | 754 ' @published final int field3;\n' |
444 ' final int field4;\n' | 755 ' final int field4;\n' |
445 ' @published int get prop1 => 1;\n' | 756 ' @published int get prop1 => 1;\n' |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 #prop1: const Declaration(#prop1, int, $prop1Details), | 793 #prop1: const Declaration(#prop1, int, $prop1Details), |
483 #prop3: const Declaration(#prop3, int, $prop3Details), | 794 #prop3: const Declaration(#prop3, int, $prop3Details), |
484 }, | 795 }, |
485 }, | 796 }, |
486 names: { | 797 names: { |
487 #field1: r'field1', | 798 #field1: r'field1', |
488 #field3: r'field3', | 799 #field3: r'field3', |
489 #prop1: r'prop1', | 800 #prop1: r'prop1', |
490 #prop3: r'prop3', | 801 #prop3: r'prop3', |
491 })); | 802 })); |
492 startPolymer([ | 803 configureForDeployment([ |
493 () => Polymer.register(\'x-foo\', i0.XFoo), | 804 () => Polymer.register(\'x-foo\', i0.XFoo), |
494 ]); | 805 ]); |
| 806 i0.main(); |
495 } | 807 } |
496 '''.replaceAll('\n ', '\n'), | 808 '''.replaceAll('\n ', '\n'), |
497 }); | 809 }); |
498 | 810 |
499 testPhases('published via attributes', phases, { | 811 testPhases('published via attributes', phases, { |
500 'a|web/test.html': | 812 'a|web/test.html': |
501 '<!DOCTYPE html><html><body>' | 813 '<!DOCTYPE html><html><body>' |
502 '<polymer-element name="x-foo" attributes="field1,prop2">' | 814 '<polymer-element name="x-foo" attributes="field1,prop2">' |
503 '</polymer-element>', | 815 '</polymer-element>', |
504 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 816 'a|web/test.html._data': expectedData(['web/a.dart']), |
505 'a|web/a.dart': | 817 'a|web/a.dart': |
506 'library a;\n' | 818 'library a;\n' |
507 'import "package:polymer/polymer.dart";\n' | 819 'import "package:polymer/polymer.dart";\n' |
508 '@CustomTag("x-foo")\n' | 820 '@CustomTag("x-foo")\n' |
509 'class XFoo extends PolymerElement {\n' | 821 'class XFoo extends PolymerElement {\n' |
510 ' int field1;\n' | 822 ' int field1;\n' |
511 ' int field2;\n' | 823 ' int field2;\n' |
512 ' int get prop1 => 1;\n' | 824 ' int get prop1 => 1;\n' |
513 ' set prop1(int x) {};\n' | 825 ' set prop1(int x) {};\n' |
514 ' int get prop2 => 2;\n' | 826 ' int get prop2 => 2;\n' |
(...skipping 24 matching lines...) Expand all Loading... |
539 declarations: { | 851 declarations: { |
540 smoke_0.XFoo: { | 852 smoke_0.XFoo: { |
541 #field1: const Declaration(#field1, int), | 853 #field1: const Declaration(#field1, int), |
542 #prop2: const Declaration(#prop2, int, kind: PROPERTY), | 854 #prop2: const Declaration(#prop2, int, kind: PROPERTY), |
543 }, | 855 }, |
544 }, | 856 }, |
545 names: { | 857 names: { |
546 #field1: r'field1', | 858 #field1: r'field1', |
547 #prop2: r'prop2', | 859 #prop2: r'prop2', |
548 })); | 860 })); |
549 startPolymer([ | 861 configureForDeployment([ |
550 () => Polymer.register(\'x-foo\', i0.XFoo), | 862 () => Polymer.register(\'x-foo\', i0.XFoo), |
551 ]); | 863 ]); |
| 864 i0.main(); |
552 } | 865 } |
553 '''.replaceAll('\n ', '\n'), | 866 '''.replaceAll('\n ', '\n'), |
554 }); | 867 }); |
555 | 868 |
556 final fooDetails = | 869 final fooDetails = |
557 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; | 870 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; |
558 final xChangedDetails = "Function, kind: METHOD"; | 871 final xChangedDetails = "Function, kind: METHOD"; |
559 testPhases('ObserveProperty and *Changed methods', phases, { | 872 testPhases('ObserveProperty and *Changed methods', phases, { |
560 'a|web/test.html': | 873 'a|web/test.html': |
561 '<!DOCTYPE html><html><body>' | 874 '<!DOCTYPE html><html><body>' |
562 '</polymer-element>', | 875 '</polymer-element>', |
563 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 876 'a|web/test.html._data': expectedData(['web/a.dart']), |
564 'a|web/a.dart': | 877 'a|web/a.dart': |
565 'library a;\n' | 878 'library a;\n' |
566 'import "package:polymer/polymer.dart";\n' | 879 'import "package:polymer/polymer.dart";\n' |
567 '@CustomTag("x-foo")\n' | 880 '@CustomTag("x-foo")\n' |
568 'class XFoo extends PolymerElement {\n' | 881 'class XFoo extends PolymerElement {\n' |
569 ' int x;\n' | 882 ' int x;\n' |
570 ' void xChanged() {}\n' | 883 ' void xChanged() {}\n' |
571 ' void attributeChanged() {}\n' // should be excluded | 884 ' void attributeChanged() {}\n' // should be excluded |
572 ' @ObserveProperty("x")' | 885 ' @ObserveProperty("x")' |
573 ' void foo() {}\n' | 886 ' void foo() {}\n' |
(...skipping 19 matching lines...) Expand all Loading... |
593 declarations: { | 906 declarations: { |
594 smoke_0.XFoo: { | 907 smoke_0.XFoo: { |
595 #foo: const Declaration(#foo, Function, $fooDetails), | 908 #foo: const Declaration(#foo, Function, $fooDetails), |
596 #xChanged: const Declaration(#xChanged, $xChangedDetails), | 909 #xChanged: const Declaration(#xChanged, $xChangedDetails), |
597 }, | 910 }, |
598 }, | 911 }, |
599 names: { | 912 names: { |
600 #foo: r'foo', | 913 #foo: r'foo', |
601 #xChanged: r'xChanged', | 914 #xChanged: r'xChanged', |
602 })); | 915 })); |
603 startPolymer([ | 916 configureForDeployment([ |
604 () => Polymer.register(\'x-foo\', i0.XFoo), | 917 () => Polymer.register(\'x-foo\', i0.XFoo), |
605 ]); | 918 ]); |
| 919 i0.main(); |
606 } | 920 } |
607 '''.replaceAll('\n ', '\n'), | 921 '''.replaceAll('\n ', '\n'), |
608 }); | 922 }); |
609 | 923 |
610 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; | 924 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; |
611 testPhases('register callback is included', phases, { | 925 testPhases('register callback is included', phases, { |
612 'a|web/test.html': | 926 'a|web/test.html': |
613 '<!DOCTYPE html><html><body>' | 927 '<!DOCTYPE html><html><body>' |
614 '</polymer-element>', | 928 '</polymer-element>', |
615 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', | 929 'a|web/test.html._data': expectedData(['web/a.dart']), |
616 'a|web/a.dart': | 930 'a|web/a.dart': |
617 'library a;\n' | 931 'library a;\n' |
618 'import "package:polymer/polymer.dart";\n' | 932 'import "package:polymer/polymer.dart";\n' |
619 '@CustomTag("x-foo")\n' | 933 '@CustomTag("x-foo")\n' |
620 'class XFoo extends PolymerElement {\n' | 934 'class XFoo extends PolymerElement {\n' |
621 ' static registerCallback() {};\n' | 935 ' static registerCallback() {};\n' |
622 ' static foo() {};\n' | 936 ' static foo() {};\n' |
623 '}\n', | 937 '}\n', |
624 }, { | 938 }, { |
625 'a|web/test.html_bootstrap.dart': | 939 'a|web/test.html_bootstrap.dart': |
(...skipping 15 matching lines...) Expand all Loading... |
641 }, | 955 }, |
642 }, | 956 }, |
643 staticMethods: { | 957 staticMethods: { |
644 smoke_0.XFoo: { | 958 smoke_0.XFoo: { |
645 #registerCallback: smoke_0.XFoo.registerCallback, | 959 #registerCallback: smoke_0.XFoo.registerCallback, |
646 }, | 960 }, |
647 }, | 961 }, |
648 names: { | 962 names: { |
649 #registerCallback: r'registerCallback', | 963 #registerCallback: r'registerCallback', |
650 })); | 964 })); |
651 startPolymer([ | 965 configureForDeployment([ |
652 () => Polymer.register(\'x-foo\', i0.XFoo), | 966 () => Polymer.register(\'x-foo\', i0.XFoo), |
653 ]); | 967 ]); |
| 968 i0.main(); |
654 } | 969 } |
655 '''.replaceAll('\n ', '\n'), | 970 '''.replaceAll('\n ', '\n'), |
656 }); | 971 }); |
657 } | 972 } |
| 973 |
OLD | NEW |