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