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

Side by Side Diff: pkg/docgen/test/multi_library_test.dart

Issue 1364553002: remove docgen source and targets from build (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: remove scripts Created 5 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library single_library_test;
6
7 import 'package:path/path.dart' as p;
8 import 'package:unittest/unittest.dart';
9
10 import '../lib/docgen.dart';
11 import '../lib/src/exports/mirrors_util.dart' as dart2js_util;
12
13 import 'util.dart';
14
15 List<Uri> _writeLibFiles() {
16 var codePath = getMultiLibraryCodePath();
17
18 codePath = p.join(codePath, 'lib');
19
20 return ['test_lib.dart', 'test_lib_bar.dart', 'test_lib_foo.dart']
21 .map((name) => p.join(codePath, name))
22 .map(p.toUri)
23 .toList();
24 }
25
26 void main() {
27 group('Generate docs for', () {
28 test('multiple libraries.', () {
29 var files = _writeLibFiles();
30 return getMirrorSystem(files, false)
31 .then((mirrorSystem) {
32 var test_libraryUri = files[0];
33 var library = new Library(mirrorSystem.libraries[test_libraryUri]);
34
35 /// Testing fixReference
36 // Testing Doc comment for class [B].
37 var libraryMirror = mirrorSystem.libraries[test_libraryUri];
38 var classDocComment = library.fixReference('B').children.first.text;
39 expect(classDocComment, 'test_lib.B');
40
41 // Test for linking to parameter [c]
42 var importedLib = libraryMirror.libraryDependencies.firstWhere(
43 (dep) => dep.isImport).targetLibrary;
44 var aClassMirror =
45 dart2js_util.classesOf(importedLib.declarations).first;
46 expect(dart2js_util.qualifiedNameOf(aClassMirror),
47 'test_lib.foo.B');
48 var exportedClass = getDocgenObject(aClassMirror, library);
49 expect(exportedClass is Class, isTrue);
50
51
52 var method = exportedClass.methods['doThis'];
53 expect(method is Method, isTrue);
54 var methodParameterDocComment = method.fixReference(
55 'c').children.first.text;
56 expect(methodParameterDocComment, 'test_lib.B.doThis.c');
57
58
59 expect(method.fixReference('A').children.first.text, 'test_lib.A');
60 // Testing trying to refer to doThis function
61 expect(method.fixReference('doThis').children.first.text,
62 'test_lib.B.doThis');
63
64 // Testing trying to refer to doThis function
65 expect(method.fixReference('doElse').children.first.text,
66 'test_lib.B.doElse');
67
68
69 // Test a third library referencing another exported library in a
70 // separate file.
71 importedLib = libraryMirror.libraryDependencies.firstWhere(
72 (dep) => dep.isImport &&
73 dart2js_util.qualifiedNameOf(dep.targetLibrary) ==
74 'test_lib.bar').targetLibrary;
75 aClassMirror = dart2js_util.classesOf(importedLib.declarations).first;
76 expect(dart2js_util.qualifiedNameOf(aClassMirror),
77 'test_lib.bar.C');
78 exportedClass = getDocgenObject(aClassMirror, library);
79 expect(exportedClass is Class, isTrue);
80 expect(exportedClass.docName, 'test_lib.C');
81
82 methodParameterDocComment = exportedClass.fixReference(
83 'B').children.first.text;
84 expect(methodParameterDocComment, 'test_lib.B');
85
86 methodParameterDocComment = exportedClass.fixReference(
87 'testFunc').children.first.text;
88 expect(methodParameterDocComment, 'test_lib.testFunc');
89
90 });
91 });
92
93 test('multiple exported libraries.', () {
94 var lib_file = p.toUri(p.join(getMultiLibraryCodePath(), 'lib',
95 'test_lib2.dart'));
96 return getMirrorSystem([lib_file], false)
97 .then((mirrorSystem) {
98 var library = new Library(mirrorSystem.libraries[lib_file]);
99
100 // Test that libraries do recursive exports correctly.
101 expect(true, library.classes.keys.contains('Bar'));
102 });
103
104 });
105 });
106 }
OLDNEW
« no previous file with comments | « pkg/docgen/test/multi_library_code/lib/test_lib_foo.dart ('k') | pkg/docgen/test/native_extensions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698