| 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("../../../lib/compiler/implementation/elements/elements.dart", prefix: "
lego"); | 10 #import("../../../lib/compiler/implementation/elements/elements.dart", prefix: "
lego"); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 String compileAll(String code) { | 41 String compileAll(String code) { |
| 42 Uri uri = new Uri.fromComponents(scheme: 'source'); | 42 Uri uri = new Uri.fromComponents(scheme: 'source'); |
| 43 MockCompiler compiler = compilerFor(code, uri); | 43 MockCompiler compiler = compilerFor(code, uri); |
| 44 compiler.runCompiler(uri); | 44 compiler.runCompiler(uri); |
| 45 Expect.isFalse(compiler.compilationFailed, | 45 Expect.isFalse(compiler.compilationFailed, |
| 46 'Unexpected compilation error'); | 46 'Unexpected compilation error'); |
| 47 return compiler.assembledCode; | 47 return compiler.assembledCode; |
| 48 } | 48 } |
| 49 | 49 |
| 50 Dynamic compileAndCheck(String code, | 50 dynamic compileAndCheck(String code, |
| 51 String name, | 51 String name, |
| 52 check(MockCompiler compiler, lego.Element element)) { | 52 check(MockCompiler compiler, lego.Element element)) { |
| 53 Uri uri = new Uri.fromComponents(scheme: 'source'); | 53 Uri uri = new Uri.fromComponents(scheme: 'source'); |
| 54 MockCompiler compiler = compilerFor(code, uri); | 54 MockCompiler compiler = compilerFor(code, uri); |
| 55 compiler.runCompiler(uri); | 55 compiler.runCompiler(uri); |
| 56 lego.Element element = findElement(compiler, name); | 56 lego.Element element = findElement(compiler, name); |
| 57 return check(compiler, element); | 57 return check(compiler, element); |
| 58 } | 58 } |
| 59 | 59 |
| 60 lego.Element findElement(compiler, String name) { | 60 lego.Element findElement(compiler, String name) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 87 '"$generated" does not match /$regexp/'); | 87 '"$generated" does not match /$regexp/'); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void compileAndDoNotMatch(String code, String entry, RegExp regexp) { | 90 void compileAndDoNotMatch(String code, String entry, RegExp regexp) { |
| 91 String generated = compile(code, entry); | 91 String generated = compile(code, entry); |
| 92 Expect.isFalse(regexp.hasMatch(generated), | 92 Expect.isFalse(regexp.hasMatch(generated), |
| 93 '"$generated" has a match in /$regexp/'); | 93 '"$generated" has a match in /$regexp/'); |
| 94 } | 94 } |
| 95 | 95 |
| 96 int length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; | 96 int length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; |
| OLD | NEW |