| Index: pkg/docgen/test/native_extensions_test.dart
|
| diff --git a/pkg/docgen/test/single_library_test.dart b/pkg/docgen/test/native_extensions_test.dart
|
| similarity index 62%
|
| copy from pkg/docgen/test/single_library_test.dart
|
| copy to pkg/docgen/test/native_extensions_test.dart
|
| index 31f3a5ea8a899cedd3bb9d5e53463f10d5fa6e87..70e789c243f21b90e1580b15f94387fc2d0c6c06 100644
|
| --- a/pkg/docgen/test/single_library_test.dart
|
| +++ b/pkg/docgen/test/native_extensions_test.dart
|
| @@ -2,7 +2,7 @@
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| -library single_library_test;
|
| +library native_extensions_test;
|
|
|
| import 'dart:io';
|
|
|
| @@ -13,41 +13,24 @@ import '../lib/src/exports/mirrors_util.dart' as dart2js_util;
|
| import '../lib/docgen.dart';
|
|
|
| const String DART_LIBRARY = '''
|
| - library test;
|
| - /**
|
| - * Doc comment for class [A].
|
| - *
|
| - * Multiline Test
|
| - */
|
| - /*
|
| - * Normal comment for class A.
|
| - */
|
| - class A {
|
| -
|
| - int _someNumber;
|
| -
|
| - A() {
|
| - _someNumber = 12;
|
| - }
|
| -
|
| - /**
|
| - * Test for linking to parameter [A]
|
| - */
|
| - void doThis(int A) {
|
| - print(A);
|
| - }
|
| - }
|
| + library sample_synchronous_extension;
|
| +
|
| + import 'dart-ext:sample_extension';
|
|
|
| - main() {
|
| - A a = new A();
|
| - a.doThis(5);
|
| + // The simplest way to call native code: top-level functions.
|
| + int systemRand() native "SystemRand";
|
| + bool systemSrand(int seed) native "SystemSrand";
|
| +
|
| + void main() {
|
| + systemRand();
|
| + systemSrand(4);
|
| }
|
| ''';
|
|
|
| main() {
|
| group('Generate docs for', () {
|
| - test('one simple file.', () {
|
| - var temporaryDir = Directory.systemTemp.createTempSync('single_library_');
|
| + test('file with native extensions.', () {
|
| + var temporaryDir = Directory.systemTemp.createTempSync('native_ext_');
|
| var fileName = path.join(temporaryDir.path, 'temp.dart');
|
| var file = new File(fileName);
|
| file.writeAsStringSync(DART_LIBRARY);
|
| @@ -72,7 +55,8 @@ main() {
|
| classMethodTypes.add(e.methods);
|
| classMethodTypes.add(e.inheritedMethods);
|
| });
|
| - expect(classMethodTypes.every((e) => e is Map<String, Method>), isTrue);
|
| + expect(classMethodTypes.every((e) => e is Map<String, Method>),
|
| + isTrue);
|
|
|
| var classMethods = [];
|
| classMethodTypes.forEach((e) {
|
| @@ -102,29 +86,14 @@ main() {
|
| var variables = library.variables.values;
|
| expect(variables.every((e) => e is Variable), isTrue);
|
|
|
| - /// Testing fixReference
|
| - // Testing Doc comment for class [A].
|
| - var libraryMirror = mirrorSystem.libraries[testLibraryUri];
|
| - var classMirror =
|
| - dart2js_util.classesOf(libraryMirror.declarations).first;
|
| - var classDocComment = library.fixReference('A').children.first.text;
|
| - expect(classDocComment, 'test.A');
|
| -
|
| - // Test for linking to parameter [A]
|
| - var method = getDocgenObject(
|
| - classMirror.declarations[dart2js_util.symbolOf('doThis')]);
|
| - var methodParameterDocComment = method.fixReference(
|
| - 'A').children.first.text;
|
| - expect(methodParameterDocComment, 'test.A.doThis.A');
|
| -
|
| - // Testing trying to refer to doThis function
|
| - var methodDocComment = method.fixReference(
|
| - 'doThis').children.first.text;
|
| - expect(methodDocComment, 'test.A.doThis');
|
| -
|
| - // Testing something with no reference
|
| - var libraryDocComment = method.fixReference('foobar').text;
|
| - expect(libraryDocComment, 'foobar');
|
| + // Testing trying to refer to m1 function
|
| + var libraryDocComment =
|
| + library.fixReference('systemRand').children.first.text;
|
| + expect(libraryDocComment, 'sample_synchronous_extension.systemRand');
|
| +
|
| + libraryDocComment =
|
| + library.fixReference('systemSrand').children.first.text;
|
| + expect(libraryDocComment, 'sample_synchronous_extension.systemSrand');
|
| }).whenComplete(() => temporaryDir.deleteSync(recursive: true));
|
| });
|
| });
|
|
|