3fba647ba8
those inside the web/ or test/ directory), and hide doctype warnings when processing non entrypoint files. R=jmesserly@google.com Review URL: https://codereview.chromium.org//23478015 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27142 260f80e4-7a28-3924-810f-c04153c831b5
113 lines
3.8 KiB
Dart
113 lines
3.8 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library polymer.test.transform.code_extractor_test;
|
|
|
|
import 'package:polymer/src/transform/code_extractor.dart';
|
|
import 'package:unittest/compact_vm_config.dart';
|
|
|
|
import 'common.dart';
|
|
|
|
void main() {
|
|
useCompactVMConfiguration();
|
|
|
|
testPhases('no changes', [[new InlineCodeExtractor()]], {
|
|
'a|web/test.html': '<!DOCTYPE html><html></html>',
|
|
}, {
|
|
'a|web/test.html': '<!DOCTYPE html><html></html>',
|
|
});
|
|
|
|
testPhases('single script, no library in script',
|
|
[[new InlineCodeExtractor()]], {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart">main() { }</script>',
|
|
}, {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart" src="test.html.0.dart"></script>'
|
|
'</head><body></body></html>',
|
|
|
|
'a|web/test.html.0.dart':
|
|
'library web_test_html_0;\nmain() { }',
|
|
});
|
|
|
|
testPhases('single script, with library', [[new InlineCodeExtractor()]], {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart">library f;\nmain() { }</script>',
|
|
}, {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart" src="test.html.0.dart"></script>'
|
|
'</head><body></body></html>',
|
|
|
|
'a|web/test.html.0.dart':
|
|
'library f;\nmain() { }',
|
|
});
|
|
|
|
testPhases('under lib/ directory also transformed',
|
|
[[new InlineCodeExtractor()]], {
|
|
'a|lib/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart">library f;\nmain() { }</script>',
|
|
}, {
|
|
'a|lib/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart" src="test.html.0.dart"></script>'
|
|
'</head><body></body></html>',
|
|
|
|
'a|lib/test.html.0.dart':
|
|
'library f;\nmain() { }',
|
|
});
|
|
|
|
testPhases('multiple scripts', [[new InlineCodeExtractor()]], {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart">library a1;\nmain1() { }</script>'
|
|
'<script type="application/dart">library a2;\nmain2() { }</script>',
|
|
}, {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart" src="test.html.0.dart"></script>'
|
|
'<script type="application/dart" src="test.html.1.dart"></script>'
|
|
'</head><body></body></html>',
|
|
|
|
'a|web/test.html.0.dart':
|
|
'library a1;\nmain1() { }',
|
|
|
|
'a|web/test.html.1.dart':
|
|
'library a2;\nmain2() { }',
|
|
});
|
|
|
|
testPhases('multiple deeper scripts', [[new InlineCodeExtractor()]], {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart">main1() { }</script>'
|
|
'</head><body><div>'
|
|
'<script type="application/dart">main2() { }</script>'
|
|
'</div><div><div>'
|
|
'<script type="application/dart">main3() { }</script>'
|
|
'</div></div>'
|
|
}, {
|
|
'a|web/test.html':
|
|
'<!DOCTYPE html><html><head>'
|
|
'<script type="application/dart" src="test.html.0.dart"></script>'
|
|
'</head><body><div>'
|
|
'<script type="application/dart" src="test.html.1.dart"></script>'
|
|
'</div><div><div>'
|
|
'<script type="application/dart" src="test.html.2.dart"></script>'
|
|
'</div></div></body></html>',
|
|
|
|
'a|web/test.html.0.dart':
|
|
'library web_test_html_0;\nmain1() { }',
|
|
|
|
'a|web/test.html.1.dart':
|
|
'library web_test_html_1;\nmain2() { }',
|
|
|
|
'a|web/test.html.2.dart':
|
|
'library web_test_html_2;\nmain3() { }',
|
|
});
|
|
}
|