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

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

Issue 13797002: Change MirrorSystem.libraries to Map<Uri, String> (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 8 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 'dart:io'; 7 import 'dart:io';
8 import 'dart:uri'; 8 import 'dart:uri';
9 import 'package:expect/expect.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
10 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ; 11 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors.dart' ;
11 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart'; 12 import '../../../sdk/lib/_internal/compiler/implementation/mirrors/dart2js_mirro r.dart';
12 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart'; 13 import '../../../sdk/lib/_internal/compiler/implementation/source_file_provider. dart';
13 import 'mock_compiler.dart'; 14 import 'mock_compiler.dart';
14 15
15 const String SOURCE = 'source'; 16 const String SOURCE = 'source';
17 const Uri SOURCE_URI = const Uri.fromComponents(scheme: SOURCE, path: SOURCE);
16 18
17 MirrorSystem createMirrorSystem(String source) { 19 MirrorSystem createMirrorSystem(String source) {
18 Uri sourceUri = new Uri.fromComponents(scheme: SOURCE, path: SOURCE);
19 MockCompiler compiler = new MockCompiler( 20 MockCompiler compiler = new MockCompiler(
20 analyzeOnly: true, 21 analyzeOnly: true,
21 analyzeAll: true, 22 analyzeAll: true,
22 preserveComments: true); 23 preserveComments: true);
23 compiler.registerSource(sourceUri, source); 24 compiler.registerSource(SOURCE_URI, source);
24 compiler.librariesToAnalyzeWhenRun = <Uri>[sourceUri]; 25 compiler.librariesToAnalyzeWhenRun = <Uri>[SOURCE_URI];
25 compiler.runCompiler(null); 26 compiler.runCompiler(null);
26 return new Dart2JsMirrorSystem(compiler); 27 return new Dart2JsMirrorSystem(compiler);
27 } 28 }
28 29
29 void validateDeclarationComment(String code, 30 void validateDeclarationComment(String code,
30 String text, 31 String text,
31 String trimmedText, 32 String trimmedText,
32 bool isDocComment, 33 bool isDocComment,
33 List<String> declarationNames) { 34 List<String> declarationNames) {
34 MirrorSystem mirrors = createMirrorSystem(code); 35 MirrorSystem mirrors = createMirrorSystem(code);
35 LibraryMirror library = mirrors.libraries[SOURCE]; 36 LibraryMirror library = mirrors.libraries[SOURCE_URI];
36 Expect.isNotNull(library); 37 Expect.isNotNull(library);
37 for (String declarationName in declarationNames) { 38 for (String declarationName in declarationNames) {
38 DeclarationMirror declaration = library.members[declarationName]; 39 DeclarationMirror declaration = library.members[declarationName];
39 Expect.isNotNull(declaration); 40 Expect.isNotNull(declaration);
40 List<InstanceMirror> metadata = declaration.metadata; 41 List<InstanceMirror> metadata = declaration.metadata;
41 Expect.isNotNull(metadata); 42 Expect.isNotNull(metadata);
42 Expect.equals(1, metadata.length); 43 Expect.equals(1, metadata.length);
43 Expect.isTrue(metadata[0] is CommentInstanceMirror); 44 Expect.isTrue(metadata[0] is CommentInstanceMirror);
44 CommentInstanceMirror commentMetadata = metadata[0]; 45 CommentInstanceMirror commentMetadata = metadata[0];
45 Expect.equals(text, commentMetadata.text); 46 Expect.equals(text, commentMetadata.text);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 testDeclarationComment('final int field = 0;', ['field']); 78 testDeclarationComment('final int field = 0;', ['field']);
78 testDeclarationComment('final field1 = 0, field2 = 0;', ['field1', 'field2']); 79 testDeclarationComment('final field1 = 0, field2 = 0;', ['field1', 'field2']);
79 testDeclarationComment('final int field1 = 0, field2 = 0;', 80 testDeclarationComment('final int field1 = 0, field2 = 0;',
80 ['field1', 'field2']); 81 ['field1', 'field2']);
81 testDeclarationComment('const field = 0;', ['field']); 82 testDeclarationComment('const field = 0;', ['field']);
82 testDeclarationComment('const int field = 0;', ['field']); 83 testDeclarationComment('const int field = 0;', ['field']);
83 testDeclarationComment('const field1 = 0, field2 = 0;', ['field1', 'field2']); 84 testDeclarationComment('const field1 = 0, field2 = 0;', ['field1', 'field2']);
84 testDeclarationComment('const int field1 = 0, field2 = 0;', 85 testDeclarationComment('const int field1 = 0, field2 = 0;',
85 ['field1', 'field2']); 86 ['field1', 'field2']);
86 } 87 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/memory_source_file_helper.dart ('k') | tests/compiler/dart2js/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698