| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return element; | 71 return element; |
| 72 } | 72 } |
| 73 | 73 |
| 74 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; | 74 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; |
| 75 | 75 |
| 76 String getIntTypeCheck(String variable) { | 76 String getIntTypeCheck(String variable) { |
| 77 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)\\)"; | 77 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)\\)"; |
| 78 } | 78 } |
| 79 | 79 |
| 80 String getNumberTypeCheck(String variable) { | 80 String getNumberTypeCheck(String variable) { |
| 81 return "\\(typeof $variable ?!== ?'number'\\)"; | 81 return """\\(typeof $variable ?!== ?"number"\\)"""; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool checkNumberOfMatches(Iterator it, int nb) { | 84 bool checkNumberOfMatches(Iterator it, int nb) { |
| 85 for (int i = 0; i < nb; i++) { | 85 for (int i = 0; i < nb; i++) { |
| 86 Expect.isTrue(it.hasNext, "Found less than $nb matches"); | 86 Expect.isTrue(it.hasNext, "Found less than $nb matches"); |
| 87 it.next(); | 87 it.next(); |
| 88 } | 88 } |
| 89 Expect.isFalse(it.hasNext, "Found more than $nb matches"); | 89 Expect.isFalse(it.hasNext, "Found more than $nb matches"); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 119 final xRe = new RegExp('\\bx\\b'); | 119 final xRe = new RegExp('\\bx\\b'); |
| 120 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 120 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 121 final spaceRe = new RegExp('\\s+'); | 121 final spaceRe = new RegExp('\\s+'); |
| 122 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 122 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 123 if (shouldMatch) { | 123 if (shouldMatch) { |
| 124 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 124 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 125 } else { | 125 } else { |
| 126 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 126 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | |
| OLD | NEW |