OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 compiler_helper; | 5 library compiler_helper; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 import 'package:compiler/src/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 trustTypeAnnotations: trustTypeAnnotations, | 104 trustTypeAnnotations: trustTypeAnnotations, |
105 expectedErrors: expectedErrors, | 105 expectedErrors: expectedErrors, |
106 expectedWarnings: expectedWarnings); | 106 expectedWarnings: expectedWarnings); |
107 compiler.registerSource(uri, code); | 107 compiler.registerSource(uri, code); |
108 return compiler; | 108 return compiler; |
109 } | 109 } |
110 | 110 |
111 Future<String> compileAll(String code, | 111 Future<String> compileAll(String code, |
112 {Map<String, String> coreSource, | 112 {Map<String, String> coreSource, |
113 bool disableInlining: true, | 113 bool disableInlining: true, |
| 114 bool trustTypeAnnotations: false, |
114 bool minify: false, | 115 bool minify: false, |
115 int expectedErrors, | 116 int expectedErrors, |
116 int expectedWarnings}) { | 117 int expectedWarnings}) { |
117 Uri uri = new Uri(scheme: 'source'); | 118 Uri uri = new Uri(scheme: 'source'); |
118 MockCompiler compiler = compilerFor( | 119 MockCompiler compiler = compilerFor( |
119 code, uri, coreSource: coreSource, disableInlining: disableInlining, | 120 code, uri, coreSource: coreSource, disableInlining: disableInlining, |
120 minify: minify, expectedErrors: expectedErrors, | 121 minify: minify, expectedErrors: expectedErrors, |
| 122 trustTypeAnnotations: trustTypeAnnotations, |
121 expectedWarnings: expectedWarnings); | 123 expectedWarnings: expectedWarnings); |
122 return compiler.runCompiler(uri).then((_) { | 124 return compiler.runCompiler(uri).then((_) { |
123 Expect.isFalse(compiler.compilationFailed, | 125 Expect.isFalse(compiler.compilationFailed, |
124 'Unexpected compilation error(s): ${compiler.errors}'); | 126 'Unexpected compilation error(s): ${compiler.errors}'); |
125 return compiler.assembledCode; | 127 return compiler.assembledCode; |
126 }); | 128 }); |
127 } | 129 } |
128 | 130 |
129 Future compileAndCheck(String code, | 131 Future compileAndCheck(String code, |
130 String name, | 132 String name, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 253 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
252 final spaceRe = new RegExp('\\s+'); | 254 final spaceRe = new RegExp('\\s+'); |
253 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 255 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
254 if (shouldMatch) { | 256 if (shouldMatch) { |
255 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 257 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
256 } else { | 258 } else { |
257 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 259 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
258 } | 260 } |
259 }); | 261 }); |
260 } | 262 } |
OLD | NEW |