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, | |
115 bool minify: false, | 114 bool minify: false, |
116 int expectedErrors, | 115 int expectedErrors, |
117 int expectedWarnings}) { | 116 int expectedWarnings}) { |
118 Uri uri = new Uri(scheme: 'source'); | 117 Uri uri = new Uri(scheme: 'source'); |
119 MockCompiler compiler = compilerFor( | 118 MockCompiler compiler = compilerFor( |
120 code, uri, coreSource: coreSource, disableInlining: disableInlining, | 119 code, uri, coreSource: coreSource, disableInlining: disableInlining, |
121 minify: minify, expectedErrors: expectedErrors, | 120 minify: minify, expectedErrors: expectedErrors, |
122 trustTypeAnnotations: trustTypeAnnotations, | |
123 expectedWarnings: expectedWarnings); | 121 expectedWarnings: expectedWarnings); |
124 return compiler.runCompiler(uri).then((_) { | 122 return compiler.runCompiler(uri).then((_) { |
125 Expect.isFalse(compiler.compilationFailed, | 123 Expect.isFalse(compiler.compilationFailed, |
126 'Unexpected compilation error(s): ${compiler.errors}'); | 124 'Unexpected compilation error(s): ${compiler.errors}'); |
127 return compiler.assembledCode; | 125 return compiler.assembledCode; |
128 }); | 126 }); |
129 } | 127 } |
130 | 128 |
131 Future compileAndCheck(String code, | 129 Future compileAndCheck(String code, |
132 String name, | 130 String name, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 251 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
254 final spaceRe = new RegExp('\\s+'); | 252 final spaceRe = new RegExp('\\s+'); |
255 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 253 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
256 if (shouldMatch) { | 254 if (shouldMatch) { |
257 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 255 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
258 } else { | 256 } else { |
259 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 257 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
260 } | 258 } |
261 }); | 259 }); |
262 } | 260 } |
OLD | NEW |