| OLD | NEW | 
| (Empty) |  | 
 |   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 | 
 |   3 // BSD-style license that can be found in the LICENSE file. | 
 |   4  | 
 |   5 // Helper class for writing compiler tests. | 
 |   6 library trydart.compiler_test_case; | 
 |   7  | 
 |   8 import 'dart:async' show | 
 |   9     Future; | 
 |  10  | 
 |  11 export 'dart:async' show | 
 |  12     Future; | 
 |  13  | 
 |  14 import 'package:async_helper/async_helper.dart' show | 
 |  15     asyncTest; | 
 |  16  | 
 |  17 import '../../compiler/dart2js/compiler_helper.dart' show | 
 |  18     MockCompiler, | 
 |  19     compilerFor; | 
 |  20  | 
 |  21 export 'package:expect/expect.dart' show | 
 |  22     Expect; | 
 |  23  | 
 |  24 const String SCHEME = 'org.trydart.compiler-test-case'; | 
 |  25  | 
 |  26 Uri customUri(String path) => Uri.parse('$SCHEME://$path'); | 
 |  27  | 
 |  28 Future runTests(List<CompilerTest> tests) { | 
 |  29   asyncTest(() => Future.forEach(tests, runTest)); | 
 |  30 } | 
 |  31  | 
 |  32 Future runTest(CompilerTestCase test) { | 
 |  33   print('\n{{{\n$test\n\n=== Test Output:\n'); | 
 |  34   return test.run().then((_) { | 
 |  35   print('}}}'); | 
 |  36   }); | 
 |  37 } | 
 |  38  | 
 |  39 abstract class CompilerTestCase { | 
 |  40   final String source; | 
 |  41  | 
 |  42   final Uri scriptUri; | 
 |  43  | 
 |  44   final MockCompiler compiler; | 
 |  45  | 
 |  46   Future<LibraryElement> mainAppCache; | 
 |  47  | 
 |  48   CompilerTestCase.init(this.source, this.scriptUri, this.compiler); | 
 |  49  | 
 |  50   CompilerTestCase.intermediate(String source, Uri scriptUri) | 
 |  51       : this.init(source, scriptUri, compilerFor(source, scriptUri)); | 
 |  52  | 
 |  53   CompilerTestCase(String source, [String path]) | 
 |  54       : this.intermediate(source, customUri(path == null ? 'main.dart' : path)); | 
 |  55  | 
 |  56   Future<LibraryElement> get mainApp { | 
 |  57     if (mainAppCache == null) { | 
 |  58       mainAppCache = compiler.libraryLoader.loadLibrary(scriptUri); | 
 |  59     } | 
 |  60     return mainAppCache; | 
 |  61   } | 
 |  62  | 
 |  63   Future run(); | 
 |  64  | 
 |  65   String toString() => source; | 
 |  66 } | 
| OLD | NEW |