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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 '''.replaceAll('\n ', '\n'), | 646 '''.replaceAll('\n ', '\n'), |
647 }, null); | 647 }, null); |
648 } | 648 } |
649 | 649 |
650 codegenTests(phases) { | 650 codegenTests(phases) { |
651 testPhases('bindings', phases, { | 651 testPhases('bindings', phases, { |
652 'a|web/test.html': | 652 'a|web/test.html': |
653 '<!DOCTYPE html><html><body>' | 653 '<!DOCTYPE html><html><body>' |
654 '<polymer-element name="foo-bar"><template>' | 654 '<polymer-element name="foo-bar"><template>' |
655 '<div>{{a.node}}</div>' | 655 '<div>{{a.node}}</div>' |
656 '<div>{{anotherNode}}</div>' | 656 '<div>{{ anotherNode }}</div>' // extra space inside bindings is OK |
657 '<div>{{a.call1(a)}}</div>' | 657 '<div>{{a.call1(a)}}</div>' |
658 '<div>{{call2(a)}}</div>' | 658 '<div>{{call2(a)}}</div>' |
| 659 '<div>{{}}</div>' // empty bindings are ignored |
| 660 '<div>{{ }}</div>' |
659 '<div class="{{an.attribute}}"></div>' | 661 '<div class="{{an.attribute}}"></div>' |
660 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' | 662 '<a href="path/{{within.an.attribute}}/foo/bar"></a>' |
661 '<div data-attribute="{{anotherAttribute}}"></div>' | 663 '<div data-attribute="{{anotherAttribute}}"></div>' |
662 // input and custom-element attributes are treated as 2-way bindings: | 664 // input and custom-element attributes are treated as 2-way bindings: |
663 '<input value="{{this.is.twoWay}}">' | 665 '<input value="{{this.iS.twoWay}}">' |
664 '<input value="{{this.is.twoWayInt | intToStringTransformer}}">' | 666 '<input value="{{this.iS.twoWayInt | intToStringTransformer}}">' |
665 '<something-else my-attribute="{{here.too}}"></something-else>' | 667 '<something-else my-attribute="{{here.too}}"></something-else>' |
666 '<div on-click="{{methodName}}"></div>' | 668 '<div on-click="{{methodName}}"></div>' |
| 669 '<div on-click="{{ methodName2 }}"></div>' // extra space is OK |
667 '<div on-click="{{@read.method}}"></div>' | 670 '<div on-click="{{@read.method}}"></div>' |
| 671 // empty handlers are invalid, but we still produce valid output. |
| 672 '<div on-click="{{}}"></div>' |
| 673 '<div on-click="{{ }}"></div>' |
668 '</template></polymer-element>', | 674 '</template></polymer-element>', |
669 'a|web/test.html._data': expectedData(['web/a.dart']), | 675 'a|web/test.html._data': expectedData(['web/a.dart']), |
670 'a|web/a.dart': | 676 'a|web/a.dart': |
671 'library a;\n' | 677 'library a;\n' |
672 'import "package:polymer/polymer.dart";\n' | 678 'import "package:polymer/polymer.dart";\n' |
673 'main(){}', | 679 'main(){}', |
674 }, { | 680 }, { |
675 'a|web/test.html_bootstrap.dart': | 681 'a|web/test.html_bootstrap.dart': |
676 '''$MAIN_HEADER | 682 '''$MAIN_HEADER |
677 import 'a.dart' as i0; | 683 import 'a.dart' as i0; |
678 ${DEFAULT_IMPORTS.join('\n')} | 684 ${DEFAULT_IMPORTS.join('\n')} |
679 | 685 |
680 void main() { | 686 void main() { |
681 useGeneratedCode(new StaticConfiguration( | 687 useGeneratedCode(new StaticConfiguration( |
682 checkedMode: false, | 688 checkedMode: false, |
683 getters: { | 689 getters: { |
684 #a: (o) => o.a, | 690 #a: (o) => o.a, |
685 #an: (o) => o.an, | 691 #an: (o) => o.an, |
686 #anotherAttribute: (o) => o.anotherAttribute, | 692 #anotherAttribute: (o) => o.anotherAttribute, |
687 #anotherNode: (o) => o.anotherNode, | 693 #anotherNode: (o) => o.anotherNode, |
688 #attribute: (o) => o.attribute, | 694 #attribute: (o) => o.attribute, |
689 #call1: (o) => o.call1, | 695 #call1: (o) => o.call1, |
690 #call2: (o) => o.call2, | 696 #call2: (o) => o.call2, |
691 #here: (o) => o.here, | 697 #here: (o) => o.here, |
| 698 #iS: (o) => o.iS, |
692 #intToStringTransformer: (o) => o.intToStringTransformer, | 699 #intToStringTransformer: (o) => o.intToStringTransformer, |
693 #is: (o) => o.is, | |
694 #method: (o) => o.method, | 700 #method: (o) => o.method, |
695 #methodName: (o) => o.methodName, | 701 #methodName: (o) => o.methodName, |
| 702 #methodName2: (o) => o.methodName2, |
696 #node: (o) => o.node, | 703 #node: (o) => o.node, |
697 #read: (o) => o.read, | 704 #read: (o) => o.read, |
698 #too: (o) => o.too, | 705 #too: (o) => o.too, |
699 #twoWay: (o) => o.twoWay, | 706 #twoWay: (o) => o.twoWay, |
700 #twoWayInt: (o) => o.twoWayInt, | 707 #twoWayInt: (o) => o.twoWayInt, |
701 #within: (o) => o.within, | 708 #within: (o) => o.within, |
702 }, | 709 }, |
703 setters: { | 710 setters: { |
704 #too: (o, v) { o.too = v; }, | 711 #too: (o, v) { o.too = v; }, |
705 #twoWay: (o, v) { o.twoWay = v; }, | 712 #twoWay: (o, v) { o.twoWay = v; }, |
706 #twoWayInt: (o, v) { o.twoWayInt = v; }, | 713 #twoWayInt: (o, v) { o.twoWayInt = v; }, |
707 }, | 714 }, |
708 names: { | 715 names: { |
709 #a: r'a', | 716 #a: r'a', |
710 #an: r'an', | 717 #an: r'an', |
711 #anotherAttribute: r'anotherAttribute', | 718 #anotherAttribute: r'anotherAttribute', |
712 #anotherNode: r'anotherNode', | 719 #anotherNode: r'anotherNode', |
713 #attribute: r'attribute', | 720 #attribute: r'attribute', |
714 #call1: r'call1', | 721 #call1: r'call1', |
715 #call2: r'call2', | 722 #call2: r'call2', |
716 #here: r'here', | 723 #here: r'here', |
| 724 #iS: r'iS', |
717 #intToStringTransformer: r'intToStringTransformer', | 725 #intToStringTransformer: r'intToStringTransformer', |
718 #is: r'is', | |
719 #method: r'method', | 726 #method: r'method', |
720 #methodName: r'methodName', | 727 #methodName: r'methodName', |
| 728 #methodName2: r'methodName2', |
721 #node: r'node', | 729 #node: r'node', |
722 #read: r'read', | 730 #read: r'read', |
723 #too: r'too', | 731 #too: r'too', |
724 #twoWay: r'twoWay', | 732 #twoWay: r'twoWay', |
725 #twoWayInt: r'twoWayInt', | 733 #twoWayInt: r'twoWayInt', |
726 #within: r'within', | 734 #within: r'within', |
727 })); | 735 })); |
728 configureForDeployment([]); | 736 configureForDeployment([]); |
729 i0.main(); | 737 i0.main(); |
730 } | 738 } |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 })); | 972 })); |
965 configureForDeployment([ | 973 configureForDeployment([ |
966 () => Polymer.register(\'x-foo\', i0.XFoo), | 974 () => Polymer.register(\'x-foo\', i0.XFoo), |
967 ]); | 975 ]); |
968 i0.main(); | 976 i0.main(); |
969 } | 977 } |
970 '''.replaceAll('\n ', '\n'), | 978 '''.replaceAll('\n ', '\n'), |
971 }); | 979 }); |
972 } | 980 } |
973 | 981 |
OLD | NEW |