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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/docgen/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e8b63136e1d631066019d04adcddfc2381efc220
--- /dev/null
+++ b/pkg/docgen/test/single_library_test.dart
@@ -0,0 +1,108 @@
+import 'dart:io';
Andrei Mouravski 2013/06/27 18:02:04 There should be a library for this file.
+import 'package:unittest/unittest.dart';
Andrei Mouravski 2013/06/27 18:02:04 One line between import blocks.
+import '../lib/docgen.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/filenames.dart';
+
+main() {
+ File file;
+ var mirrors;
+ Library library;
+ setUp(() {
Andrei Mouravski 2013/06/27 18:02:04 Newline before setUp().
+ file = new File('test.dart');
+ file.writeAsStringSync('''
+library test;
+/**
+* Doc comment for class A.
Andrei Mouravski 2013/06/27 18:02:04 You're missing a space before the * here and below
+*
+* 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 name', () {
Andrei Mouravski 2013/06/27 18:02:04 These are not different tests, they're all testing
+ var expectedLibraryName = 'test';
+ expect(library.name, equals(expectedLibraryName));
+ });
+
+ test('Test number of classes', () {
+ var expectedNumberOfClasses = 1;
+ expect(library.classes.length, equals(expectedNumberOfClasses));
+ });
+
+ test('Test class name', () {
+ var expectedClassSimpleName = 'A';
+ var expectedClassQualifiedName = 'test.A';
+ var classA = library.classes.values.first;
+ expect(classA.name, equals(expectedClassSimpleName));
+ expect(classA.qualifiedName, equals(expectedClassQualifiedName));
+ });
+
+ test('Test number of class methods', () {
+ var expectedNumberOfClassMethods = 2;
+ expect(library.classes.values.first.methods.length,
+ equals(expectedNumberOfClassMethods));
+ });
+
+ test('Test class methods names', () {
+ var expectedClassMethods = ['test.A.A', 'test.A.doThis'];
+ var actualMethods = library.classes.values.first.methods.values;
+ actualMethods.forEach((m) {
+ expect(m.qualifiedName, anyOf(expectedClassMethods));
+ });
+ });
+
+ test('Test parameter name for doThis method', () {
+ var expectedParameterForDoThis = 'test.A.doThis#a';
+ var doThisMethod = library.classes.values.first.methods['doThis'];
+ expect(doThisMethod.parameters.values.first.qualifiedName,
+ equals(expectedParameterForDoThis));
+ });
+
+ test('Test number of top level functions', () {
+ var expectedNumberOfFunctions = 1;
+ expect(library.functions.length, equals(expectedNumberOfFunctions));
+ });
+
+ test('Test function name', () {
+ var expectedFunctionSimpleName = 'main';
+ var expectedFunctionQualifiedName = 'test.main';
+ var function = library.functions.values.first;
+ expect(function.name, equals(expectedFunctionSimpleName));
+ expect(function.qualifiedName, equals(expectedFunctionQualifiedName));
+ });
+}
« 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