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

Side by Side Diff: tests/compiler/dart2js/mirrors_metadata_test.dart

Issue 339563002: Remove scanBuiltinLibraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 4
5 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 import "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'dart:async'; 7 import 'dart:async';
8 import 'mirror_system_helper.dart'; 8 import 'mirror_system_helper.dart';
9 9
10 void validateDeclarationComment(String code, 10 Future validateDeclarationComment(String code,
11 String text, 11 String text,
12 String trimmedText, 12 String trimmedText,
13 bool isDocComment, 13 bool isDocComment,
14 List<Symbol> declarationNames) { 14 List<Symbol> declarationNames) {
15 asyncTest(() => createMirrorSystem(code).then((mirrors) { 15 return createMirrorSystem(code).then((mirrors) {
16 LibraryMirror library = mirrors.libraries[SOURCE_URI]; 16 LibraryMirror library = mirrors.libraries[SOURCE_URI];
17 Expect.isNotNull(library); 17 Expect.isNotNull(library);
18 for (Symbol declarationName in declarationNames) { 18 for (Symbol declarationName in declarationNames) {
19 DeclarationMirror declaration = library.declarations[declarationName]; 19 DeclarationMirror declaration = library.declarations[declarationName];
20 Expect.isNotNull(declaration); 20 Expect.isNotNull(declaration);
21 List<InstanceMirror> metadata = declaration.metadata; 21 List<InstanceMirror> metadata = declaration.metadata;
22 Expect.isNotNull(metadata); 22 Expect.isNotNull(metadata);
23 Expect.equals(1, metadata.length); 23 Expect.equals(1, metadata.length);
24 Expect.isTrue(metadata[0] is CommentInstanceMirror); 24 Expect.isTrue(metadata[0] is CommentInstanceMirror);
25 CommentInstanceMirror commentMetadata = metadata[0]; 25 CommentInstanceMirror commentMetadata = metadata[0];
26 Expect.equals(text, commentMetadata.text); 26 Expect.equals(text, commentMetadata.text);
27 Expect.equals(trimmedText, commentMetadata.trimmedText); 27 Expect.equals(trimmedText, commentMetadata.trimmedText);
28 Expect.equals(isDocComment, commentMetadata.isDocComment); 28 Expect.equals(isDocComment, commentMetadata.isDocComment);
29 } 29 }
30 })); 30 });
31 } 31 }
32 32
33 void testDeclarationComment(String declaration, List<Symbol> declarationNames) { 33 Future testDeclarationComment(String declaration,
34 String text = 'Single line comment'; 34 List<Symbol> declarationNames) {
35 String comment = '// $text'; 35 return Future.forEach([
36 String code = '$comment\n$declaration'; 36 () {
37 validateDeclarationComment(code, comment, text, false, declarationNames); 37 String text = 'Single line comment';
38 38 String comment = '// $text';
39 comment = '/// $text'; 39 String code = '$comment\n$declaration';
40 code = '$comment\n$declaration'; 40 return validateDeclarationComment(
41 validateDeclarationComment(code, comment, text, true, declarationNames); 41 code, comment, text, false, declarationNames);
42 42 },
43 text = 'Multiline comment'; 43 () {
44 comment = '/* $text*/'; 44 String text = 'Single line comment';
45 code = '$comment$declaration'; 45 String comment = '/// $text';
46 validateDeclarationComment(code, comment, text, false, declarationNames); 46 String code = '$comment\n$declaration';
47 47 return validateDeclarationComment(
48 comment = '/** $text*/'; 48 code, comment, text, true, declarationNames);
49 code = '$comment$declaration'; 49 },
50 validateDeclarationComment(code, comment, text, true, declarationNames); 50 () {
51 String text = 'Multiline comment';
52 String comment = '/* $text*/';
53 String code = '$comment$declaration';
54 return validateDeclarationComment(
55 code, comment, text, false, declarationNames);
56 },
57 () {
58 String text = 'Multiline comment';
59 String comment = '/** $text*/';
60 String code = '$comment$declaration';
61 return validateDeclarationComment(
62 code, comment, text, true, declarationNames);
63 },
64 ], (f) => f());
51 } 65 }
52 66
53 void main() { 67 void main() {
54 testDeclarationComment('var field;', [#field]); 68 asyncTest(() => Future.forEach([
55 testDeclarationComment('int field;', [#field]); 69 () => testDeclarationComment('var field;', [#field]),
56 testDeclarationComment('int field = 0;', [#field]); 70 () => testDeclarationComment('int field;', [#field]),
57 testDeclarationComment('int field1, field2;', [#field1, #field2]); 71 () => testDeclarationComment('int field = 0;', [#field]),
58 testDeclarationComment('final field = 0;', [#field]); 72 () => testDeclarationComment('int field1, field2;', [#field1, #field2]),
59 testDeclarationComment('final int field = 0;', [#field]); 73 () => testDeclarationComment('final field = 0;', [#field]),
60 testDeclarationComment('final field1 = 0, field2 = 0;', [#field1, #field2]); 74 () => testDeclarationComment('final int field = 0;', [#field]),
61 testDeclarationComment('final int field1 = 0, field2 = 0;', 75 () => testDeclarationComment('final field1 = 0, field2 = 0;',
62 [#field1, #field2]); 76 [#field1, #field2]),
63 testDeclarationComment('const field = 0;', [#field]); 77 () => testDeclarationComment('final int field1 = 0, field2 = 0;',
64 testDeclarationComment('const int field = 0;', [#field]); 78 [#field1, #field2]),
65 testDeclarationComment('const field1 = 0, field2 = 0;', [#field1, #field2]); 79 () => testDeclarationComment('const field = 0;', [#field]),
66 testDeclarationComment('const int field1 = 0, field2 = 0;', 80 () => testDeclarationComment('const int field = 0;', [#field]),
67 [#field1, #field2]); 81 () => testDeclarationComment('const field1 = 0, field2 = 0;',
82 [#field1, #field2]),
83 () => testDeclarationComment('const int field1 = 0, field2 = 0;',
84 [#field1, #field2]),
85 ], (f) => f()));
68 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698