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

Side by Side Diff: pkg/docgen/test/native_extensions_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 native_extensions_test;
6
7 import 'dart:io';
8
9 import 'package:path/path.dart' as path;
10 import 'package:unittest/unittest.dart';
11
12 import '../lib/src/exports/mirrors_util.dart' as dart2js_util;
13 import '../lib/docgen.dart';
14
15 const String DART_LIBRARY = '''
16 library sample_synchronous_extension;
17
18 import 'dart-ext:sample_extension';
19
20 // The simplest way to call native code: top-level functions.
21 int systemRand() native "SystemRand";
22 bool systemSrand(int seed) native "SystemSrand";
23
24 void main() {
25 systemRand();
26 systemSrand(4);
27 }
28 ''';
29
30 main() {
31 group('Generate docs for', () {
32 test('file with native extensions.', () {
33 var temporaryDir = Directory.systemTemp.createTempSync('native_ext_');
34 var fileName = path.join(temporaryDir.path, 'temp.dart');
35 var file = new File(fileName);
36 file.writeAsStringSync(DART_LIBRARY);
37
38 return getMirrorSystem([new Uri.file(fileName)], false)
39 .then((mirrorSystem) {
40 var testLibraryUri = new Uri.file(path.absolute(fileName),
41 windows: Platform.isWindows);
42 var library = new Library(mirrorSystem.libraries[testLibraryUri]);
43 expect(library is Library, isTrue);
44
45 var classTypes = library.classes;
46 var classes = [];
47 classes.addAll(classTypes.values);
48 classes.addAll(library.errors.values);
49 expect(classes.every((e) => e is Class), isTrue);
50
51 expect(library.typedefs.values.every((e) => e is Typedef), isTrue);
52
53 var classMethodTypes = [];
54 classes.forEach((e) {
55 classMethodTypes.add(e.methods);
56 classMethodTypes.add(e.inheritedMethods);
57 });
58 expect(classMethodTypes.every((e) => e is Map<String, Method>),
59 isTrue);
60
61 var classMethods = [];
62 classMethodTypes.forEach((e) {
63 classMethods.addAll(e.values);
64 });
65 expect(classMethods.every((e) => e is Method), isTrue);
66
67 var methodParameters = [];
68 classMethods.forEach((e) {
69 methodParameters.addAll(e.parameters.values);
70 });
71 expect(methodParameters.every((e) => e is Parameter), isTrue);
72
73 var functionTypes = library.functions;
74 expect(functionTypes is Map<String, Method>, isTrue);
75
76 var functions = [];
77 functions.addAll(functionTypes.values);
78 expect(functions.every((e) => e is Method), isTrue);
79
80 var functionParameters = [];
81 functions.forEach((e) {
82 functionParameters.addAll(e.parameters.values);
83 });
84 expect(functionParameters.every((e) => e is Parameter), isTrue);
85
86 var variables = library.variables.values;
87 expect(variables.every((e) => e is Variable), isTrue);
88
89 // Testing trying to refer to m1 function
90 var libraryDocComment =
91 library.fixReference('systemRand').children.first.text;
92 expect(libraryDocComment, 'sample_synchronous_extension.systemRand');
93
94 libraryDocComment =
95 library.fixReference('systemSrand').children.first.text;
96 expect(libraryDocComment, 'sample_synchronous_extension.systemSrand');
97 }).whenComplete(() => temporaryDir.deleteSync(recursive: true));
98 });
99 });
100 }
OLDNEW
« no previous file with comments | « pkg/docgen/test/multi_library_test.dart ('k') | pkg/docgen/test/only_lib_content_in_pkg_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698