Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Unified Diff: tests/compiler/dart2js/mirrors_metadata_test.dart

Issue 1805563002: Revert "Delete support for source mirrors" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/mirrors_lookup_test.dart ('k') | tests/compiler/dart2js/mirrors_mixin_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/mirrors_metadata_test.dart
diff --git a/tests/compiler/dart2js/mirrors_metadata_test.dart b/tests/compiler/dart2js/mirrors_metadata_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4097da71210bc314daa10a3147d461931557516d
--- /dev/null
+++ b/tests/compiler/dart2js/mirrors_metadata_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+import "package:async_helper/async_helper.dart";
+import 'dart:async';
+import 'mirror_system_helper.dart';
+
+Future validateDeclarationComment(String code,
+ String text,
+ String trimmedText,
+ bool isDocComment,
+ List<Symbol> declarationNames) {
+ return createMirrorSystem(code).then((mirrors) {
+ LibraryMirror library = mirrors.libraries[SOURCE_URI];
+ Expect.isNotNull(library);
+ for (Symbol declarationName in declarationNames) {
+ DeclarationMirror declaration = library.declarations[declarationName];
+ Expect.isNotNull(declaration);
+ List<InstanceMirror> metadata = declaration.metadata;
+ Expect.isNotNull(metadata);
+ Expect.equals(1, metadata.length);
+ Expect.isTrue(metadata[0] is CommentInstanceMirror);
+ CommentInstanceMirror commentMetadata = metadata[0];
+ Expect.equals(text, commentMetadata.text);
+ Expect.equals(trimmedText, commentMetadata.trimmedText);
+ Expect.equals(isDocComment, commentMetadata.isDocComment);
+ }
+ });
+}
+
+Future testDeclarationComment(String declaration,
+ List<Symbol> declarationNames) {
+ return Future.forEach([
+ () {
+ String text = 'Single line comment';
+ String comment = '// $text';
+ String code = '$comment\n$declaration';
+ return validateDeclarationComment(
+ code, comment, text, false, declarationNames);
+ },
+ () {
+ String text = 'Single line comment';
+ String comment = '/// $text';
+ String code = '$comment\n$declaration';
+ return validateDeclarationComment(
+ code, comment, text, true, declarationNames);
+ },
+ () {
+ String text = 'Multiline comment';
+ String comment = '/* $text*/';
+ String code = '$comment$declaration';
+ return validateDeclarationComment(
+ code, comment, text, false, declarationNames);
+ },
+ () {
+ String text = 'Multiline comment';
+ String comment = '/** $text*/';
+ String code = '$comment$declaration';
+ return validateDeclarationComment(
+ code, comment, text, true, declarationNames);
+ },
+ ], (f) => f());
+}
+
+void main() {
+ asyncTest(() => Future.forEach([
+ () => testDeclarationComment('var field;', [#field]),
+ () => testDeclarationComment('int field;', [#field]),
+ () => testDeclarationComment('int field = 0;', [#field]),
+ () => testDeclarationComment('int field1, field2;', [#field1, #field2]),
+ () => testDeclarationComment('final field = 0;', [#field]),
+ () => testDeclarationComment('final int field = 0;', [#field]),
+ () => testDeclarationComment('final field1 = 0, field2 = 0;',
+ [#field1, #field2]),
+ () => testDeclarationComment('final int field1 = 0, field2 = 0;',
+ [#field1, #field2]),
+ () => testDeclarationComment('const field = 0;', [#field]),
+ () => testDeclarationComment('const int field = 0;', [#field]),
+ () => testDeclarationComment('const field1 = 0, field2 = 0;',
+ [#field1, #field2]),
+ () => testDeclarationComment('const int field1 = 0, field2 = 0;',
+ [#field1, #field2]),
+ ], (f) => f()));
+}
« no previous file with comments | « tests/compiler/dart2js/mirrors_lookup_test.dart ('k') | tests/compiler/dart2js/mirrors_mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698