| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dev_compiler.src.testing; | 5 library dev_compiler.src.testing; |
| 6 | 6 |
| 7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
| 9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
| 12 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; | 12 show AnalysisContext, AnalysisEngine, AnalysisOptionsImpl; |
| 13 import 'package:analyzer/src/generated/error.dart'; | 13 import 'package:analyzer/src/generated/error.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:cli_util/cli_util.dart' show getSdkDir; | 15 import 'package:cli_util/cli_util.dart' show getSdkDir; |
| 15 import 'package:logging/logging.dart'; | 16 import 'package:logging/logging.dart'; |
| 16 import 'package:path/path.dart' as path; | 17 import 'package:path/path.dart' as path; |
| 17 import 'package:source_span/source_span.dart'; | 18 import 'package:source_span/source_span.dart'; |
| 18 import 'package:test/test.dart'; | 19 import 'package:test/test.dart'; |
| 19 | 20 |
| 20 import 'package:dev_compiler/strong_mode.dart'; | 21 import 'package:dev_compiler/strong_mode.dart'; |
| 21 import 'package:dev_compiler/src/analysis_context.dart'; | 22 import 'package:dev_compiler/src/analysis_context.dart'; |
| 22 | 23 |
| 23 import 'package:dev_compiler/src/server/dependency_graph.dart' | 24 import 'package:dev_compiler/src/server/dependency_graph.dart' |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 provider.newFile(key, value); | 119 provider.newFile(key, value); |
| 119 }); | 120 }); |
| 120 return provider; | 121 return provider; |
| 121 } | 122 } |
| 122 | 123 |
| 123 class TestUriResolver extends ResourceUriResolver { | 124 class TestUriResolver extends ResourceUriResolver { |
| 124 final MemoryResourceProvider provider; | 125 final MemoryResourceProvider provider; |
| 125 TestUriResolver(provider) | 126 TestUriResolver(provider) |
| 126 : provider = provider, | 127 : provider = provider, |
| 127 super(provider); | 128 super(provider); |
| 128 resolveAbsolute(Uri uri) { | 129 |
| 130 @override |
| 131 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 129 if (uri.scheme == 'package') { | 132 if (uri.scheme == 'package') { |
| 130 return (provider.getResource('/packages/' + uri.path) as File) | 133 return (provider.getResource('/packages/' + uri.path) as File) |
| 131 .createSource(uri); | 134 .createSource(uri); |
| 132 } | 135 } |
| 133 return super.resolveAbsolute(uri); | 136 return super.resolveAbsolute(uri, actualUri); |
| 134 } | 137 } |
| 135 } | 138 } |
| 136 | 139 |
| 137 class _ExpectedErrorVisitor extends UnifyingAstVisitor { | 140 class _ExpectedErrorVisitor extends UnifyingAstVisitor { |
| 138 final Set<AnalysisError> _actualErrors; | 141 final Set<AnalysisError> _actualErrors; |
| 139 CompilationUnit _unit; | 142 CompilationUnit _unit; |
| 140 String _unitSourceCode; | 143 String _unitSourceCode; |
| 141 | 144 |
| 142 _ExpectedErrorVisitor(List<AnalysisError> actualErrors) | 145 _ExpectedErrorVisitor(List<AnalysisError> actualErrors) |
| 143 : _actualErrors = new Set.from(actualErrors); | 146 : _actualErrors = new Set.from(actualErrors); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 258 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
| 256 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 259 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
| 257 if (tokens[0] == "pass") return null; | 260 if (tokens[0] == "pass") return null; |
| 258 // TODO(leafp) For now, we just use whatever the current expectation is, | 261 // TODO(leafp) For now, we just use whatever the current expectation is, |
| 259 // eventually we could do more automated reporting here. | 262 // eventually we could do more automated reporting here. |
| 260 return _parse(tokens[0]); | 263 return _parse(tokens[0]); |
| 261 } | 264 } |
| 262 | 265 |
| 263 String toString() => '$level $typeName'; | 266 String toString() => '$level $typeName'; |
| 264 } | 267 } |
| OLD | NEW |