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

Side by Side Diff: pkg/polymer/test/transform/code_extractor_test.dart

Issue 23478015: Apply several phases only to entrypoint files (which currently are identified as (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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.transform.code_extractor_test; 5 library polymer.test.transform.code_extractor_test;
6 6
7 import 'package:polymer/src/transform/code_extractor.dart'; 7 import 'package:polymer/src/transform/code_extractor.dart';
8 import 'package:unittest/compact_vm_config.dart'; 8 import 'package:unittest/compact_vm_config.dart';
9 9
10 import 'common.dart'; 10 import 'common.dart';
11 11
12 void main() { 12 void main() {
13 useCompactVMConfiguration(); 13 useCompactVMConfiguration();
14 14
15 testPhases('no changes', [[new InlineCodeExtractor()]], { 15 testPhases('no changes', [[new InlineCodeExtractor()]], {
16 'a|test.html': '<!DOCTYPE html><html></html>', 16 'a|web/test.html': '<!DOCTYPE html><html></html>',
17 }, { 17 }, {
18 'a|test.html': '<!DOCTYPE html><html></html>', 18 'a|web/test.html': '<!DOCTYPE html><html></html>',
19 }); 19 });
20 20
21 testPhases('single script, no lib', [[new InlineCodeExtractor()]], { 21 testPhases('single script, no library in script',
22 'a|test.html': 22 [[new InlineCodeExtractor()]], {
23 'a|web/test.html':
23 '<!DOCTYPE html><html><head>' 24 '<!DOCTYPE html><html><head>'
24 '<script type="application/dart">main() { }</script>', 25 '<script type="application/dart">main() { }</script>',
25 }, { 26 }, {
26 'a|test.html': 27 'a|web/test.html':
27 '<!DOCTYPE html><html><head>' 28 '<!DOCTYPE html><html><head>'
28 '<script type="application/dart" src="test.html.0.dart"></script>' 29 '<script type="application/dart" src="test.html.0.dart"></script>'
29 '</head><body></body></html>', 30 '</head><body></body></html>',
30 31
31 'a|test.html.0.dart': 32 'a|web/test.html.0.dart':
32 'library test_html_0;\nmain() { }', 33 'library web_test_html_0;\nmain() { }',
33 }); 34 });
34 35
35 testPhases('single script, with lib', [[new InlineCodeExtractor()]], { 36 testPhases('single script, with library', [[new InlineCodeExtractor()]], {
36 'a|test.html': 37 'a|web/test.html':
37 '<!DOCTYPE html><html><head>' 38 '<!DOCTYPE html><html><head>'
38 '<script type="application/dart">library f;\nmain() { }</script>', 39 '<script type="application/dart">library f;\nmain() { }</script>',
39 }, { 40 }, {
40 'a|test.html': 41 'a|web/test.html':
41 '<!DOCTYPE html><html><head>' 42 '<!DOCTYPE html><html><head>'
42 '<script type="application/dart" src="test.html.0.dart"></script>' 43 '<script type="application/dart" src="test.html.0.dart"></script>'
43 '</head><body></body></html>', 44 '</head><body></body></html>',
44 45
45 'a|test.html.0.dart': 46 'a|web/test.html.0.dart':
47 'library f;\nmain() { }',
48 });
49
50 testPhases('under lib/ directory also transformed',
51 [[new InlineCodeExtractor()]], {
52 'a|lib/test.html':
53 '<!DOCTYPE html><html><head>'
54 '<script type="application/dart">library f;\nmain() { }</script>',
55 }, {
56 'a|lib/test.html':
57 '<!DOCTYPE html><html><head>'
58 '<script type="application/dart" src="test.html.0.dart"></script>'
59 '</head><body></body></html>',
60
61 'a|lib/test.html.0.dart':
46 'library f;\nmain() { }', 62 'library f;\nmain() { }',
47 }); 63 });
48 64
49 testPhases('multiple scripts', [[new InlineCodeExtractor()]], { 65 testPhases('multiple scripts', [[new InlineCodeExtractor()]], {
50 'a|test.html': 66 'a|web/test.html':
51 '<!DOCTYPE html><html><head>' 67 '<!DOCTYPE html><html><head>'
52 '<script type="application/dart">library a1;\nmain1() { }</script>' 68 '<script type="application/dart">library a1;\nmain1() { }</script>'
53 '<script type="application/dart">library a2;\nmain2() { }</script>', 69 '<script type="application/dart">library a2;\nmain2() { }</script>',
54 }, { 70 }, {
55 'a|test.html': 71 'a|web/test.html':
56 '<!DOCTYPE html><html><head>' 72 '<!DOCTYPE html><html><head>'
57 '<script type="application/dart" src="test.html.0.dart"></script>' 73 '<script type="application/dart" src="test.html.0.dart"></script>'
58 '<script type="application/dart" src="test.html.1.dart"></script>' 74 '<script type="application/dart" src="test.html.1.dart"></script>'
59 '</head><body></body></html>', 75 '</head><body></body></html>',
60 76
61 'a|test.html.0.dart': 77 'a|web/test.html.0.dart':
62 'library a1;\nmain1() { }', 78 'library a1;\nmain1() { }',
63 79
64 'a|test.html.1.dart': 80 'a|web/test.html.1.dart':
65 'library a2;\nmain2() { }', 81 'library a2;\nmain2() { }',
66 }); 82 });
67 83
68 testPhases('multiple deeper scripts', [[new InlineCodeExtractor()]], { 84 testPhases('multiple deeper scripts', [[new InlineCodeExtractor()]], {
69 'a|test.html': 85 'a|web/test.html':
70 '<!DOCTYPE html><html><head>' 86 '<!DOCTYPE html><html><head>'
71 '<script type="application/dart">main1() { }</script>' 87 '<script type="application/dart">main1() { }</script>'
72 '</head><body><div>' 88 '</head><body><div>'
73 '<script type="application/dart">main2() { }</script>' 89 '<script type="application/dart">main2() { }</script>'
74 '</div><div><div>' 90 '</div><div><div>'
75 '<script type="application/dart">main3() { }</script>' 91 '<script type="application/dart">main3() { }</script>'
76 '</div></div>' 92 '</div></div>'
77 }, { 93 }, {
78 'a|test.html': 94 'a|web/test.html':
79 '<!DOCTYPE html><html><head>' 95 '<!DOCTYPE html><html><head>'
80 '<script type="application/dart" src="test.html.0.dart"></script>' 96 '<script type="application/dart" src="test.html.0.dart"></script>'
81 '</head><body><div>' 97 '</head><body><div>'
82 '<script type="application/dart" src="test.html.1.dart"></script>' 98 '<script type="application/dart" src="test.html.1.dart"></script>'
83 '</div><div><div>' 99 '</div><div><div>'
84 '<script type="application/dart" src="test.html.2.dart"></script>' 100 '<script type="application/dart" src="test.html.2.dart"></script>'
85 '</div></div></body></html>', 101 '</div></div></body></html>',
86 102
87 'a|test.html.0.dart': 103 'a|web/test.html.0.dart':
88 'library test_html_0;\nmain1() { }', 104 'library web_test_html_0;\nmain1() { }',
89 105
90 'a|test.html.1.dart': 106 'a|web/test.html.1.dart':
91 'library test_html_1;\nmain2() { }', 107 'library web_test_html_1;\nmain2() { }',
92 108
93 'a|test.html.2.dart': 109 'a|web/test.html.2.dart':
94 'library test_html_2;\nmain3() { }', 110 'library web_test_html_2;\nmain3() { }',
95 }); 111 });
96 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698