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

Unified Diff: pkg/docgen/test/multi_library_test.dart

Issue 138623002: Enable re-export in docgen. Work in progress. More to come. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 | « pkg/docgen/lib/docgen.dart ('k') | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/test/multi_library_test.dart
diff --git a/pkg/docgen/test/multi_library_test.dart b/pkg/docgen/test/multi_library_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1346de8a6d5d5028a46e2578cbdde46dd1aae153
--- /dev/null
+++ b/pkg/docgen/test/multi_library_test.dart
@@ -0,0 +1,174 @@
+library single_library_test;
+
+import 'dart:io';
+
+import 'package:path/path.dart' as path;
+import 'package:unittest/unittest.dart';
+
+import '../lib/docgen.dart';
+
+const String DART_LIBRARY_1 = '''
+ library testLib;
+ import 'temp2.dart';
+ import 'temp3.dart';
+ export 'temp2.dart';
+ export 'temp3.dart';
+
+ /**
+ * Doc comment for class [A].
+ *
+ * Multiline Test
+ */
+ /*
+ * Normal comment for class A.
+ */
+ class A {
+
+ int _someNumber;
+
+ A() {
+ _someNumber = 12;
+ }
+
+ A.customConstructor();
+
+ /**
+ * Test for linking to parameter [A]
+ */
+ void doThis(int A) {
+ print(A);
+ }
+ }
+''';
+
+const String DART_LIBRARY_2 = '''
+ library testLib2.foo;
+ import 'temp.dart';
+
+ /**
+ * Doc comment for class [B].
+ *
+ * Multiline Test
+ */
+
+ /*
+ * Normal comment for class B.
+ */
+ class B extends A {
+
+ B();
+ B.fooBar();
+
+ /**
+ * Test for linking to super
+ */
+ int doElse(int b) {
+ print(b);
+ }
+
+ /**
+ * Test for linking to parameter [c]
+ */
+ void doThis(int c) {
+ print(a);
+ }
+ }
+
+ int testFunc(int a) {
+ }
+''';
+
+const String DART_LIBRARY_3 = '''
+ library testLib.bar;
+ import 'temp.dart';
+
+ /*
+ * Normal comment for class C.
+ */
+ class C {
+ }
+''';
+
+Directory TEMP_DIRNAME;
+
+List writeLibFiles() {
+ TEMP_DIRNAME = Directory.systemTemp.createTempSync('single_library_');
+ var fileName = path.join(TEMP_DIRNAME.path, 'temp.dart');
+ var file = new File(fileName);
+ file.writeAsStringSync(DART_LIBRARY_1);
+
+ var fileName2 = path.join(TEMP_DIRNAME.path, 'temp2.dart');
+ file = new File(fileName2);
+ file.writeAsStringSync(DART_LIBRARY_2);
+
+ var fileName3 = path.join(TEMP_DIRNAME.path, 'temp3.dart');
+ file = new File(fileName3);
+ file.writeAsStringSync(DART_LIBRARY_3);
+ return [new Uri.file(fileName), new Uri.file(fileName3),
+ new Uri.file(fileName3)];
+}
+
+main() {
+ group('Generate docs for', () {
+ test('multiple libraries.', () {
+ var files = writeLibFiles();
+ getMirrorSystem(files)
+ .then(expectAsync1((mirrorSystem) {
+ var testLibraryUri = files[0];
+ var library = new Library(mirrorSystem.libraries[testLibraryUri]);
+
+ /// Testing fixReference
+ // Testing Doc comment for class [B].
+ var libraryMirror = mirrorSystem.libraries[testLibraryUri];
+ var classDocComment = library.fixReference('B').children.first.text;
+ expect(classDocComment, 'testLib.B');
+
+ // Test for linking to parameter [c]
+ var importedLib = libraryMirror.libraryDependencies.firstWhere(
+ (dep) => dep.isImport).targetLibrary;
+ var aClassMirror = importedLib.classes.values.first;
+ expect(aClassMirror.qualifiedName, 'testLib2.foo.B');
+ var exportedClass = getDocgenObject(aClassMirror, library);
+ expect(exportedClass is Class, isTrue);
+
+
+ var method = exportedClass.methods['doThis'];
+ expect(method is Method, isTrue);
+ var methodParameterDocComment = method.fixReference(
+ 'c').children.first.text;
+ expect(methodParameterDocComment, 'testLib.B.doThis.c');
+
+
+ expect(method.fixReference('A').children.first.text, 'testLib.A');
+ // Testing trying to refer to doThis function
+ expect(method.fixReference('doThis').children.first.text,
+ 'testLib.B.doThis');
+
+ // Testing trying to refer to doThis function
+ expect(method.fixReference('doElse').children.first.text,
+ 'testLib.B.doElse');
+
+
+ // Test a third library referencing another exported library in a
+ // separate file.
+ importedLib = libraryMirror.libraryDependencies.firstWhere(
+ (dep) => dep.isImport && dep.targetLibrary.qualifiedName ==
+ 'testLib.bar').targetLibrary;
+ aClassMirror = importedLib.classes.values.first;
+ expect(aClassMirror.qualifiedName, 'testLib.bar.C');
+ exportedClass = getDocgenObject(aClassMirror, library);
+ expect(exportedClass is Class, isTrue);
+ expect(exportedClass.docName, 'testLib.C');
+
+ methodParameterDocComment = exportedClass.fixReference(
+ 'B').children.first.text;
+ expect(methodParameterDocComment, 'testLib.B');
+
+ methodParameterDocComment = exportedClass.fixReference(
+ 'testFunc').children.first.text;
+ expect(methodParameterDocComment, 'testLib.testFunc');
+
+ })).whenComplete(() => TEMP_DIRNAME.deleteSync(recursive: true));
+ });
+ });
+}
« no previous file with comments | « pkg/docgen/lib/docgen.dart ('k') | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698