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

Unified Diff: third_party/pkg/di/test/generator_test.dart

Issue 180873006: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review feedback Created 6 years, 10 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 | « third_party/pkg/di/test/fixed-unittest.dart ('k') | third_party/pkg/di/test/main.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/di/test/generator_test.dart
diff --git a/third_party/pkg/di/test/generator_test.dart b/third_party/pkg/di/test/generator_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..900b312a6162d9fc70ec81acfc09b8690fe3c5a9
--- /dev/null
+++ b/third_party/pkg/di/test/generator_test.dart
@@ -0,0 +1,44 @@
+import 'dart:io';
+import 'package:analyzer/analyzer.dart';
+import 'package:di/generator.dart' as generator;
+import 'package:unittest/unittest.dart';
+
+main(args) => group('generator', () {
+
+ test('should codesplit deferred libraries', () {
+ Map<generator.Chunk, String> code = generator.generateCode(
+ 'test/assets/gen_test1/main.dart', ['annotations.Injectable'],
+ Platform.environment['DART_SDK'], [Platform.packageRoot]);
+
+ expect(code.keys.map((chunk) => chunk.library == null ? null : chunk.library.name),
+ unorderedEquals([null, 'lib_a', 'lib_b']));
+
+ code.forEach((chunk, code) {
+ var cu = parseCompilationUnit(code);
+ if (chunk.library == null) {
+ expectHasImports(cu, ['main.dart', 'common1.dart']);
+ } else if (chunk.library.name.endsWith('lib_a')) {
+ expectHasImports(cu, ['a.dart', 'a2.dart', 'common2.dart']);
+ } else if (chunk.library.name.endsWith('lib_b')) {
+ expectHasImports(cu, ['b.dart', 'b2.dart', 'common2.dart']);
+ }
+ });
+ });
+});
+
+expectHasImports(CompilationUnit cu, List<String> expectedImports) {
+ var imports = <String>[];
+ cu.directives.forEach((Directive directive) {
+ if (directive is NamespaceDirective) {
+ if (directive is! ImportDirective) {
+ fail('Only expecting import, no exports.');
+ }
+ ImportDirective import = directive;
+ imports.add(import.uri.stringValue);
+ }
+ });
+ expect(imports.length, equals(expectedImports.length));
+ for (int i = 0; i < imports.length; i++) {
+ expect(imports[i], endsWith(expectedImports[i]));
+ }
+}
« no previous file with comments | « third_party/pkg/di/test/fixed-unittest.dart ('k') | third_party/pkg/di/test/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698