| 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'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 import 'package:dev_compiler/src/analysis_context.dart'; | 22 import 'package:dev_compiler/src/analysis_context.dart'; |
| 23 | 23 |
| 24 import 'package:dev_compiler/src/server/dependency_graph.dart' | 24 import 'package:dev_compiler/src/server/dependency_graph.dart' |
| 25 show runtimeFilesForServerMode; | 25 show runtimeFilesForServerMode; |
| 26 import 'package:dev_compiler/src/info.dart'; | 26 import 'package:dev_compiler/src/info.dart'; |
| 27 import 'package:dev_compiler/src/options.dart'; | 27 import 'package:dev_compiler/src/options.dart'; |
| 28 import 'package:dev_compiler/src/utils.dart'; | 28 import 'package:dev_compiler/src/utils.dart'; |
| 29 | 29 |
| 30 /// Shared analysis context used for compilation. | 30 /// Shared analysis context used for compilation. |
| 31 final realSdkContext = createAnalysisContextWithSources(new StrongModeOptions(), | 31 final realSdkContext = createAnalysisContextWithSources(new StrongModeOptions(), |
| 32 new SourceResolverOptions(dartSdkPath: getSdkDir().path)) | 32 new SourceResolverOptions( |
| 33 ..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') |
| 40 }))..analysisOptions = (new AnalysisOptionsImpl()..cacheSize = 512); |
| 41 |
| 42 String _testCodegenPath(String p1, [String p2]) => |
| 43 path.join(testDirectory, 'codegen', p1, p2); |
| 34 | 44 |
| 35 final String testDirectory = | 45 final String testDirectory = |
| 36 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); | 46 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); |
| 37 | 47 |
| 38 class _TestUtils {} | 48 class _TestUtils {} |
| 39 | 49 |
| 40 /// 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 |
| 41 /// [testFiles]. | 51 /// [testFiles]. |
| 42 /// | 52 /// |
| 43 /// 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 268 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
| 259 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 269 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
| 260 if (tokens[0] == "pass") return null; | 270 if (tokens[0] == "pass") return null; |
| 261 // 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, |
| 262 // eventually we could do more automated reporting here. | 272 // eventually we could do more automated reporting here. |
| 263 return _parse(tokens[0]); | 273 return _parse(tokens[0]); |
| 264 } | 274 } |
| 265 | 275 |
| 266 String toString() => '$level $typeName'; | 276 String toString() => '$level $typeName'; |
| 267 } | 277 } |
| OLD | NEW |