| Index: pkg/analyzer/test/src/context/context_test.dart
|
| diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart
|
| index 81a0d50cd7ad33158305f9ab9ecdc5ba6e2324c5..698ddaf35cbed0035e1f2608a72cc819a123c1c7 100644
|
| --- a/pkg/analyzer/test/src/context/context_test.dart
|
| +++ b/pkg/analyzer/test/src/context/context_test.dart
|
| @@ -43,6 +43,7 @@ import '../../generated/engine_test.dart';
|
| import '../../generated/test_support.dart';
|
| import '../../reflective_tests.dart';
|
| import 'abstract_context.dart';
|
| +import 'package:html/dom.dart' show Document;
|
|
|
| main() {
|
| groupSep = ' | ';
|
| @@ -159,8 +160,8 @@ import 'libB.dart';''';
|
| expect(errors.length > 0, isTrue);
|
| }
|
|
|
| - void fail_computeErrors_html_none() {
|
| - Source source = addSource("/test.html", "<html></html>");
|
| + void test_computeErrors_html_none() {
|
| + Source source = addSource("/test.html", "<!DOCTYPE html><html></html>");
|
| List<AnalysisError> errors = context.computeErrors(source);
|
| expect(errors, hasLength(0));
|
| }
|
| @@ -332,7 +333,7 @@ class A {
|
| expect(errors, hasLength(0));
|
| }
|
|
|
| - void fail_getErrors_html_some() {
|
| + void test_getErrors_html_some() {
|
| Source source = addSource("/test.html", r'''
|
| <html><head>
|
| <script type='application/dart' src='test.dart'/>
|
| @@ -341,9 +342,8 @@ class A {
|
| expect(errorInfo, isNotNull);
|
| List<AnalysisError> errors = errorInfo.errors;
|
| expect(errors, hasLength(0));
|
| - context.computeErrors(source);
|
| - errors = errorInfo.errors;
|
| - expect(errors, hasLength(1));
|
| + errors = context.computeErrors(source);
|
| + expect(errors, hasLength(3));
|
| }
|
|
|
| void fail_getHtmlElement_html() {
|
| @@ -355,23 +355,26 @@ class A {
|
| expect(element, isNotNull);
|
| }
|
|
|
| - void fail_getHtmlFilesReferencing_library() {
|
| + void test_getHtmlFilesReferencing_library() {
|
| Source htmlSource = addSource("/test.html", r'''
|
| +<!DOCTYPE html>
|
| <html><head>
|
| <script type='application/dart' src='test.dart'/>
|
| <script type='application/dart' src='test.js'/>
|
| </head></html>''');
|
| Source librarySource = addSource("/test.dart", "library lib;");
|
| + context.computeLibraryElement(librarySource);
|
| List<Source> result = context.getHtmlFilesReferencing(librarySource);
|
| expect(result, hasLength(0));
|
| - context.parseHtmlUnit(htmlSource);
|
| + context.computeHtmlElement(htmlSource);
|
| result = context.getHtmlFilesReferencing(librarySource);
|
| expect(result, hasLength(1));
|
| expect(result[0], htmlSource);
|
| }
|
|
|
| - void fail_getHtmlFilesReferencing_part() {
|
| + void test_getHtmlFilesReferencing_part() {
|
| Source htmlSource = addSource("/test.html", r'''
|
| +<!DOCTYPE html>
|
| <html><head>
|
| <script type='application/dart' src='test.dart'/>
|
| <script type='application/dart' src='test.js'/>
|
| @@ -382,31 +385,31 @@ class A {
|
| context.computeLibraryElement(librarySource);
|
| List<Source> result = context.getHtmlFilesReferencing(partSource);
|
| expect(result, hasLength(0));
|
| - context.parseHtmlUnit(htmlSource);
|
| + context.computeHtmlElement(htmlSource);
|
| result = context.getHtmlFilesReferencing(partSource);
|
| expect(result, hasLength(1));
|
| expect(result[0], htmlSource);
|
| }
|
|
|
| - void fail_getHtmlSources() {
|
| + void test_getHtmlSources() {
|
| List<Source> sources = context.htmlSources;
|
| expect(sources, hasLength(0));
|
| Source source = addSource("/test.html", "");
|
| - context.computeKindOf(source);
|
| sources = context.htmlSources;
|
| expect(sources, hasLength(1));
|
| expect(sources[0], source);
|
| }
|
|
|
| - void fail_getLibrariesReferencedFromHtml() {
|
| + void test_getLibrariesReferencedFromHtml() {
|
| Source htmlSource = addSource("/test.html", r'''
|
| +<!DOCTYPE html>
|
| <html><head>
|
| <script type='application/dart' src='test.dart'/>
|
| <script type='application/dart' src='test.js'/>
|
| </head></html>''');
|
| Source librarySource = addSource("/test.dart", "library lib;");
|
| context.computeLibraryElement(librarySource);
|
| - context.parseHtmlUnit(htmlSource);
|
| + context.computeHtmlElement(htmlSource);
|
| List<Source> result = context.getLibrariesReferencedFromHtml(htmlSource);
|
| expect(result, hasLength(1));
|
| expect(result[0], librarySource);
|
| @@ -432,6 +435,12 @@ class A {
|
| fail("Implement this");
|
| }
|
|
|
| + void test_parseDocument() {
|
| + Source source = addSource("/lib.html", "<!DOCTYPE html><html></html>");
|
| + Document unit = context.parseDocument(source);
|
| + expect(unit, isNotNull);
|
| + }
|
| +
|
| void fail_parseHtmlUnit_noErrors() {
|
| Source source = addSource("/lib.html", "<html></html>");
|
| ht.HtmlUnit unit = context.parseHtmlUnit(source);
|
| @@ -443,6 +452,7 @@ class A {
|
| library lib;
|
| class ClassA {}''');
|
| Source source = addSource("/lib.html", r'''
|
| +<!DOCTYPE html>
|
| <html>
|
| <head>
|
| <script type='application/dart'>
|
|
|