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.linter_test; | 5 library polymer.test.linter_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/linter.dart'; | 8 import 'package:polymer/src/build/linter.dart'; |
9 import 'package:source_maps/span.dart'; | 9 import 'package:source_maps/span.dart'; |
10 import 'package:unittest/compact_vm_config.dart'; | 10 import 'package:unittest/compact_vm_config.dart'; |
11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
12 | 12 |
13 import 'common.dart'; | 13 import 'common.dart'; |
14 | 14 |
15 void main() { | 15 void main() { |
16 useCompactVMConfiguration(); | 16 useCompactVMConfiguration(); |
17 _testLinter('nothing to report', { | 17 _testLinter('nothing to report', { |
18 'a|lib/test.html': '<!DOCTYPE html><html></html>', | 18 'a|lib/test.html': '<!DOCTYPE html><html></html>', |
19 }, { | 19 }, { |
20 'a|lib/test.html.messages': '' | 20 'a|lib/test.html.messages': '' |
21 }); | 21 }); |
22 | 22 |
23 group('must use init.dart, dart.js, not boot.js', () { | 23 group('must have Dart code to invoke initPolymer, dart.js, not boot.js', () { |
24 _testLinter('nothing to report', { | 24 _testLinter('nothing to report', { |
25 'a|web/test.html': '<!DOCTYPE html><html>' | 25 'a|web/test.html': '<!DOCTYPE html><html>' |
26 '<script type="application/dart" src="packages/polymer/init.dart">' | 26 '<script type="application/dart" src="foo.dart">' |
27 '</script>' | 27 '</script>' |
28 '<script src="packages/browser/dart.js"></script>' | 28 '<script src="packages/browser/dart.js"></script>' |
29 '</html>', | 29 '</html>', |
30 }, { | 30 }, { |
31 'a|web/test.html.messages': '', | 31 'a|web/test.html.messages': '', |
32 }); | 32 }); |
33 | 33 |
34 _testLinter('missing init.dart and dart.js', { | 34 _testLinter('missing Dart code and dart.js', { |
35 'a|web/test.html': '<!DOCTYPE html><html></html>', | 35 'a|web/test.html': '<!DOCTYPE html><html></html>', |
36 }, { | 36 }, { |
37 'a|web/test.html.messages': 'error: $USE_INIT_DART\n' | 37 'a|web/test.html.messages': 'error: $USE_INIT_DART\n' |
38 'error: $USE_DART_JS', | 38 'error: $USE_DART_JS', |
39 }); | 39 }); |
40 | 40 |
41 _testLinter('using deprecated boot.js', { | 41 _testLinter('using deprecated boot.js', { |
42 'a|web/test.html': '<!DOCTYPE html><html>\n' | 42 'a|web/test.html': '<!DOCTYPE html><html>\n' |
43 '<script src="packages/polymer/boot.js"></script>' | 43 '<script src="packages/polymer/boot.js"></script>' |
44 '<script type="application/dart" src="packages/polymer/init.dart">' | 44 '<script type="application/dart" src="foo.dart">' |
45 '</script>' | 45 '</script>' |
46 '<script src="packages/browser/dart.js"></script>' | 46 '<script src="packages/browser/dart.js"></script>' |
47 '</html>', | 47 '</html>', |
48 }, { | 48 }, { |
49 'a|web/test.html.messages': 'warning: $BOOT_JS_DEPRECATED ' | 49 'a|web/test.html.messages': 'warning: $BOOT_JS_DEPRECATED ' |
50 '(web/test.html 1 0)', | 50 '(web/test.html 1 0)', |
51 }); | 51 }); |
52 }); | 52 }); |
53 group('single script tag per document', () { | 53 group('single script tag per document', () { |
54 _testLinter('two top-level tags', { | 54 _testLinter('two top-level tags', { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 524 |
525 | 525 |
526 _testFormatter(String kind, String message, Span span) { | 526 _testFormatter(String kind, String message, Span span) { |
527 var formattedMessage = '$kind: $message'; | 527 var formattedMessage = '$kind: $message'; |
528 if (span != null) { | 528 if (span != null) { |
529 formattedMessage = '$formattedMessage ' | 529 formattedMessage = '$formattedMessage ' |
530 '(${span.sourceUrl} ${span.start.line} ${span.start.column})'; | 530 '(${span.sourceUrl} ${span.start.line} ${span.start.column})'; |
531 } | 531 } |
532 return formattedMessage; | 532 return formattedMessage; |
533 } | 533 } |
OLD | NEW |