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 // Test constant folding. | 4 // Test constant folding. |
5 | 5 |
6 library compiler_helper; | 6 library compiler_helper; |
7 | 7 |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 export 'dart:uri' show Uri; | 9 export 'dart:uri' show Uri; |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 leg.CodegenWorkItem work = | 70 leg.CodegenWorkItem work = |
71 new leg.CodegenWorkItem(element, resolutionWork.resolutionTree, context); | 71 new leg.CodegenWorkItem(element, resolutionWork.resolutionTree, context); |
72 compiler.phase = Compiler.PHASE_COMPILING; | 72 compiler.phase = Compiler.PHASE_COMPILING; |
73 work.run(compiler, compiler.enqueuer.codegen); | 73 work.run(compiler, compiler.enqueuer.codegen); |
74 js.JavaScriptBackend backend = compiler.backend; | 74 js.JavaScriptBackend backend = compiler.backend; |
75 return backend.assembleCode(element); | 75 return backend.assembleCode(element); |
76 } | 76 } |
77 | 77 |
78 MockCompiler compilerFor(String code, Uri uri, | 78 MockCompiler compilerFor(String code, Uri uri, |
79 {bool analyzeAll: false, | 79 {bool analyzeAll: false, |
| 80 bool analyzeOnly: false, |
80 String coreSource: DEFAULT_CORELIB}) { | 81 String coreSource: DEFAULT_CORELIB}) { |
81 MockCompiler compiler = new MockCompiler( | 82 MockCompiler compiler = new MockCompiler( |
82 analyzeAll: analyzeAll, coreSource: coreSource); | 83 analyzeAll: analyzeAll, |
| 84 analyzeOnly: analyzeOnly, |
| 85 coreSource: coreSource); |
83 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code); | 86 compiler.sourceFiles[uri.toString()] = new SourceFile(uri.toString(), code); |
84 return compiler; | 87 return compiler; |
85 } | 88 } |
86 | 89 |
87 String compileAll(String code, {String coreSource: DEFAULT_CORELIB}) { | 90 String compileAll(String code, {String coreSource: DEFAULT_CORELIB}) { |
88 Uri uri = new Uri.fromComponents(scheme: 'source'); | 91 Uri uri = new Uri.fromComponents(scheme: 'source'); |
89 MockCompiler compiler = compilerFor(code, uri, coreSource: coreSource); | 92 MockCompiler compiler = compilerFor(code, uri, coreSource: coreSource); |
90 compiler.runCompiler(uri); | 93 compiler.runCompiler(uri); |
91 Expect.isFalse(compiler.compilationFailed, | 94 Expect.isFalse(compiler.compilationFailed, |
92 'Unexpected compilation error'); | 95 'Unexpected compilation error'); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 final xRe = new RegExp('\\bx\\b'); | 205 final xRe = new RegExp('\\bx\\b'); |
203 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 206 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
204 final spaceRe = new RegExp('\\s+'); | 207 final spaceRe = new RegExp('\\s+'); |
205 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 208 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
206 if (shouldMatch) { | 209 if (shouldMatch) { |
207 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 210 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
208 } else { | 211 } else { |
209 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 212 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
210 } | 213 } |
211 } | 214 } |
OLD | NEW |