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

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

Issue 745533002: Support native extensions for analysis and docgen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comment Created 6 years, 1 month 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/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
});
});
« no previous file with comments | « pkg/compiler/lib/src/warnings.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698