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

Side by Side Diff: test/testing.dart

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
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'
24 show runtimeFilesForServerMode; 25 show runtimeFilesForServerMode;
25 import 'package:dev_compiler/src/info.dart'; 26 import 'package:dev_compiler/src/info.dart';
26 import 'package:dev_compiler/src/options.dart'; 27 import 'package:dev_compiler/src/options.dart';
27 import 'package:dev_compiler/src/utils.dart'; 28 import 'package:dev_compiler/src/utils.dart';
28 29
29 /// Shared analysis context used for compilation. 30 /// Shared analysis context used for compilation.
30 final realSdkContext = createAnalysisContextWithSources(new StrongModeOptions(), 31 final realSdkContext = createAnalysisContextWithSources(new StrongModeOptions(),
31 new SourceResolverOptions(dartSdkPath: getSdkDir().path)) 32 new SourceResolverOptions(
32 ..analysisOptions = (new AnalysisOptionsImpl()..cacheSize = 512); 33 dartSdkPath: getSdkDir().path,
34 customUrlMappings: {
35 'package:expect/expect.dart': _testCodegenPath('expect.dart'),
36 'package:async_helper/async_helper.dart':
37 _testCodegenPath('async_helper.dart'),
38 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'),
39 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart')
vsm 2015/07/27 21:03:24 Move out of sunflower? And perhaps all of these i
Jennifer Messerly 2015/07/27 21:46:35 Good ideas, filed https://github.com/dart-lang/dev
40 }))..analysisOptions = (new AnalysisOptionsImpl()..cacheSize = 512);
41
42 String _testCodegenPath(String p1, [String p2]) =>
43 path.join(testDirectory, 'codegen', p1, p2);
33 44
34 final String testDirectory = 45 final String testDirectory =
35 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); 46 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path);
36 47
37 class _TestUtils {} 48 class _TestUtils {}
38 49
39 /// Run the checker on a program with files contents as indicated in 50 /// Run the checker on a program with files contents as indicated in
40 /// [testFiles]. 51 /// [testFiles].
41 /// 52 ///
42 /// This function makes several assumptions to make it easier to describe error 53 /// This function makes several assumptions to make it easier to describe error
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 provider.newFile(key, value); 129 provider.newFile(key, value);
119 }); 130 });
120 return provider; 131 return provider;
121 } 132 }
122 133
123 class TestUriResolver extends ResourceUriResolver { 134 class TestUriResolver extends ResourceUriResolver {
124 final MemoryResourceProvider provider; 135 final MemoryResourceProvider provider;
125 TestUriResolver(provider) 136 TestUriResolver(provider)
126 : provider = provider, 137 : provider = provider,
127 super(provider); 138 super(provider);
128 resolveAbsolute(Uri uri) { 139
140 @override
141 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
129 if (uri.scheme == 'package') { 142 if (uri.scheme == 'package') {
130 return (provider.getResource('/packages/' + uri.path) as File) 143 return (provider.getResource('/packages/' + uri.path) as File)
131 .createSource(uri); 144 .createSource(uri);
132 } 145 }
133 return super.resolveAbsolute(uri); 146 return super.resolveAbsolute(uri, actualUri);
134 } 147 }
135 } 148 }
136 149
137 class _ExpectedErrorVisitor extends UnifyingAstVisitor { 150 class _ExpectedErrorVisitor extends UnifyingAstVisitor {
138 final Set<AnalysisError> _actualErrors; 151 final Set<AnalysisError> _actualErrors;
139 CompilationUnit _unit; 152 CompilationUnit _unit;
140 String _unitSourceCode; 153 String _unitSourceCode;
141 154
142 _ExpectedErrorVisitor(List<AnalysisError> actualErrors) 155 _ExpectedErrorVisitor(List<AnalysisError> actualErrors)
143 : _actualErrors = new Set.from(actualErrors); 156 : _actualErrors = new Set.from(actualErrors);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 expect(tokens[1], "should", reason: 'invalid error descriptor'); 268 expect(tokens[1], "should", reason: 'invalid error descriptor');
256 expect(tokens[2], "be", reason: 'invalid error descriptor'); 269 expect(tokens[2], "be", reason: 'invalid error descriptor');
257 if (tokens[0] == "pass") return null; 270 if (tokens[0] == "pass") return null;
258 // TODO(leafp) For now, we just use whatever the current expectation is, 271 // TODO(leafp) For now, we just use whatever the current expectation is,
259 // eventually we could do more automated reporting here. 272 // eventually we could do more automated reporting here.
260 return _parse(tokens[0]); 273 return _parse(tokens[0]);
261 } 274 }
262 275
263 String toString() => '$level $typeName'; 276 String toString() => '$level $typeName';
264 } 277 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698