@@ -30,6 +30,44 @@ class NnbdMigrationTestBase extends AbstractAnalysisTest {
3030 includedRoot: includedRoot, removeViaComments: removeViaComments);
3131 }
3232
33+ /// Uses the InfoBuilder to build information for a single test file.
34+ ///
35+ /// Asserts that [originalContent] is migrated to [migratedContent] . Returns
36+ /// the singular UnitInfo which was built.
37+ Future <UnitInfo > buildInfoForSingleTestFile (String originalContent,
38+ {@required String migratedContent, bool removeViaComments = true }) async {
39+ addTestFile (originalContent);
40+ await buildInfo (removeViaComments: removeViaComments);
41+ // Ignore info for dart:core.
42+ var filteredInfos = [
43+ for (var info in infos) if (! info.path.contains ('core.dart' )) info
44+ ];
45+ expect (filteredInfos, hasLength (1 ));
46+ UnitInfo unit = filteredInfos[0 ];
47+ expect (unit.path, testFile);
48+ expect (unit.content, migratedContent);
49+ return unit;
50+ }
51+
52+ /// Uses the InfoBuilder to build information for test files.
53+ ///
54+ /// Returns
55+ /// the singular UnitInfo which was built.
56+ Future <List <UnitInfo >> buildInfoForTestFiles (Map <String , String > files,
57+ {String includedRoot}) async {
58+ var testPaths = < String > [];
59+ files.forEach ((String path, String content) {
60+ newFile (path, content: content);
61+ testPaths.add (path);
62+ });
63+ await _buildMigrationInfo (testPaths, includedRoot: includedRoot);
64+ // Ignore info for dart:core.
65+ var filteredInfos = [
66+ for (var info in infos) if (! info.path.contains ('core.dart' )) info
67+ ];
68+ return filteredInfos;
69+ }
70+
3371 /// Uses the InfoBuilder to build information for files at [testPaths] , which
3472 /// should all share a common parent directory, [includedRoot] .
3573 Future <void > _buildMigrationInfo (List <String > testPaths,
@@ -61,42 +99,4 @@ class NnbdMigrationTestBase extends AbstractAnalysisTest {
6199 explainNonNullableTypes: true );
62100 infos = await builder.explainMigration ();
63101 }
64-
65- /// Uses the InfoBuilder to build information for test files.
66- ///
67- /// Returns
68- /// the singular UnitInfo which was built.
69- Future <List <UnitInfo >> buildInfoForTestFiles (Map <String , String > files,
70- {String includedRoot}) async {
71- var testPaths = < String > [];
72- files.forEach ((String path, String content) {
73- newFile (path, content: content);
74- testPaths.add (path);
75- });
76- await _buildMigrationInfo (testPaths, includedRoot: includedRoot);
77- // Ignore info for dart:core.
78- var filteredInfos = [
79- for (var info in infos) if (info.path.indexOf ('core.dart' ) == - 1 ) info
80- ];
81- return filteredInfos;
82- }
83-
84- /// Uses the InfoBuilder to build information for a single test file.
85- ///
86- /// Asserts that [originalContent] is migrated to [migratedContent] . Returns
87- /// the singular UnitInfo which was built.
88- Future <UnitInfo > buildInfoForSingleTestFile (String originalContent,
89- {@required String migratedContent, bool removeViaComments = true }) async {
90- addTestFile (originalContent);
91- await buildInfo (removeViaComments: removeViaComments);
92- // Ignore info for dart:core.
93- var filteredInfos = [
94- for (var info in infos) if (info.path.indexOf ('core.dart' ) == - 1 ) info
95- ];
96- expect (filteredInfos, hasLength (1 ));
97- UnitInfo unit = filteredInfos[0 ];
98- expect (unit.path, testFile);
99- expect (unit.content, migratedContent);
100- return unit;
101- }
102102}
0 commit comments