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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 configureForDeployment([]); | 731 configureForDeployment([]); |
732 i0.main(); | 732 i0.main(); |
733 } | 733 } |
734 '''.replaceAll('\n ', '\n'), | 734 '''.replaceAll('\n ', '\n'), |
735 'a|web/a.dart': | 735 'a|web/a.dart': |
736 'library a;\n' | 736 'library a;\n' |
737 'import "package:polymer/polymer.dart";\n' | 737 'import "package:polymer/polymer.dart";\n' |
738 'main(){}', | 738 'main(){}', |
739 }); | 739 }); |
740 | 740 |
| 741 computedDeclaration(name, expr) => |
| 742 '#$name: const Declaration(#$name, dynamic, kind: PROPERTY,' |
| 743 ' isFinal: true, annotations: const [const smoke_1.ComputedProperty' |
| 744 '(\'$expr\')])'; |
| 745 |
| 746 testPhases('computed properties', phases, { |
| 747 'a|web/test.html': |
| 748 '<!DOCTYPE html><html><body>' |
| 749 '<polymer-element name="x-foo"><template>' |
| 750 '</template></polymer-element>', |
| 751 'a|web/test.html._data': expectedData(['web/a.dart']), |
| 752 'a|web/a.dart': |
| 753 'library a;\n' |
| 754 'import "package:polymer/polymer.dart";\n' |
| 755 '@CustomTag("x-foo")\n' |
| 756 'class XFoo extends PolymerElement {\n' |
| 757 ' @ComputedProperty("ta.tb")\n' |
| 758 ' get pa => readValue(#pa);\n' |
| 759 ' @ComputedProperty(" tc ")\n' // extra space inside is OK |
| 760 ' get pb => null;\n' |
| 761 ' @ComputedProperty("td.m1(te)")\n' |
| 762 ' get pc => null;\n' |
| 763 ' @ComputedProperty("m2(tf)")\n' |
| 764 ' get pd => null;\n' |
| 765 ' @ComputedProperty("")\n' // empty is ignored |
| 766 ' get pe => null;\n' |
| 767 ' @ComputedProperty(" ")\n' |
| 768 ' get pf => null;\n' |
| 769 ' @ComputedProperty("tg + th")\n' |
| 770 ' get pg => null;\n' |
| 771 ' @ComputedProperty("ti.tj | tk")\n' |
| 772 ' get ph => null;\n' |
| 773 '}\n' |
| 774 'main(){}', |
| 775 }, { |
| 776 'a|web/test.html_bootstrap.dart': |
| 777 '''$MAIN_HEADER |
| 778 import 'a.dart' as i0; |
| 779 ${DEFAULT_IMPORTS.join('\n')} |
| 780 import 'a.dart' as smoke_0; |
| 781 import 'package:polymer/polymer.dart' as smoke_1; |
| 782 |
| 783 void main() { |
| 784 useGeneratedCode(new StaticConfiguration( |
| 785 checkedMode: false, |
| 786 getters: { |
| 787 #m1: (o) => o.m1, |
| 788 #m2: (o) => o.m2, |
| 789 #pa: (o) => o.pa, |
| 790 #pb: (o) => o.pb, |
| 791 #pc: (o) => o.pc, |
| 792 #pd: (o) => o.pd, |
| 793 #pe: (o) => o.pe, |
| 794 #pf: (o) => o.pf, |
| 795 #pg: (o) => o.pg, |
| 796 #ph: (o) => o.ph, |
| 797 #ta: (o) => o.ta, |
| 798 #tb: (o) => o.tb, |
| 799 #tc: (o) => o.tc, |
| 800 #td: (o) => o.td, |
| 801 #te: (o) => o.te, |
| 802 #tf: (o) => o.tf, |
| 803 #tg: (o) => o.tg, |
| 804 #th: (o) => o.th, |
| 805 #ti: (o) => o.ti, |
| 806 #tj: (o) => o.tj, |
| 807 #tk: (o) => o.tk, |
| 808 }, |
| 809 setters: { |
| 810 #tb: (o, v) { o.tb = v; }, |
| 811 #tc: (o, v) { o.tc = v; }, |
| 812 #tj: (o, v) { o.tj = v; }, |
| 813 }, |
| 814 parents: { |
| 815 smoke_0.XFoo: smoke_1.PolymerElement, |
| 816 }, |
| 817 declarations: { |
| 818 smoke_0.XFoo: { |
| 819 ${computedDeclaration('pa', 'ta.tb')}, |
| 820 ${computedDeclaration('pb', ' tc ')}, |
| 821 ${computedDeclaration('pc', 'td.m1(te)')}, |
| 822 ${computedDeclaration('pd', 'm2(tf)')}, |
| 823 ${computedDeclaration('pe', '')}, |
| 824 ${computedDeclaration('pf', ' ')}, |
| 825 ${computedDeclaration('pg', 'tg + th')}, |
| 826 ${computedDeclaration('ph', 'ti.tj | tk')}, |
| 827 }, |
| 828 }, |
| 829 names: { |
| 830 #m1: r'm1', |
| 831 #m2: r'm2', |
| 832 #pa: r'pa', |
| 833 #pb: r'pb', |
| 834 #pc: r'pc', |
| 835 #pd: r'pd', |
| 836 #pe: r'pe', |
| 837 #pf: r'pf', |
| 838 #pg: r'pg', |
| 839 #ph: r'ph', |
| 840 #ta: r'ta', |
| 841 #tb: r'tb', |
| 842 #tc: r'tc', |
| 843 #td: r'td', |
| 844 #te: r'te', |
| 845 #tf: r'tf', |
| 846 #tg: r'tg', |
| 847 #th: r'th', |
| 848 #ti: r'ti', |
| 849 #tj: r'tj', |
| 850 #tk: r'tk', |
| 851 })); |
| 852 configureForDeployment([ |
| 853 () => Polymer.register(\'x-foo\', i0.XFoo), |
| 854 ]); |
| 855 i0.main(); |
| 856 } |
| 857 '''.replaceAll('\n ', '\n'), |
| 858 }); |
| 859 |
741 final field1Details = "annotations: const [smoke_1.published]"; | 860 final field1Details = "annotations: const [smoke_1.published]"; |
742 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; | 861 final field3Details = "isFinal: true, annotations: const [smoke_1.published]"; |
743 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; | 862 final prop1Details = "kind: PROPERTY, annotations: const [smoke_1.published]"; |
744 final prop3Details = | 863 final prop3Details = |
745 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; | 864 "kind: PROPERTY, isFinal: true, annotations: const [smoke_1.published]"; |
746 testPhases('published via annotation', phases, { | 865 testPhases('published via annotation', phases, { |
747 'a|web/test.html': | 866 'a|web/test.html': |
748 '<!DOCTYPE html><html><body>', | 867 '<!DOCTYPE html><html><body>', |
749 'a|web/test.html._data': expectedData(['web/a.dart']), | 868 'a|web/test.html._data': expectedData(['web/a.dart']), |
750 'a|web/a.dart': | 869 'a|web/a.dart': |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 })); | 1086 })); |
968 configureForDeployment([ | 1087 configureForDeployment([ |
969 () => Polymer.register(\'x-foo\', i0.XFoo), | 1088 () => Polymer.register(\'x-foo\', i0.XFoo), |
970 ]); | 1089 ]); |
971 i0.main(); | 1090 i0.main(); |
972 } | 1091 } |
973 '''.replaceAll('\n ', '\n'), | 1092 '''.replaceAll('\n ', '\n'), |
974 }); | 1093 }); |
975 } | 1094 } |
976 | 1095 |
OLD | NEW |