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

Side by Side Diff: pkg/analyzer/test/src/abstract_single_unit.dart

Issue 1827293002: Use AbstractSingleUnitTest, so MockSdk in resynthesize tests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 test.services.src.index.abstract_single_file; 5 library test.services.src.index.abstract_single_file;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/element/element.dart'; 8 import 'package:analyzer/dart/element/element.dart';
9 import 'package:analyzer/src/dart/ast/utilities.dart'; 9 import 'package:analyzer/src/dart/ast/utilities.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
11 import 'package:analyzer/src/generated/java_engine.dart'; 11 import 'package:analyzer/src/generated/java_engine.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
14 14
15 import 'context/abstract_context.dart'; 15 import 'context/abstract_context.dart';
16 16
17 class AbstractSingleUnitTest extends AbstractContextTest { 17 class AbstractSingleUnitTest extends AbstractContextTest {
18 bool verifyNoTestUnitErrors = true; 18 bool verifyNoTestUnitErrors = true;
19 19
20 String testCode; 20 String testCode;
21 String testFile = '/test.dart'; 21 String testFile = '/test.dart';
22 Source testSource; 22 Source testSource;
23 CompilationUnit testUnit; 23 CompilationUnit testUnit;
24 CompilationUnitElement testUnitElement; 24 CompilationUnitElement testUnitElement;
25 LibraryElement testLibraryElement; 25 LibraryElement testLibraryElement;
26 26
27 void addTestSource(String code, [Uri uri]) { 27 Source addTestSource(String code, [Uri uri]) {
28 testCode = code; 28 testCode = code;
29 testSource = addSource(testFile, code); 29 testSource = addSource(testFile, code);
30 return testSource;
30 } 31 }
31 32
32 void assertNoErrorsInSource(Source source) { 33 void assertNoErrorsInSource(Source source) {
33 List<AnalysisError> errors = context.getErrors(source).errors; 34 List<AnalysisError> errors = context.getErrors(source).errors;
34 expect(errors, isEmpty); 35 expect(errors, isEmpty);
35 } 36 }
36 37
37 Element findElement(String name, [ElementKind kind]) { 38 Element findElement(String name, [ElementKind kind]) {
38 return findChildElement(testUnitElement, name, kind); 39 return findChildElement(testUnitElement, name, kind);
39 } 40 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void resolveTestUnit(String code) { 102 void resolveTestUnit(String code) {
102 addTestSource(code); 103 addTestSource(code);
103 testUnit = resolveLibraryUnit(testSource); 104 testUnit = resolveLibraryUnit(testSource);
104 if (verifyNoTestUnitErrors) { 105 if (verifyNoTestUnitErrors) {
105 assertNoErrorsInSource(testSource); 106 assertNoErrorsInSource(testSource);
106 } 107 }
107 testUnitElement = testUnit.element; 108 testUnitElement = testUnit.element;
108 testLibraryElement = testUnitElement.library; 109 testLibraryElement = testUnitElement.library;
109 } 110 }
110 } 111 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698