| 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:async'; | 8 import 'dart:async'; |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 Expect.isNotNull(element, 'Could not locate $name'); | 151 Expect.isNotNull(element, 'Could not locate $name'); |
| 152 switch (how) { | 152 switch (how) { |
| 153 case 'exact': return new types.TypeMask.exact(element); | 153 case 'exact': return new types.TypeMask.exact(element); |
| 154 case 'nonNullExact': return new types.TypeMask.nonNullExact(element); | 154 case 'nonNullExact': return new types.TypeMask.nonNullExact(element); |
| 155 case 'subclass': return new types.TypeMask.subclass(element); | 155 case 'subclass': return new types.TypeMask.subclass(element); |
| 156 case 'nonNullSubclass': return new types.TypeMask.nonNullSubclass(element); | 156 case 'nonNullSubclass': return new types.TypeMask.nonNullSubclass(element); |
| 157 case 'subtype': return new types.TypeMask.subtype(element); | 157 case 'subtype': return new types.TypeMask.subtype(element); |
| 158 case 'nonNullSubtype': return new types.TypeMask.nonNullSubtype(element); | 158 case 'nonNullSubtype': return new types.TypeMask.nonNullSubtype(element); |
| 159 } | 159 } |
| 160 Expect.fail('Unknown HType constructor $how'); | 160 Expect.fail('Unknown TypeMask constructor $how'); |
| 161 } | |
| 162 | |
| 163 ssa.HType findHType(compiler, String name, [String how = 'nonNullExact']) { | |
| 164 return new ssa.HType.fromMask(findTypeMask(compiler, name, how), compiler); | |
| 165 } | 161 } |
| 166 | 162 |
| 167 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; | 163 String anyIdentifier = "[a-zA-Z][a-zA-Z0-9]*"; |
| 168 | 164 |
| 169 String getIntTypeCheck(String variable) { | 165 String getIntTypeCheck(String variable) { |
| 170 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)|" | 166 return "\\($variable ?!== ?\\($variable ?\\| ?0\\)|" |
| 171 "\\($variable ?>>> ?0 ?!== ?$variable"; | 167 "\\($variable ?>>> ?0 ?!== ?$variable"; |
| 172 } | 168 } |
| 173 | 169 |
| 174 String getNumberTypeCheck(String variable) { | 170 String getNumberTypeCheck(String variable) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 final xRe = new RegExp('\\bx\\b'); | 210 final xRe = new RegExp('\\bx\\b'); |
| 215 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); | 211 regexp = regexp.replaceAll(xRe, '(?:$anyIdentifier)'); |
| 216 final spaceRe = new RegExp('\\s+'); | 212 final spaceRe = new RegExp('\\s+'); |
| 217 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); | 213 regexp = regexp.replaceAll(spaceRe, '(?:\\s*)'); |
| 218 if (shouldMatch) { | 214 if (shouldMatch) { |
| 219 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); | 215 Expect.isTrue(new RegExp(regexp).hasMatch(generated)); |
| 220 } else { | 216 } else { |
| 221 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); | 217 Expect.isFalse(new RegExp(regexp).hasMatch(generated)); |
| 222 } | 218 } |
| 223 } | 219 } |
| OLD | NEW |