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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 years, 3 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 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart";
7 import 'dart:io'; 8 import 'dart:io';
8 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ; 10 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ;
10 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart'; 11 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart';
11 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart'; 12 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart';
12 import 'mock_compiler.dart'; 13 import 'mock_compiler.dart';
13 14
14 const String SOURCE = 'source'; 15 const String SOURCE = 'source';
15 Uri SOURCE_URI = new Uri(scheme: SOURCE, path: SOURCE); 16 Uri SOURCE_URI = new Uri(scheme: SOURCE, path: SOURCE);
16 17
17 MirrorSystem createMirrorSystem(String source) { 18 Future<MirrorSystem> createMirrorSystem(String source) {
18 MockCompiler compiler = new MockCompiler( 19 MockCompiler compiler = new MockCompiler(
19 analyzeOnly: true, 20 analyzeOnly: true,
20 analyzeAll: true, 21 analyzeAll: true,
21 preserveComments: true); 22 preserveComments: true);
22 compiler.registerSource(SOURCE_URI, source); 23 compiler.registerSource(SOURCE_URI, source);
23 compiler.librariesToAnalyzeWhenRun = <Uri>[SOURCE_URI]; 24 compiler.librariesToAnalyzeWhenRun = <Uri>[SOURCE_URI];
24 compiler.runCompiler(null); 25 return compiler.runCompiler(null).then((_) {
25 return new Dart2JsMirrorSystem(compiler); 26 return new Dart2JsMirrorSystem(compiler);
27 });
26 } 28 }
27 29
28 void validateDeclarationComment(String code, 30 void validateDeclarationComment(String code,
29 String text, 31 String text,
30 String trimmedText, 32 String trimmedText,
31 bool isDocComment, 33 bool isDocComment,
32 List<String> declarationNames) { 34 List<String> declarationNames) {
33 MirrorSystem mirrors = createMirrorSystem(code); 35 asyncTest(() => createMirrorSystem(code).then((mirrors) {
34 LibraryMirror library = mirrors.libraries[SOURCE_URI]; 36 LibraryMirror library = mirrors.libraries[SOURCE_URI];
35 Expect.isNotNull(library); 37 Expect.isNotNull(library);
36 for (String declarationName in declarationNames) { 38 for (String declarationName in declarationNames) {
37 DeclarationMirror declaration = library.members[declarationName]; 39 DeclarationMirror declaration = library.members[declarationName];
38 Expect.isNotNull(declaration); 40 Expect.isNotNull(declaration);
39 List<InstanceMirror> metadata = declaration.metadata; 41 List<InstanceMirror> metadata = declaration.metadata;
40 Expect.isNotNull(metadata); 42 Expect.isNotNull(metadata);
41 Expect.equals(1, metadata.length); 43 Expect.equals(1, metadata.length);
42 Expect.isTrue(metadata[0] is CommentInstanceMirror); 44 Expect.isTrue(metadata[0] is CommentInstanceMirror);
43 CommentInstanceMirror commentMetadata = metadata[0]; 45 CommentInstanceMirror commentMetadata = metadata[0];
44 Expect.equals(text, commentMetadata.text); 46 Expect.equals(text, commentMetadata.text);
45 Expect.equals(trimmedText, commentMetadata.trimmedText); 47 Expect.equals(trimmedText, commentMetadata.trimmedText);
46 Expect.equals(isDocComment, commentMetadata.isDocComment); 48 Expect.equals(isDocComment, commentMetadata.isDocComment);
47 } 49 }
50 }));
48 } 51 }
49 52
50 void testDeclarationComment(String declaration, List<String> declarationNames) { 53 void testDeclarationComment(String declaration, List<String> declarationNames) {
51 String text = 'Single line comment'; 54 String text = 'Single line comment';
52 String comment = '// $text'; 55 String comment = '// $text';
53 String code = '$comment\n$declaration'; 56 String code = '$comment\n$declaration';
54 validateDeclarationComment(code, comment, text, false, declarationNames); 57 validateDeclarationComment(code, comment, text, false, declarationNames);
55 58
56 comment = '/// $text'; 59 comment = '/// $text';
57 code = '$comment\n$declaration'; 60 code = '$comment\n$declaration';
(...skipping 18 matching lines...) Expand all
76 testDeclarationComment('final int field = 0;', ['field']); 79 testDeclarationComment('final int field = 0;', ['field']);
77 testDeclarationComment('final field1 = 0, field2 = 0;', ['field1', 'field2']); 80 testDeclarationComment('final field1 = 0, field2 = 0;', ['field1', 'field2']);
78 testDeclarationComment('final int field1 = 0, field2 = 0;', 81 testDeclarationComment('final int field1 = 0, field2 = 0;',
79 ['field1', 'field2']); 82 ['field1', 'field2']);
80 testDeclarationComment('const field = 0;', ['field']); 83 testDeclarationComment('const field = 0;', ['field']);
81 testDeclarationComment('const int field = 0;', ['field']); 84 testDeclarationComment('const int field = 0;', ['field']);
82 testDeclarationComment('const field1 = 0, field2 = 0;', ['field1', 'field2']); 85 testDeclarationComment('const field1 = 0, field2 = 0;', ['field1', 'field2']);
83 testDeclarationComment('const int field1 = 0, field2 = 0;', 86 testDeclarationComment('const int field1 = 0, field2 = 0;',
84 ['field1', 'field2']); 87 ['field1', 'field2']);
85 } 88 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mirrors_lookup_test.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698