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

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

Issue 18089006: Single unit test for a single library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « pkg/docgen/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 import 'dart:io';
Andrei Mouravski 2013/06/27 18:02:04 There should be a library for this file.
2 import 'package:unittest/unittest.dart';
Andrei Mouravski 2013/06/27 18:02:04 One line between import blocks.
3 import '../lib/docgen.dart';
4 import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
5
6 main() {
7 File file;
8 var mirrors;
9 Library library;
10 setUp(() {
Andrei Mouravski 2013/06/27 18:02:04 Newline before setUp().
11 file = new File('test.dart');
12 file.writeAsStringSync('''
13 library test;
14 /**
15 * Doc comment for class A.
Andrei Mouravski 2013/06/27 18:02:04 You're missing a space before the * here and below
16 *
17 * Multiline Test
18 */
19 /*
20 * Normal comment for class A.
21 */
22 class A {
23
24 /**
25 * Markdown _test_ for **class** [A]
26 */
27 int _someNumber;
28
29 A() {
30 _someNumber = 12;
31 }
32
33 void doThis(int a) {
34 print(a);
35 }
36 }
37
38 main() {
39 A a = new A();
40 a.doThis(5);
41 }
42 ''');
43 parseSdk = false;
44 includePrivate = true;
45 includeSdk = false;
46 return getMirrorSystem(['test.dart']).then(expectAsync1((mirrorSystem) {
47 mirrors = mirrorSystem;
48 var testLibraryUri = currentDirectory.resolve('test.dart');
49 library = generateLibrary(mirrorSystem.libraries[testLibraryUri]);
50 }));
51 });
52
53 tearDown(() {
54 file.deleteSync();
55 });
56
57 test('Test library name', () {
Andrei Mouravski 2013/06/27 18:02:04 These are not different tests, they're all testing
58 var expectedLibraryName = 'test';
59 expect(library.name, equals(expectedLibraryName));
60 });
61
62 test('Test number of classes', () {
63 var expectedNumberOfClasses = 1;
64 expect(library.classes.length, equals(expectedNumberOfClasses));
65 });
66
67 test('Test class name', () {
68 var expectedClassSimpleName = 'A';
69 var expectedClassQualifiedName = 'test.A';
70 var classA = library.classes.values.first;
71 expect(classA.name, equals(expectedClassSimpleName));
72 expect(classA.qualifiedName, equals(expectedClassQualifiedName));
73 });
74
75 test('Test number of class methods', () {
76 var expectedNumberOfClassMethods = 2;
77 expect(library.classes.values.first.methods.length,
78 equals(expectedNumberOfClassMethods));
79 });
80
81 test('Test class methods names', () {
82 var expectedClassMethods = ['test.A.A', 'test.A.doThis'];
83 var actualMethods = library.classes.values.first.methods.values;
84 actualMethods.forEach((m) {
85 expect(m.qualifiedName, anyOf(expectedClassMethods));
86 });
87 });
88
89 test('Test parameter name for doThis method', () {
90 var expectedParameterForDoThis = 'test.A.doThis#a';
91 var doThisMethod = library.classes.values.first.methods['doThis'];
92 expect(doThisMethod.parameters.values.first.qualifiedName,
93 equals(expectedParameterForDoThis));
94 });
95
96 test('Test number of top level functions', () {
97 var expectedNumberOfFunctions = 1;
98 expect(library.functions.length, equals(expectedNumberOfFunctions));
99 });
100
101 test('Test function name', () {
102 var expectedFunctionSimpleName = 'main';
103 var expectedFunctionQualifiedName = 'test.main';
104 var function = library.functions.values.first;
105 expect(function.name, equals(expectedFunctionSimpleName));
106 expect(function.qualifiedName, equals(expectedFunctionQualifiedName));
107 });
108 }
OLDNEW
« no previous file with comments | « pkg/docgen/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698