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

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

Issue 77373002: "Reverting 30388" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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.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';
(...skipping 16 matching lines...) Expand all
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 Dart code 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',
38 'error: $USE_DART_JS',
39 }); 38 });
40 39
41 _testLinter('using deprecated boot.js', { 40 _testLinter('using deprecated boot.js', {
42 'a|web/test.html': '<!DOCTYPE html><html>\n' 41 'a|web/test.html': '<!DOCTYPE html><html>\n'
43 '<script src="packages/polymer/boot.js"></script>' 42 '<script src="packages/polymer/boot.js"></script>'
44 '<script type="application/dart" src="foo.dart">' 43 '<script type="application/dart" src="foo.dart">'
45 '</script>' 44 '</script>'
46 '<script src="packages/browser/dart.js"></script>' 45 '<script src="packages/browser/dart.js"></script>'
47 '</html>', 46 '</html>',
48 }, { 47 }, {
49 'a|web/test.html.messages': 'warning: $BOOT_JS_DEPRECATED ' 48 'a|web/test.html.messages': 'warning: $BOOT_JS_DEPRECATED '
50 '(web/test.html 1 0)', 49 '(web/test.html 1 0)',
51 }); 50 });
52 }); 51 });
53 group('single script tag per document', () { 52 group('single script tag per document', () {
54 _testLinter('two top-level tags', { 53 _testLinter('two top-level tags', {
55 'a|web/test.html': '<!DOCTYPE html><html>' 54 'a|web/test.html': '<!DOCTYPE html><html>'
56 '<script type="application/dart" src="a.dart">' 55 '<script type="application/dart" src="a.dart">'
57 '</script>\n' 56 '</script>\n'
58 '<script type="application/dart" src="b.dart">' 57 '<script type="application/dart" src="b.dart">'
59 '</script>' 58 '</script>'
60 '<script src="packages/browser/dart.js"></script>' 59 '<script src="packages/browser/dart.js"></script>'
61 }, { 60 }, {
62 'a|web/test.html.messages': 61 'a|web/test.html.messages':
63 'warning: Only one "application/dart" script tag per document is' 62 'warning: Only one "application/dart" script tag per document is'
64 ' allowed. (web/test.html 1 0)', 63 ' allowed. (web/test.html 1 0)',
65 }); 64 });
66 65
67 _testLinter('two top-level tags, non entrypoint', { 66 _testLinter('two top-level tags, non entrypoint', {
68 'a|lib/test.html': '<!DOCTYPE html><html>' 67 'a|lib/test.html': '<!DOCTYPE html><html>'
69 '<script type="application/dart" src="a.dart">' 68 '<script type="application/dart" src="a.dart">'
70 '</script>\n' 69 '</script>\n'
71 '<script type="application/dart" src="b.dart">' 70 '<script type="application/dart" src="b.dart">'
72 '</script>' 71 '</script>'
73 '<script src="packages/browser/dart.js"></script>' 72 '<script src="packages/browser/dart.js"></script>'
74 }, { 73 }, {
75 'a|lib/test.html.messages': 74 'a|lib/test.html.messages':
76 'warning: Only one "application/dart" script tag per document is' 75 'warning: Only one "application/dart" script tag per document is'
77 ' allowed. (lib/test.html 1 0)', 76 ' allowed. (lib/test.html 1 0)',
78 }); 77 });
79 78
80 _testLinter('tags inside elements', { 79 _testLinter('tags inside elements', {
81 'a|web/test.html': '<!DOCTYPE html><html>' 80 'a|web/test.html': '<!DOCTYPE html><html>'
82 '<polymer-element name="x-a">' 81 '<polymer-element name="x-a">'
83 '<script type="application/dart" src="a.dart">' 82 '<script type="application/dart" src="a.dart">'
84 '</script>' 83 '</script>'
85 '</polymer-element>\n' 84 '</polymer-element>\n'
86 '<script type="application/dart" src="b.dart">' 85 '<script type="application/dart" src="b.dart">'
87 '</script>' 86 '</script>'
88 '<script src="packages/browser/dart.js"></script>' 87 '<script src="packages/browser/dart.js"></script>'
89 }, { 88 }, {
90 'a|web/test.html.messages': 89 'a|web/test.html.messages':
91 'warning: Only one "application/dart" script tag per document is' 90 'warning: Only one "application/dart" script tag per document is'
92 ' allowed. (web/test.html 1 0)', 91 ' allowed. (web/test.html 1 0)',
93 }); 92 });
94 }); 93 });
95 94
96 group('doctype warning', () { 95 group('doctype warning', () {
97 _testLinter('in web', { 96 _testLinter('in web', {
98 'a|web/test.html': '<html></html>', 97 'a|web/test.html': '<html></html>',
99 }, { 98 }, {
100 'a|web/test.html.messages': 99 'a|web/test.html.messages':
101 'warning: Unexpected start tag (html). Expected DOCTYPE. ' 100 'warning: Unexpected start tag (html). Expected DOCTYPE. '
102 '(web/test.html 0 0)\n' 101 '(web/test.html 0 0)\n'
103 'error: $USE_INIT_DART\n' 102 'error: $USE_INIT_DART',
104 'error: $USE_DART_JS',
105 }); 103 });
106 104
107 _testLinter('in lib', { 105 _testLinter('in lib', {
108 'a|lib/test.html': '<html></html>', 106 'a|lib/test.html': '<html></html>',
109 }, { 107 }, {
110 'a|lib/test.html.messages': '', 108 'a|lib/test.html.messages': '',
111 }); 109 });
112 }); 110 });
113 111
114 group('duplicate polymer-elements,', () { 112 group('duplicate polymer-elements,', () {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 </polymer-element> 352 </polymer-element>
355 '''.replaceAll(' ', ''), 353 '''.replaceAll(' ', ''),
356 }, { 354 }, {
357 'a|lib/test.html.messages': 355 'a|lib/test.html.messages':
358 'warning: Invalid event handler body "bar()". Declare a method ' 356 'warning: Invalid event handler body "bar()". Declare a method '
359 'in your custom element "void handlerName(event, detail, target)" ' 357 'in your custom element "void handlerName(event, detail, target)" '
360 'and use the form on-foo="handlerName". ' 358 'and use the form on-foo="handlerName". '
361 '(lib/test.html 1 33)' 359 '(lib/test.html 1 33)'
362 }); 360 });
363 361
364 _testLinter('on-foo-bar is no longer supported', { 362 _testLinter('on-foo-bar is supported as a custom event name', {
365 'a|lib/test.html': '''<html><body> 363 'a|lib/test.html': '''<html><body>
366 <polymer-element name="x-a"><div on-foo-bar="quux"></div> 364 <polymer-element name="x-a"><div on-foo-bar="quux"></div>
367 </polymer-element> 365 </polymer-element>
368 '''.replaceAll(' ', ''), 366 '''.replaceAll(' ', ''),
369 }, { 367 }, {});
370 'a|lib/test.html.messages':
371 'warning: Invalid event name "on-foo-bar". After the "on-" the '
372 'event name should not use dashes. For example use "on-fooBar" or '
373 '"on-foobar" (both forms are equivalent in HTML). '
374 '(lib/test.html 1 33)'
375 });
376 }); 368 });
377 369
378 group('using custom tags', () { 370 group('using custom tags', () {
379 _testLinter('tag exists (x-tag)', { 371 _testLinter('tag exists (x-tag)', {
380 'a|lib/test.html': '<x-foo></x-foo>', 372 'a|lib/test.html': '<x-foo></x-foo>',
381 }, { 373 }, {
382 'a|lib/test.html.messages': 374 'a|lib/test.html.messages':
383 'warning: definition for Polymer element with tag name "x-foo" not ' 375 'warning: definition for Polymer element with tag name "x-foo" not '
384 'found. (lib/test.html 0 0)' 376 'found. (lib/test.html 0 0)'
385 }); 377 });
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 516
525 517
526 _testFormatter(String kind, String message, Span span) { 518 _testFormatter(String kind, String message, Span span) {
527 var formattedMessage = '$kind: $message'; 519 var formattedMessage = '$kind: $message';
528 if (span != null) { 520 if (span != null) {
529 formattedMessage = '$formattedMessage ' 521 formattedMessage = '$formattedMessage '
530 '(${span.sourceUrl} ${span.start.line} ${span.start.column})'; 522 '(${span.sourceUrl} ${span.start.line} ${span.start.column})';
531 } 523 }
532 return formattedMessage; 524 return formattedMessage;
533 } 525 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698