Chromium Code Reviews| Index: pkg/docgen/test/single_library_test.dart |
| diff --git a/pkg/docgen/test/single_library_test.dart b/pkg/docgen/test/single_library_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8ef51f6a4f4ab024512946f35276059098a7e09b |
| --- /dev/null |
| +++ b/pkg/docgen/test/single_library_test.dart |
| @@ -0,0 +1,84 @@ |
| +library single_library_test; |
| + |
| +import 'dart:io'; |
| + |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import '../lib/docgen.dart'; |
| +import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart'; |
| + |
| +main() { |
| + File file; |
| + var mirrors; |
| + Library library; |
| + |
| + setUp(() { |
| + file = new File('test.dart'); |
| + file.writeAsStringSync(''' |
|
Tate Mandel
2013/06/28 16:43:29
You can probably just include this file in the tes
|
| +library test; |
| +/** |
| + * Doc comment for class A. |
| + * |
| + * Multiline Test |
| + */ |
| +/* |
| + * Normal comment for class A. |
| + */ |
| +class A { |
| + |
| + /** |
| + * Markdown _test_ for **class** [A] |
| + */ |
| + int _someNumber; |
| + |
| + A() { |
| + _someNumber = 12; |
| + } |
| + |
| + void doThis(int a) { |
| + print(a); |
| + } |
| +} |
| + |
| +main() { |
| + A a = new A(); |
| + a.doThis(5); |
| +} |
| + '''); |
| + parseSdk = false; |
| + includePrivate = true; |
| + includeSdk = false; |
| + return getMirrorSystem(['test.dart']).then(expectAsync1((mirrorSystem) { |
| + mirrors = mirrorSystem; |
| + var testLibraryUri = currentDirectory.resolve('test.dart'); |
| + library = generateLibrary(mirrorSystem.libraries[testLibraryUri]); |
| + })); |
| + }); |
| + |
| + tearDown(() { |
| + file.deleteSync(); |
| + }); |
| + |
| + test('Test library generated is of type Library', () { |
|
Tate Mandel
2013/06/28 16:43:29
All of your tests are testing the same unit of cod
|
| + expect(library is Library, isTrue); |
| + }); |
| + |
| + test('Test class generated is of type Class', () { |
| + expect(library.classes.values.every((e) => e is Class), isTrue); |
| + }); |
| + |
| + test('Test class methods generated are of type Method', () { |
| + expect(library.classes.values.first.methods.values |
| + .every((e) => e is Method), isTrue); |
| + }); |
| + |
| + test('Test class method parameter for doThis generated is of type Parameter', |
| + () { |
| + expect(library.classes.values.first.methods['doThis'].parameters.values |
|
Tate Mandel
2013/06/28 16:43:29
If you combine all of these tests into a single bl
|
| + .every((e) => e is Parameter), isTrue); |
| + }); |
| + |
| + test('Test top-level functions generated are of type Method', () { |
| + expect(library.functions.values.every((e) => e is Method), isTrue); |
| + }); |
| +} |