| 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 | 9 |
| 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" | 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar
t" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import "parser_helper.dart"; | 21 import "parser_helper.dart"; |
| 22 | 22 |
| 23 String compile(String code, {String entry: 'main', | 23 String compile(String code, {String entry: 'main', |
| 24 bool enableTypeAssertions: false, | 24 bool enableTypeAssertions: false, |
| 25 bool minify: false}) { | 25 bool minify: false}) { |
| 26 MockCompiler compiler = | 26 MockCompiler compiler = |
| 27 new MockCompiler(enableTypeAssertions: enableTypeAssertions, | 27 new MockCompiler(enableTypeAssertions: enableTypeAssertions, |
| 28 enableMinification: minify); | 28 enableMinification: minify); |
| 29 compiler.parseScript(code); | 29 compiler.parseScript(code); |
| 30 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); | 30 lego.Element element = compiler.mainApp.find(buildSourceString(entry)); |
| 31 if (element === null) return null; | 31 if (element == null) return null; |
| 32 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); | 32 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution); |
| 33 compiler.processQueue(compiler.enqueuer.resolution, element); | 33 compiler.processQueue(compiler.enqueuer.resolution, element); |
| 34 var context = new js.JavaScriptItemCompilationContext(); | 34 var context = new js.JavaScriptItemCompilationContext(); |
| 35 leg.WorkItem work = new leg.WorkItem(element, null, context); | 35 leg.WorkItem work = new leg.WorkItem(element, null, context); |
| 36 work.run(compiler, compiler.enqueuer.codegen); | 36 work.run(compiler, compiler.enqueuer.codegen); |
| 37 return compiler.enqueuer.codegen.lookupCode(element); | 37 return compiler.enqueuer.codegen.lookupCode(element); |
| 38 } | 38 } |
| 39 | 39 |
| 40 MockCompiler compilerFor(String code, Uri uri) { | 40 MockCompiler compilerFor(String code, Uri uri) { |
| 41 MockCompiler compiler = new MockCompiler(); | 41 MockCompiler compiler = new MockCompiler(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 117 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 118 final spaceRe = new RegExp('\\s+'); | 118 final spaceRe = new RegExp('\\s+'); |
| 119 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 119 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 120 if (shouldMatch) { | 120 if (shouldMatch) { |
| 121 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 121 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 122 } else { | 122 } else { |
| 123 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 123 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| OLD | NEW |