| 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 // Test a sequence of modifications to hello-world which used to cause problems |
| 6 // on Try Dart. |
| 7 |
| 8 import 'dart:io' show |
| 9 Platform; |
| 10 |
| 11 import 'dart:async' show |
| 12 Future; |
| 13 |
| 14 import 'package:try/src/caching_compiler.dart' show |
| 15 reuseCompiler; |
| 16 |
| 17 import 'package:compiler/compiler.dart' as compiler; |
| 18 |
| 19 import 'package:async_helper/async_helper.dart' show |
| 20 asyncTest; |
| 21 |
| 22 import 'package:expect/expect.dart' show |
| 23 Expect; |
| 24 |
| 25 import '../memory_source_file_helper.dart' show |
| 26 MemorySourceFileProvider; |
| 27 |
| 28 import 'incremental_helper.dart'; |
| 29 |
| 30 var tests = { |
| 31 '/test1.dart': |
| 32 ''' |
| 33 var greeting = "Hello, World!"; |
| 34 |
| 35 void main() { |
| 36 print(greeting); |
| 37 } |
| 38 ''', |
| 39 '/test2.dart': |
| 40 ''' |
| 41 va greeting = "Hello, World!"; |
| 42 |
| 43 void main() { |
| 44 print(greeting); |
| 45 } |
| 46 ''', |
| 47 '/test3.dart': |
| 48 ''' |
| 49 greeting = "Hello, World!"; |
| 50 |
| 51 void main() { |
| 52 print(greeting); |
| 53 } |
| 54 ''', |
| 55 '/test4.dart': |
| 56 ''' |
| 57 in greeting = "Hello, World!"; |
| 58 |
| 59 void main() { |
| 60 print(greeting); |
| 61 } |
| 62 ''', |
| 63 '/test5.dart': |
| 64 ''' |
| 65 int greeting = "Hello, World!"; |
| 66 |
| 67 void main() { |
| 68 print(greeting); |
| 69 } |
| 70 ''', |
| 71 }; |
| 72 |
| 73 var testResults = { |
| 74 '/test1.dart': true, |
| 75 '/test2.dart': true, |
| 76 '/test3.dart': false, |
| 77 '/test4.dart': false, |
| 78 '/test5.dart': true, |
| 79 }; |
| 80 |
| 81 var cachedCompiler; |
| 82 |
| 83 main() { |
| 84 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| 85 Uri packageRoot = Uri.base.resolveUri( |
| 86 new Uri.file('${Platform.packageRoot}/')); |
| 87 MemorySourceFileProvider provider = |
| 88 new MemorySourceFileProvider(tests); |
| 89 asyncTest( |
| 90 () => runTests(libraryRoot, packageRoot, provider, INCREMENTAL_OPTIONS)); |
| 91 } |
| 92 |
| 93 Future runTests( |
| 94 Uri libraryRoot, |
| 95 Uri packageRoot, |
| 96 MemorySourceFileProvider provider, |
| 97 options) { |
| 98 return Future.forEach(tests.keys, (String testName) { |
| 99 cachedCompiler = reuseCompiler( |
| 100 diagnosticHandler: handler, |
| 101 inputProvider: provider, |
| 102 options: options, |
| 103 cachedCompiler: cachedCompiler, |
| 104 libraryRoot: libraryRoot, |
| 105 packageRoot: packageRoot); |
| 106 Uri testUri = Uri.parse('memory:$testName'); |
| 107 return cachedCompiler.run(testUri).then((bool success) { |
| 108 Expect.equals( |
| 109 testResults[testName], success, |
| 110 'Compilation unexpectedly ${success ? "succeed" : "failed"}.'); |
| 111 }); |
| 112 }); |
| 113 } |
| 114 |
| 115 void handler(Uri uri, |
| 116 int begin, |
| 117 int end, |
| 118 String message, |
| 119 compiler.Diagnostic kind) { |
| 120 if (kind != compiler.Diagnostic.VERBOSE_INFO) { |
| 121 print('$uri:$begin:$end:$message:$kind'); |
| 122 } |
| 123 } |
| OLD | NEW |