Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Side by Side Diff: pkg/polymer/test/build/all_phases_test.dart

Issue 180933002: combine script extractor and import inliner (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: refactor Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.all_phases_test; 5 library polymer.test.build.all_phases_test;
6 6
7 import 'package:polymer/src/build/common.dart'; 7 import 'package:polymer/src/build/common.dart';
8 import 'package:polymer/src/build/script_compactor.dart' show MAIN_HEADER; 8 import 'package:polymer/src/build/script_compactor.dart' show MAIN_HEADER;
9 import 'package:polymer/transformer.dart'; 9 import 'package:polymer/transformer.dart';
10 import 'package:unittest/compact_vm_config.dart'; 10 import 'package:unittest/compact_vm_config.dart';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 testPhases('single inline script', phases, { 58 testPhases('single inline script', phases, {
59 'a|web/test.html': 59 'a|web/test.html':
60 '<!DOCTYPE html><html><head>' 60 '<!DOCTYPE html><html><head>'
61 '<script type="application/dart">' 61 '<script type="application/dart">'
62 '${_sampleObservable("B", "bar")}</script>', 62 '${_sampleObservable("B", "bar")}</script>',
63 }, { 63 }, {
64 'a|web/test.html': 64 'a|web/test.html':
65 '<!DOCTYPE html><html><head>' 65 '<!DOCTYPE html><html><head>'
66 '$WEB_COMPONENTS_TAG' 66 '$WEB_COMPONENTS_TAG'
67 '$INTEROP_TAG' 67 '$INTEROP_TAG'
68 '</head><body>'
68 '<script src="test.html_bootstrap.dart.js"></script>' 69 '<script src="test.html_bootstrap.dart.js"></script>'
69 '</head><body></body></html>', 70 '</body></html>',
70 71
71 'a|web/test.html_bootstrap.dart': 72 'a|web/test.html_bootstrap.dart':
72 '''$MAIN_HEADER 73 '''$MAIN_HEADER
73 import 'test.html.0.dart' as i0; 74 import 'test.html.0.dart' as i0;
74 75
75 void main() { 76 void main() {
76 configureForDeployment([ 77 configureForDeployment([
77 ]); 78 ]);
78 i0.main(); 79 i0.main();
79 } 80 }
(...skipping 16 matching lines...) Expand all
96 '<script type="application/dart">' 97 '<script type="application/dart">'
97 '${_sampleObservable("C", "car")}</script>' 98 '${_sampleObservable("C", "car")}</script>'
98 '</div>' 99 '</div>'
99 '<script type="application/dart" src="d.dart"></script>', 100 '<script type="application/dart" src="d.dart"></script>',
100 'a|web/a.dart': _sampleObservable('A', 'foo'), 101 'a|web/a.dart': _sampleObservable('A', 'foo'),
101 }, { 102 }, {
102 'a|web/test.html': 103 'a|web/test.html':
103 '<!DOCTYPE html><html><head>' 104 '<!DOCTYPE html><html><head>'
104 '$WEB_COMPONENTS_TAG' 105 '$WEB_COMPONENTS_TAG'
105 '$INTEROP_TAG' 106 '$INTEROP_TAG'
107 '</head><body>'
106 '<script src="test.html_bootstrap.dart.js"></script>' 108 '<script src="test.html_bootstrap.dart.js"></script>'
107 '</head><body>'
108 '<div></div>' 109 '<div></div>'
109 '</body></html>', 110 '</body></html>',
110 111
111 'a|web/test.html_bootstrap.dart': 112 'a|web/test.html_bootstrap.dart':
112 '''$MAIN_HEADER 113 '''$MAIN_HEADER
113 import 'a.dart' as i0; 114 import 'a.dart' as i0;
114 115
115 void main() { 116 void main() {
116 configureForDeployment([ 117 configureForDeployment([
117 ]); 118 ]);
118 i0.main(); 119 i0.main();
119 } 120 }
120 '''.replaceAll('\n ', '\n'), 121 '''.replaceAll('\n ', '\n'),
121 'a|web/a.dart': _sampleObservableOutput('A', 'foo'), 122 'a|web/a.dart': _sampleObservableOutput('A', 'foo'),
Siggi Cherem (dart-lang) 2014/02/26 22:27:09 consider providing also the expectedMessages argum
Jennifer Messerly 2014/02/27 22:31:40 done. All of our warnings are emitted too much (I
122 'a|web/test.html.0.dart': _sampleObservableOutput("B", "bar"),
123 'a|web/test.html.1.dart': _sampleObservableOutput("C", "car"),
124 }); 123 });
125 124
126 testPhases('with imports', phases, { 125 testPhases('with imports', phases, {
127 'a|web/index.html': 126 'a|web/index.html':
128 '<!DOCTYPE html><html><head>' 127 '<!DOCTYPE html><html><head>'
129 '<link rel="import" href="test2.html">' 128 '<link rel="import" href="test2.html">'
130 '</head><body>' 129 '</head><body>'
131 '<script type="application/dart" src="b.dart"></script>', 130 '<script type="application/dart" src="b.dart"></script>',
132 'a|web/b.dart': _sampleObservable('B', 'bar'), 131 'a|web/b.dart': _sampleObservable('B', 'bar'),
133 'a|web/test2.html': 132 'a|web/test2.html':
134 '<!DOCTYPE html><html><head></head><body>' 133 '<!DOCTYPE html><html><head></head><body>'
135 '<polymer-element>1' 134 '<polymer-element>1'
136 '<script type="application/dart">' 135 '<script type="application/dart">'
137 '${_sampleObservable("A", "foo")}</script>' 136 '${_sampleObservable("A", "foo")}</script>'
138 '</polymer-element></html>', 137 '</polymer-element></html>',
139 }, { 138 }, {
140 'a|web/index.html': 139 'a|web/index.html':
141 '<!DOCTYPE html><html><head>' 140 '<!DOCTYPE html><html><head>'
142 '$WEB_COMPONENTS_TAG' 141 '$WEB_COMPONENTS_TAG'
143 '$INTEROP_TAG' 142 '$INTEROP_TAG'
144 '</head><body><polymer-element>1</polymer-element>' 143 '</head><body><polymer-element>1</polymer-element>'
145 '<script src="index.html_bootstrap.dart.js"></script>' 144 '<script src="index.html_bootstrap.dart.js"></script>'
146 '</body></html>', 145 '</body></html>',
147 'a|web/index.html_bootstrap.dart': 146 'a|web/index.html_bootstrap.dart':
148 '''$MAIN_HEADER 147 '''$MAIN_HEADER
149 import 'test2.html.0.dart' as i0; 148 import 'index.html.0.dart' as i0;
150 import 'b.dart' as i1; 149 import 'b.dart' as i1;
151 150
152 void main() { 151 void main() {
153 configureForDeployment([ 152 configureForDeployment([
154 ]); 153 ]);
155 i1.main(); 154 i1.main();
156 } 155 }
157 '''.replaceAll('\n ', '\n'), 156 '''.replaceAll('\n ', '\n'),
158 'a|web/test2.html.0.dart': _sampleObservableOutput("A", "foo"), 157 'a|web/index.html.0.dart': _sampleObservableOutput("A", "foo"),
159 'a|web/b.dart': _sampleObservableOutput('B', 'bar'), 158 'a|web/b.dart': _sampleObservableOutput('B', 'bar'),
160 }); 159 });
161 } 160 }
162 161
163 String _sampleObservable(String className, String fieldName) => ''' 162 String _sampleObservable(String className, String fieldName) => '''
164 library ${className}_$fieldName; 163 library ${className}_$fieldName;
165 import 'package:observe/observe.dart'; 164 import 'package:observe/observe.dart';
166 165
167 class $className extends Observable { 166 class $className extends Observable {
168 @observable int $fieldName; 167 @observable int $fieldName;
169 $className(this.$fieldName); 168 $className(this.$fieldName);
170 } 169 }
171 '''; 170 ''';
172 171
173 String _sampleObservableOutput(String className, String field, 172 String _sampleObservableOutput(String className, String field,
174 {bool includeMain: false}) => 173 {bool includeMain: false}) =>
175 "library ${className}_$field;\n" 174 "library ${className}_$field;\n"
176 "import 'package:observe/observe.dart';\n\n" 175 "import 'package:observe/observe.dart';\n\n"
177 "class $className extends ChangeNotifier {\n" 176 "class $className extends ChangeNotifier {\n"
178 " @reflectable @observable int get $field => __\$$field; " 177 " @reflectable @observable int get $field => __\$$field; "
179 "int __\$$field; " 178 "int __\$$field; "
180 "@reflectable set $field(int value) { " 179 "@reflectable set $field(int value) { "
181 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); " 180 "__\$$field = notifyPropertyChange(#$field, __\$$field, value); "
182 "}\n" 181 "}\n"
183 " $className($field) : __\$$field = $field;\n" 182 " $className($field) : __\$$field = $field;\n"
184 "}\n"; 183 "}\n";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698