| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 | 4 |
| 5 // TODO(jmesserly): this file needs to be refactored, it's a port from | 5 // TODO(jmesserly): this file needs to be refactored, it's a port from |
| 6 // package:dev_compiler's tests | 6 // package:dev_compiler's tests |
| 7 library test.src.task.strong.strong_test_helper; | 7 library test.src.task.strong.strong_test_helper; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // Use error marker found in an immediately preceding comment, | 166 // Use error marker found in an immediately preceding comment, |
| 167 // and attach it to the outermost expression that starts at that token. | 167 // and attach it to the outermost expression that starts at that token. |
| 168 if (comment != null) { | 168 if (comment != null) { |
| 169 while (comment.next != null) { | 169 while (comment.next != null) { |
| 170 comment = comment.next; | 170 comment = comment.next; |
| 171 } | 171 } |
| 172 if (comment.end == token.offset && node.parent.beginToken != token) { | 172 if (comment.end == token.offset && node.parent.beginToken != token) { |
| 173 var commentText = '$comment'; | 173 var commentText = '$comment'; |
| 174 var start = commentText.lastIndexOf('/*'); | 174 var start = commentText.lastIndexOf('/*'); |
| 175 var end = commentText.lastIndexOf('*/'); | 175 var end = commentText.lastIndexOf('*/'); |
| 176 if (start != -1 && end != -1) { | 176 if (start != -1 && |
| 177 end != -1 && |
| 178 !commentText.startsWith('/*<', start) && |
| 179 !commentText.startsWith('/*=', start)) { |
| 177 expect(start, lessThan(end)); | 180 expect(start, lessThan(end)); |
| 178 var errors = commentText.substring(start + 2, end).split(','); | 181 var errors = commentText.substring(start + 2, end).split(','); |
| 179 var expectations = | 182 var expectations = |
| 180 errors.map(_ErrorExpectation.parse).where((x) => x != null); | 183 errors.map(_ErrorExpectation.parse).where((x) => x != null); |
| 181 | 184 |
| 182 for (var e in expectations) _expectError(node, e); | 185 for (var e in expectations) { |
| 186 _expectError(node, e); |
| 187 } |
| 183 } | 188 } |
| 184 } | 189 } |
| 185 } | 190 } |
| 186 return super.visitNode(node); | 191 return super.visitNode(node); |
| 187 } | 192 } |
| 188 | 193 |
| 189 void _expectError(AstNode node, _ErrorExpectation expected) { | 194 void _expectError(AstNode node, _ErrorExpectation expected) { |
| 190 // See if we can find the expected error in our actual errors | 195 // See if we can find the expected error in our actual errors |
| 191 for (var actual in _actualErrors) { | 196 for (var actual in _actualErrors) { |
| 192 if (actual.offset == node.offset && actual.length == node.length) { | 197 if (actual.offset == node.offset && actual.length == node.length) { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 if (levelName == 'warning') return _MAGENTA_COLOR; | 509 if (levelName == 'warning') return _MAGENTA_COLOR; |
| 505 if (levelName == 'info') return _CYAN_COLOR; | 510 if (levelName == 'info') return _CYAN_COLOR; |
| 506 return null; | 511 return null; |
| 507 } | 512 } |
| 508 | 513 |
| 509 const String _RED_COLOR = '\u001b[31m'; | 514 const String _RED_COLOR = '\u001b[31m'; |
| 510 const String _MAGENTA_COLOR = '\u001b[35m'; | 515 const String _MAGENTA_COLOR = '\u001b[35m'; |
| 511 const String _CYAN_COLOR = '\u001b[36m'; | 516 const String _CYAN_COLOR = '\u001b[36m'; |
| 512 const String GREEN_COLOR = '\u001b[32m'; | 517 const String GREEN_COLOR = '\u001b[32m'; |
| 513 const String NO_COLOR = '\u001b[0m'; | 518 const String NO_COLOR = '\u001b[0m'; |
| OLD | NEW |