| 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 '<input value="{{this.is.twoWayInt | intToStringTransformer}}">' | 300 '<input value="{{this.is.twoWayInt | intToStringTransformer}}">' |
| 309 '<something-else my-attribute="{{here.too}}"></something-else>' | 301 '<something-else my-attribute="{{here.too}}"></something-else>' |
| 310 '<div on-click="{{methodName}}"></div>' | 302 '<div on-click="{{methodName}}"></div>' |
| 311 '<div on-click="{{@read.method}}"></div>' | 303 '<div on-click="{{@read.method}}"></div>' |
| 312 '</template></polymer-element>' | 304 '</template></polymer-element>', |
| 313 '<script type="application/dart" src="a.dart"></script>', | 305 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
| 314 'a|web/test.html.scriptUrls': '[]', | |
| 315 'a|web/a.dart': | 306 'a|web/a.dart': |
| 316 'library a;\n' | 307 'library a;\n' |
| 317 'import "package:polymer/polymer.dart";\n' | 308 'import "package:polymer/polymer.dart";\n' |
| 318 'main(){}', | 309 '@initMethod main(){}', |
| 319 }, { | 310 }, { |
| 320 'a|web/test.html_bootstrap.dart': | 311 'a|web/test.html_bootstrap.dart': |
| 321 '''$MAIN_HEADER | 312 '''$MAIN_HEADER |
| 322 import 'a.dart' as i0; | 313 import 'a.dart' as i0; |
| 323 ${DEFAULT_IMPORTS.join('\n')} | 314 ${DEFAULT_IMPORTS.join('\n')} |
| 324 | 315 |
| 325 void main() { | 316 void main() { |
| 326 useGeneratedCode(new StaticConfiguration( | 317 useGeneratedCode(new StaticConfiguration( |
| 327 checkedMode: false, | 318 checkedMode: false, |
| 328 getters: { | 319 getters: { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 359 #is: r'is', | 350 #is: r'is', |
| 360 #method: r'method', | 351 #method: r'method', |
| 361 #methodName: r'methodName', | 352 #methodName: r'methodName', |
| 362 #node: r'node', | 353 #node: r'node', |
| 363 #read: r'read', | 354 #read: r'read', |
| 364 #too: r'too', | 355 #too: r'too', |
| 365 #twoWay: r'twoWay', | 356 #twoWay: r'twoWay', |
| 366 #twoWayInt: r'twoWayInt', | 357 #twoWayInt: r'twoWayInt', |
| 367 #within: r'within', | 358 #within: r'within', |
| 368 })); | 359 })); |
| 369 configureForDeployment([ | 360 startPolymer([ |
| 361 i0.main, |
| 370 ]); | 362 ]); |
| 371 i0.main(); | |
| 372 } | 363 } |
| 373 '''.replaceAll('\n ', '\n'), | 364 '''.replaceAll('\n ', '\n'), |
| 374 'a|web/a.dart': | 365 'a|web/a.dart': |
| 375 'library a;\n' | 366 'library a;\n' |
| 376 'import "package:polymer/polymer.dart";\n' | 367 'import "package:polymer/polymer.dart";\n' |
| 377 'main(){}', | 368 '@initMethod main(){}', |
| 378 }); | 369 }); |
| 379 | 370 |
| 380 final field1Details = "annotations: const [smoke_1.published]"; | 371 final field1Details = "annotations: const [smoke_1.published]"; |
| 381 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; | 372 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; |
| 382 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; | 373 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; |
| 383 final prop3Details = | 374 final prop3Details = |
| 384 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; | 375 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; |
| 385 testPhases('published via annotation', phases, { | 376 testPhases('published via annotation', phases, { |
| 386 'a|web/test.html': | 377 'a|web/test.html': |
| 387 '<!DOCTYPE html><html><body>' | 378 '<!DOCTYPE html><html><body>', |
| 388 '<script type="application/dart" src="a.dart"></script>', | 379 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
| 389 'a|web/test.html.scriptUrls': '[]', | |
| 390 'a|web/a.dart': | 380 'a|web/a.dart': |
| 391 'library a;\n' | 381 'library a;\n' |
| 392 'import "package:polymer/polymer.dart";\n' | 382 'import "package:polymer/polymer.dart";\n' |
| 393 '@CustomTag("x-foo")\n' | 383 '@CustomTag("x-foo")\n' |
| 394 'class XFoo extends PolymerElement {\n' | 384 'class XFoo extends PolymerElement {\n' |
| 395 ' @published int field1;\n' | 385 ' @published int field1;\n' |
| 396 ' int field2;\n' | 386 ' int field2;\n' |
| 397 ' @published final int field3;\n' | 387 ' @published final int field3;\n' |
| 398 ' final int field4;\n' | 388 ' final int field4;\n' |
| 399 ' @published int get prop1 => 1;\n' | 389 ' @published int get prop1 => 1;\n' |
| 400 ' set prop1(int x) {};\n' | 390 ' set prop1(int x) {};\n' |
| 401 ' int get prop2 => 2;\n' | 391 ' int get prop2 => 2;\n' |
| 402 ' set prop2(int x) {};\n' | 392 ' set prop2(int x) {};\n' |
| 403 ' @published int get prop3 => 3;\n' | 393 ' @published int get prop3 => 3;\n' |
| 404 ' int get prop4 => 4;\n' | 394 ' int get prop4 => 4;\n' |
| 405 ' @published int method1() => 1;\n' | 395 ' @published int method1() => 1;\n' |
| 406 ' int method2() => 2;\n' | 396 ' int method2() => 2;\n' |
| 407 '}\n' | 397 '}\n', |
| 408 'main(){}', | |
| 409 }, { | 398 }, { |
| 410 'a|web/test.html_bootstrap.dart': | 399 'a|web/test.html_bootstrap.dart': |
| 411 '''$MAIN_HEADER | 400 '''$MAIN_HEADER |
| 412 import 'a.dart' as i0; | 401 import 'a.dart' as i0; |
| 413 ${DEFAULT_IMPORTS.join('\n')} | 402 ${DEFAULT_IMPORTS.join('\n')} |
| 414 import 'a.dart' as smoke_0; | 403 import 'a.dart' as smoke_0; |
| 415 import 'package:polymer/polymer.dart' as smoke_1; | 404 import 'package:polymer/polymer.dart' as smoke_1; |
| 416 | 405 |
| 417 void main() { | 406 void main() { |
| 418 useGeneratedCode(new StaticConfiguration( | 407 useGeneratedCode(new StaticConfiguration( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 437 #prop1: const Declaration(#prop1, int, $prop1Details), | 426 #prop1: const Declaration(#prop1, int, $prop1Details), |
| 438 #prop3: const Declaration(#prop3, int, $prop3Details), | 427 #prop3: const Declaration(#prop3, int, $prop3Details), |
| 439 }, | 428 }, |
| 440 }, | 429 }, |
| 441 names: { | 430 names: { |
| 442 #field1: r'field1', | 431 #field1: r'field1', |
| 443 #field3: r'field3', | 432 #field3: r'field3', |
| 444 #prop1: r'prop1', | 433 #prop1: r'prop1', |
| 445 #prop3: r'prop3', | 434 #prop3: r'prop3', |
| 446 })); | 435 })); |
| 447 configureForDeployment([ | 436 startPolymer([ |
| 448 () => Polymer.register(\'x-foo\', i0.XFoo), | 437 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 449 ]); | 438 ]); |
| 450 i0.main(); | |
| 451 } | 439 } |
| 452 '''.replaceAll('\n ', '\n'), | 440 '''.replaceAll('\n ', '\n'), |
| 453 }); | 441 }); |
| 454 | 442 |
| 455 testPhases('published via attributes', phases, { | 443 testPhases('published via attributes', phases, { |
| 456 'a|web/test.html': | 444 'a|web/test.html': |
| 457 '<!DOCTYPE html><html><body>' | 445 '<!DOCTYPE html><html><body>' |
| 458 '<polymer-element name="x-foo" attributes="field1,prop2">' | 446 '<polymer-element name="x-foo" attributes="field1,prop2">' |
| 459 '</polymer-element>' | 447 '</polymer-element>', |
| 460 '<script type="application/dart" src="a.dart"></script>', | 448 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
| 461 'a|web/test.html.scriptUrls': '[]', | |
| 462 'a|web/a.dart': | 449 'a|web/a.dart': |
| 463 'library a;\n' | 450 'library a;\n' |
| 464 'import "package:polymer/polymer.dart";\n' | 451 'import "package:polymer/polymer.dart";\n' |
| 465 '@CustomTag("x-foo")\n' | 452 '@CustomTag("x-foo")\n' |
| 466 'class XFoo extends PolymerElement {\n' | 453 'class XFoo extends PolymerElement {\n' |
| 467 ' int field1;\n' | 454 ' int field1;\n' |
| 468 ' int field2;\n' | 455 ' int field2;\n' |
| 469 ' int get prop1 => 1;\n' | 456 ' int get prop1 => 1;\n' |
| 470 ' set prop1(int x) {};\n' | 457 ' set prop1(int x) {};\n' |
| 471 ' int get prop2 => 2;\n' | 458 ' int get prop2 => 2;\n' |
| 472 ' set prop2(int x) {};\n' | 459 ' set prop2(int x) {};\n' |
| 473 '}\n' | 460 '}\n', |
| 474 'main(){}', | |
| 475 }, { | 461 }, { |
| 476 'a|web/test.html_bootstrap.dart': | 462 'a|web/test.html_bootstrap.dart': |
| 477 '''$MAIN_HEADER | 463 '''$MAIN_HEADER |
| 478 import 'a.dart' as i0; | 464 import 'a.dart' as i0; |
| 479 ${DEFAULT_IMPORTS.join('\n')} | 465 ${DEFAULT_IMPORTS.join('\n')} |
| 480 import 'a.dart' as smoke_0; | 466 import 'a.dart' as smoke_0; |
| 481 import 'package:polymer/polymer.dart' as smoke_1; | 467 import 'package:polymer/polymer.dart' as smoke_1; |
| 482 | 468 |
| 483 void main() { | 469 void main() { |
| 484 useGeneratedCode(new StaticConfiguration( | 470 useGeneratedCode(new StaticConfiguration( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 497 declarations: { | 483 declarations: { |
| 498 smoke_0.XFoo: { | 484 smoke_0.XFoo: { |
| 499 #field1: const Declaration(#field1, int), | 485 #field1: const Declaration(#field1, int), |
| 500 #prop2: const Declaration(#prop2, int, kind: PROPERTY), | 486 #prop2: const Declaration(#prop2, int, kind: PROPERTY), |
| 501 }, | 487 }, |
| 502 }, | 488 }, |
| 503 names: { | 489 names: { |
| 504 #field1: r'field1', | 490 #field1: r'field1', |
| 505 #prop2: r'prop2', | 491 #prop2: r'prop2', |
| 506 })); | 492 })); |
| 507 configureForDeployment([ | 493 startPolymer([ |
| 508 () => Polymer.register(\'x-foo\', i0.XFoo), | 494 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 509 ]); | 495 ]); |
| 510 i0.main(); | |
| 511 } | 496 } |
| 512 '''.replaceAll('\n ', '\n'), | 497 '''.replaceAll('\n ', '\n'), |
| 513 }); | 498 }); |
| 514 | 499 |
| 515 final fooDetails = | 500 final fooDetails = |
| 516 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; | 501 "kind: METHOD, annotations: const [const smoke_1.ObserveProperty('x')]"; |
| 517 final xChangedDetails = "Function, kind: METHOD"; | 502 final xChangedDetails = "Function, kind: METHOD"; |
| 518 testPhases('ObserveProperty and *Changed methods', phases, { | 503 testPhases('ObserveProperty and *Changed methods', phases, { |
| 519 'a|web/test.html': | 504 'a|web/test.html': |
| 520 '<!DOCTYPE html><html><body>' | 505 '<!DOCTYPE html><html><body>' |
| 521 '</polymer-element>' | 506 '</polymer-element>', |
| 522 '<script type="application/dart" src="a.dart"></script>', | 507 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
| 523 'a|web/test.html.scriptUrls': '[]', | |
| 524 'a|web/a.dart': | 508 'a|web/a.dart': |
| 525 'library a;\n' | 509 'library a;\n' |
| 526 'import "package:polymer/polymer.dart";\n' | 510 'import "package:polymer/polymer.dart";\n' |
| 527 '@CustomTag("x-foo")\n' | 511 '@CustomTag("x-foo")\n' |
| 528 'class XFoo extends PolymerElement {\n' | 512 'class XFoo extends PolymerElement {\n' |
| 529 ' int x;\n' | 513 ' int x;\n' |
| 530 ' void xChanged() {}\n' | 514 ' void xChanged() {}\n' |
| 531 ' void attributeChanged() {}\n' // should be excluded | 515 ' void attributeChanged() {}\n' // should be excluded |
| 532 ' @ObserveProperty("x")' | 516 ' @ObserveProperty("x")' |
| 533 ' void foo() {}\n' | 517 ' void foo() {}\n' |
| 534 '}\n' | 518 '}\n', |
| 535 'main(){}', | |
| 536 }, { | 519 }, { |
| 537 'a|web/test.html_bootstrap.dart': | 520 'a|web/test.html_bootstrap.dart': |
| 538 '''$MAIN_HEADER | 521 '''$MAIN_HEADER |
| 539 import 'a.dart' as i0; | 522 import 'a.dart' as i0; |
| 540 ${DEFAULT_IMPORTS.join('\n')} | 523 ${DEFAULT_IMPORTS.join('\n')} |
| 541 import 'a.dart' as smoke_0; | 524 import 'a.dart' as smoke_0; |
| 542 import 'package:polymer/polymer.dart' as smoke_1; | 525 import 'package:polymer/polymer.dart' as smoke_1; |
| 543 | 526 |
| 544 void main() { | 527 void main() { |
| 545 useGeneratedCode(new StaticConfiguration( | 528 useGeneratedCode(new StaticConfiguration( |
| 546 checkedMode: false, | 529 checkedMode: false, |
| 547 getters: { | 530 getters: { |
| 548 #foo: (o) => o.foo, | 531 #foo: (o) => o.foo, |
| 549 #xChanged: (o) => o.xChanged, | 532 #xChanged: (o) => o.xChanged, |
| 550 }, | 533 }, |
| 551 parents: { | 534 parents: { |
| 552 smoke_0.XFoo: smoke_1.PolymerElement, | 535 smoke_0.XFoo: smoke_1.PolymerElement, |
| 553 }, | 536 }, |
| 554 declarations: { | 537 declarations: { |
| 555 smoke_0.XFoo: { | 538 smoke_0.XFoo: { |
| 556 #foo: const Declaration(#foo, Function, $fooDetails), | 539 #foo: const Declaration(#foo, Function, $fooDetails), |
| 557 #xChanged: const Declaration(#xChanged, $xChangedDetails), | 540 #xChanged: const Declaration(#xChanged, $xChangedDetails), |
| 558 }, | 541 }, |
| 559 }, | 542 }, |
| 560 names: { | 543 names: { |
| 561 #foo: r'foo', | 544 #foo: r'foo', |
| 562 #xChanged: r'xChanged', | 545 #xChanged: r'xChanged', |
| 563 })); | 546 })); |
| 564 configureForDeployment([ | 547 startPolymer([ |
| 565 () => Polymer.register(\'x-foo\', i0.XFoo), | 548 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 566 ]); | 549 ]); |
| 567 i0.main(); | |
| 568 } | 550 } |
| 569 '''.replaceAll('\n ', '\n'), | 551 '''.replaceAll('\n ', '\n'), |
| 570 }); | 552 }); |
| 571 | 553 |
| 572 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; | 554 final rcDetails = "#registerCallback, Function, kind: METHOD, isStatic: true"; |
| 573 testPhases('register callback is included', phases, { | 555 testPhases('register callback is included', phases, { |
| 574 'a|web/test.html': | 556 'a|web/test.html': |
| 575 '<!DOCTYPE html><html><body>' | 557 '<!DOCTYPE html><html><body>' |
| 576 '</polymer-element>' | 558 '</polymer-element>', |
| 577 '<script type="application/dart" src="a.dart"></script>', | 559 'a|web/test.html.scriptUrls': '[["a","web/a.dart"]]', |
| 578 'a|web/test.html.scriptUrls': '[]', | |
| 579 'a|web/a.dart': | 560 'a|web/a.dart': |
| 580 'library a;\n' | 561 'library a;\n' |
| 581 'import "package:polymer/polymer.dart";\n' | 562 'import "package:polymer/polymer.dart";\n' |
| 582 '@CustomTag("x-foo")\n' | 563 '@CustomTag("x-foo")\n' |
| 583 'class XFoo extends PolymerElement {\n' | 564 'class XFoo extends PolymerElement {\n' |
| 584 ' static registerCallback() {};\n' | 565 ' static registerCallback() {};\n' |
| 585 ' static foo() {};\n' | 566 ' static foo() {};\n' |
| 586 '}\n' | 567 '}\n', |
| 587 'main(){}', | |
| 588 }, { | 568 }, { |
| 589 'a|web/test.html_bootstrap.dart': | 569 'a|web/test.html_bootstrap.dart': |
| 590 '''$MAIN_HEADER | 570 '''$MAIN_HEADER |
| 591 import 'a.dart' as i0; | 571 import 'a.dart' as i0; |
| 592 ${DEFAULT_IMPORTS.join('\n')} | 572 ${DEFAULT_IMPORTS.join('\n')} |
| 593 import 'a.dart' as smoke_0; | 573 import 'a.dart' as smoke_0; |
| 594 import 'package:polymer/polymer.dart' as smoke_1; | 574 import 'package:polymer/polymer.dart' as smoke_1; |
| 595 | 575 |
| 596 void main() { | 576 void main() { |
| 597 useGeneratedCode(new StaticConfiguration( | 577 useGeneratedCode(new StaticConfiguration( |
| 598 checkedMode: false, | 578 checkedMode: false, |
| 599 parents: { | 579 parents: { |
| 600 smoke_0.XFoo: smoke_1.PolymerElement, | 580 smoke_0.XFoo: smoke_1.PolymerElement, |
| 601 }, | 581 }, |
| 602 declarations: { | 582 declarations: { |
| 603 smoke_0.XFoo: { | 583 smoke_0.XFoo: { |
| 604 #registerCallback: const Declaration($rcDetails), | 584 #registerCallback: const Declaration($rcDetails), |
| 605 }, | 585 }, |
| 606 }, | 586 }, |
| 607 staticMethods: { | 587 staticMethods: { |
| 608 smoke_0.XFoo: { | 588 smoke_0.XFoo: { |
| 609 #registerCallback: smoke_0.XFoo.registerCallback, | 589 #registerCallback: smoke_0.XFoo.registerCallback, |
| 610 }, | 590 }, |
| 611 }, | 591 }, |
| 612 names: { | 592 names: { |
| 613 #registerCallback: r'registerCallback', | 593 #registerCallback: r'registerCallback', |
| 614 })); | 594 })); |
| 615 configureForDeployment([ | 595 startPolymer([ |
| 616 () => Polymer.register(\'x-foo\', i0.XFoo), | 596 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 617 ]); | 597 ]); |
| 618 i0.main(); | |
| 619 } | 598 } |
| 620 '''.replaceAll('\n ', '\n'), | 599 '''.replaceAll('\n ', '\n'), |
| 621 }); | 600 }); |
| 622 } | 601 } |
| OLD | NEW |