| 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 10 matching lines...) Expand all Loading... |
| 21 import 'package:dev_compiler/strong_mode.dart'; | 21 import 'package:dev_compiler/strong_mode.dart'; |
| 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( | 31 final AnalysisContext realSdkContext = () { |
| 32 new StrongModeOptions(), | 32 var context = createAnalysisContextWithSources( |
| 33 new SourceResolverOptions( | 33 new StrongModeOptions(), |
| 34 dartSdkPath: getSdkDir().path, | 34 new SourceResolverOptions( |
| 35 customUrlMappings: { | 35 dartSdkPath: getSdkDir().path, |
| 36 'package:expect/expect.dart': _testCodegenPath('expect.dart'), | 36 customUrlMappings: { |
| 37 'package:async_helper/async_helper.dart': | 37 'package:expect/expect.dart': _testCodegenPath('expect.dart'), |
| 38 _testCodegenPath('async_helper.dart'), | 38 'package:async_helper/async_helper.dart': |
| 39 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'), | 39 _testCodegenPath('async_helper.dart'), |
| 40 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart') | 40 'package:unittest/unittest.dart': _testCodegenPath('unittest.dart'), |
| 41 }))..analysisOptions.cacheSize = 512; | 41 'package:dom/dom.dart': _testCodegenPath('sunflower', 'dom.dart') |
| 42 })); |
| 43 (context.analysisOptions as AnalysisOptionsImpl).cacheSize = 512; |
| 44 return context; |
| 45 }(); |
| 42 | 46 |
| 43 String _testCodegenPath(String p1, [String p2]) => | 47 String _testCodegenPath(String p1, [String p2]) => |
| 44 path.join(testDirectory, 'codegen', p1, p2); | 48 path.join(testDirectory, 'codegen', p1, p2); |
| 45 | 49 |
| 46 final String testDirectory = | 50 final String testDirectory = |
| 47 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); | 51 path.dirname((reflectClass(_TestUtils).owner as LibraryMirror).uri.path); |
| 48 | 52 |
| 49 class _TestUtils {} | 53 class _TestUtils {} |
| 50 | 54 |
| 51 /// Run the checker on a program with files contents as indicated in | 55 /// Run the checker on a program with files contents as indicated in |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 expect(tokens[1], "should", reason: 'invalid error descriptor'); | 271 expect(tokens[1], "should", reason: 'invalid error descriptor'); |
| 268 expect(tokens[2], "be", reason: 'invalid error descriptor'); | 272 expect(tokens[2], "be", reason: 'invalid error descriptor'); |
| 269 if (tokens[0] == "pass") return null; | 273 if (tokens[0] == "pass") return null; |
| 270 // TODO(leafp) For now, we just use whatever the current expectation is, | 274 // TODO(leafp) For now, we just use whatever the current expectation is, |
| 271 // eventually we could do more automated reporting here. | 275 // eventually we could do more automated reporting here. |
| 272 return _parse(tokens[0]); | 276 return _parse(tokens[0]); |
| 273 } | 277 } |
| 274 | 278 |
| 275 String toString() => '$level $typeName'; | 279 String toString() => '$level $typeName'; |
| 276 } | 280 } |
| OLD | NEW |