| 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|web/test.html': '<!DOCTYPE html><html></html>', | 18 'a|lib/test.html': '<!DOCTYPE html><html></html>', |
| 19 }, { | 19 }, { |
| 20 'a|web/test.html.messages': '', | 20 'a|lib/test.html.messages': '' |
| 21 }); | 21 }); |
| 22 | 22 |
| 23 group('must use init.dart, dart.js, not boot.js', () { |
| 24 _testLinter('nothing to report', { |
| 25 'a|web/test.html': '<!DOCTYPE html><html>' |
| 26 '<script type="application/dart" src="packages/polymer/init.dart">' |
| 27 '</script>' |
| 28 '<script src="packages/browser/dart.js"></script>' |
| 29 '</html>', |
| 30 }, { |
| 31 'a|web/test.html.messages': '', |
| 32 }); |
| 33 |
| 34 _testLinter('missing init.dart and dart.js', { |
| 35 'a|web/test.html': '<!DOCTYPE html><html></html>', |
| 36 }, { |
| 37 'a|web/test.html.messages': 'error: $USE_INIT_DART\n' |
| 38 'error: $USE_DART_JS', |
| 39 }); |
| 40 |
| 41 _testLinter('using deprecated boot.js', { |
| 42 'a|web/test.html': '<!DOCTYPE html><html>\n' |
| 43 '<script src="packages/polymer/boot.js"></script>' |
| 44 '<script type="application/dart" src="packages/polymer/init.dart">' |
| 45 '</script>' |
| 46 '<script src="packages/browser/dart.js"></script>' |
| 47 '</html>', |
| 48 }, { |
| 49 'a|web/test.html.messages': 'warning: $BOOT_JS_DEPRECATED ' |
| 50 '(web/test.html 1 0)', |
| 51 }); |
| 52 }); |
| 53 |
| 23 group('doctype warning', () { | 54 group('doctype warning', () { |
| 24 _testLinter('in web', { | 55 _testLinter('in web', { |
| 25 'a|web/test.html': '<html></html>', | 56 'a|web/test.html': '<html></html>', |
| 26 }, { | 57 }, { |
| 27 'a|web/test.html.messages': | 58 'a|web/test.html.messages': |
| 28 'warning: Unexpected start tag (html). Expected DOCTYPE. ' | 59 'warning: Unexpected start tag (html). Expected DOCTYPE. ' |
| 29 '(web/test.html 0 0)', | 60 '(web/test.html 0 0)\n' |
| 61 'error: $USE_INIT_DART\n' |
| 62 'error: $USE_DART_JS', |
| 30 }); | 63 }); |
| 31 | 64 |
| 32 _testLinter('in lib', { | 65 _testLinter('in lib', { |
| 33 'a|lib/test.html': '<html></html>', | 66 'a|lib/test.html': '<html></html>', |
| 34 }, { | 67 }, { |
| 35 'a|lib/test.html.messages': '', | 68 'a|lib/test.html.messages': '', |
| 36 }); | 69 }); |
| 37 }); | 70 }); |
| 38 | 71 |
| 39 group('duplicate polymer-elements,', () { | 72 group('duplicate polymer-elements,', () { |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 484 |
| 452 | 485 |
| 453 _testFormatter(String kind, String message, Span span) { | 486 _testFormatter(String kind, String message, Span span) { |
| 454 var formattedMessage = '$kind: $message'; | 487 var formattedMessage = '$kind: $message'; |
| 455 if (span != null) { | 488 if (span != null) { |
| 456 formattedMessage = '$formattedMessage ' | 489 formattedMessage = '$formattedMessage ' |
| 457 '(${span.sourceUrl} ${span.start.line} ${span.start.column})'; | 490 '(${span.sourceUrl} ${span.start.line} ${span.start.column})'; |
| 458 } | 491 } |
| 459 return formattedMessage; | 492 return formattedMessage; |
| 460 } | 493 } |
| OLD | NEW |