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

Side by Side Diff: third_party/pkg/di/test/generator_test.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
OLDNEW
1 import 'dart:io'; 1 import 'dart:io';
2 import 'package:analyzer/analyzer.dart'; 2 import 'package:analyzer/analyzer.dart';
3 import 'package:di/generator.dart' as generator; 3 import 'package:di/generator.dart' as generator;
4 import 'package:unittest/unittest.dart'; 4 import 'package:unittest/unittest.dart';
5 5
6 main(args) => group('generator', () { 6 main(args) => group('generator', () {
7 7
8 test('should codesplit deferred libraries', () { 8 test('should codesplit deferred libraries', () {
9 Map<generator.Chunk, String> code = generator.generateCode( 9 Map<generator.Chunk, String> code = generator.generateCode(
10 'test/assets/gen_test1/main.dart', ['annotations.Injectable'], 10 'test_assets/gen_test1/main.dart', ['annotations.InjectableTest'],
11 Platform.environment['DART_SDK'], [Platform.packageRoot]); 11 Platform.environment['DART_SDK'], [Platform.packageRoot], 'main.dart');
12 12
13 expect(code.keys.map((chunk) => chunk.library == null ? null : chunk.library .name), 13 expect(code.keys.map((chunk) => chunk.library == null ? null : chunk.library .name),
14 unorderedEquals([null, 'lib_a', 'lib_b'])); 14 unorderedEquals([null, 'lib_a', 'lib_b', 'lib_c']));
15 15
16 code.forEach((chunk, code) { 16 code.forEach((chunk, code) {
17 var cu = parseCompilationUnit(code); 17 var cu = parseCompilationUnit(code);
18 if (chunk.library == null) { 18 if (chunk.library == null) {
19 expectHasImports(cu, ['main.dart', 'common1.dart']); 19 expectHasImports(cu, ['main.dart', 'common1.dart']);
20 } else if (chunk.library.name.endsWith('lib_a')) { 20 } else if (chunk.library.name.endsWith('lib_a')) {
21 expectHasImports(cu, ['a.dart', 'a2.dart', 'common2.dart']); 21 expectHasImports(cu, ['a.dart', 'a2.dart', 'common2.dart']);
22 } else if (chunk.library.name.endsWith('lib_b')) { 22 } else if (chunk.library.name.endsWith('lib_b')) {
23 expectHasImports(cu, ['b.dart', 'b2.dart', 'common2.dart']); 23 expectHasImports(cu, ['b.dart', 'b2.dart', 'common2.dart']);
24 } else if (chunk.library.name.endsWith('lib_c')) {
25 expectHasImports(cu, []);
24 } 26 }
25 }); 27 });
26 }); 28 });
27 }); 29 });
28 30
29 expectHasImports(CompilationUnit cu, List<String> expectedImports) { 31 expectHasImports(CompilationUnit cu, List<String> expectedImports) {
30 var imports = <String>[]; 32 var imports = <String>[];
31 cu.directives.forEach((Directive directive) { 33 cu.directives.forEach((Directive directive) {
32 if (directive is NamespaceDirective) { 34 if (directive is NamespaceDirective) {
33 if (directive is! ImportDirective) { 35 if (directive is! ImportDirective) {
34 fail('Only expecting import, no exports.'); 36 fail('Only expecting import, no exports.');
35 } 37 }
36 ImportDirective import = directive; 38 ImportDirective import = directive;
37 imports.add(import.uri.stringValue); 39 imports.add(import.uri.stringValue);
38 } 40 }
39 }); 41 });
40 expect(imports.length, equals(expectedImports.length)); 42 expect(imports.length, equals(expectedImports.length));
41 for (int i = 0; i < imports.length; i++) { 43 for (int i = 0; i < imports.length; i++) {
42 expect(imports[i], endsWith(expectedImports[i])); 44 expect(imports[i], endsWith(expectedImports[i]));
43 } 45 }
44 } 46 }
OLDNEW
« no previous file with comments | « third_party/pkg/di/test/fixed-unittest.dart ('k') | third_party/pkg/di/test/injector_generator_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698