| 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 library analyzer.test.src.summary.summary_test; | 5 library analyzer.test.src.summary.summary_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 * strings containing comments, nested comments, etc. | 234 * strings containing comments, nested comments, etc. |
| 235 */ | 235 */ |
| 236 void checkDocumentationComment( | 236 void checkDocumentationComment( |
| 237 UnlinkedDocumentationComment documentationComment, String text) { | 237 UnlinkedDocumentationComment documentationComment, String text) { |
| 238 expect(documentationComment, isNotNull); | 238 expect(documentationComment, isNotNull); |
| 239 int commentStart = text.indexOf('/*'); | 239 int commentStart = text.indexOf('/*'); |
| 240 expect(commentStart, isNot(-1)); | 240 expect(commentStart, isNot(-1)); |
| 241 int commentEnd = text.indexOf('*/'); | 241 int commentEnd = text.indexOf('*/'); |
| 242 expect(commentEnd, isNot(-1)); | 242 expect(commentEnd, isNot(-1)); |
| 243 commentEnd += 2; | 243 commentEnd += 2; |
| 244 String expectedCommentText = text.substring(commentStart, commentEnd); | 244 String expectedCommentText = |
| 245 text.substring(commentStart, commentEnd).replaceAll('\r\n', '\n'); |
| 245 expect(documentationComment.text, expectedCommentText); | 246 expect(documentationComment.text, expectedCommentText); |
| 247 expect(documentationComment.offset, commentStart); |
| 248 expect(documentationComment.length, commentEnd - commentStart); |
| 246 } | 249 } |
| 247 | 250 |
| 248 /** | 251 /** |
| 249 * Verify that the given [typeRef] represents the type `dynamic`. | 252 * Verify that the given [typeRef] represents the type `dynamic`. |
| 250 */ | 253 */ |
| 251 void checkDynamicTypeRef(UnlinkedTypeRef typeRef) { | 254 void checkDynamicTypeRef(UnlinkedTypeRef typeRef) { |
| 252 checkTypeRef(typeRef, null, null, null); | 255 checkTypeRef(typeRef, null, null, null); |
| 253 } | 256 } |
| 254 | 257 |
| 255 /** | 258 /** |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 | 870 |
| 868 class D {} | 871 class D {} |
| 869 class E {}'''; | 872 class E {}'''; |
| 870 UnlinkedClass cls = serializeClassText(text); | 873 UnlinkedClass cls = serializeClassText(text); |
| 871 expect(cls.documentationComment, isNotNull); | 874 expect(cls.documentationComment, isNotNull); |
| 872 checkDocumentationComment(cls.documentationComment, text); | 875 checkDocumentationComment(cls.documentationComment, text); |
| 873 } | 876 } |
| 874 | 877 |
| 875 test_class_documented_with_with_windows_line_endings() { | 878 test_class_documented_with_with_windows_line_endings() { |
| 876 String text = '/**\r\n * Docs\r\n */\r\nclass C {}'; | 879 String text = '/**\r\n * Docs\r\n */\r\nclass C {}'; |
| 877 String convertedText = text.replaceAll('\r\n', '\n'); | |
| 878 UnlinkedClass cls = serializeClassText(text); | 880 UnlinkedClass cls = serializeClassText(text); |
| 879 expect(cls.documentationComment, isNotNull); | 881 expect(cls.documentationComment, isNotNull); |
| 880 checkDocumentationComment(cls.documentationComment, convertedText); | 882 checkDocumentationComment(cls.documentationComment, text); |
| 881 } | 883 } |
| 882 | 884 |
| 883 test_class_interface() { | 885 test_class_interface() { |
| 884 UnlinkedClass cls = serializeClassText(''' | 886 UnlinkedClass cls = serializeClassText(''' |
| 885 class C implements D {} | 887 class C implements D {} |
| 886 class D {} | 888 class D {} |
| 887 '''); | 889 '''); |
| 888 expect(cls.interfaces, hasLength(1)); | 890 expect(cls.interfaces, hasLength(1)); |
| 889 checkTypeRef(cls.interfaces[0], null, null, 'D'); | 891 checkTypeRef(cls.interfaces[0], null, null, 'D'); |
| 890 } | 892 } |
| (...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 UnlinkedVariable variable = | 2655 UnlinkedVariable variable = |
| 2654 serializeVariableText('int i;', variableName: 'i'); | 2656 serializeVariableText('int i;', variableName: 'i'); |
| 2655 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); | 2657 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); |
| 2656 } | 2658 } |
| 2657 | 2659 |
| 2658 test_varible_private() { | 2660 test_varible_private() { |
| 2659 serializeVariableText('int _i;', variableName: '_i'); | 2661 serializeVariableText('int _i;', variableName: '_i'); |
| 2660 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); | 2662 expect(unlinkedUnits[0].publicNamespace.names, isEmpty); |
| 2661 } | 2663 } |
| 2662 } | 2664 } |
| OLD | NEW |