44
55library testing.multitest;
66
7- import 'dart:async' show Stream, StreamTransformer;
7+ import 'dart:async' show
8+ Stream,
9+ StreamTransformer;
810
9- import 'dart:io' show Directory, File;
11+ import 'dart:io' show
12+ Directory,
13+ File;
1014
11- import 'log.dart' show splitLines;
15+ import 'log.dart' show
16+ splitLines;
1217
13- import 'test_description.dart' show TestDescription;
18+ import 'test_description.dart' show
19+ TestDescription;
1420
1521bool isError (Set <String > expectations) {
1622 if (expectations.contains ("compile-time error" )) return true ;
@@ -26,17 +32,16 @@ bool isCheckedModeError(Set<String> expectations) {
2632
2733class MultitestTransformer
2834 implements StreamTransformer <TestDescription , TestDescription > {
29- static RegExp multitestMarker = new RegExp (r"//[#/]" );
30- static int _multitestMarkerLength = 3 ;
35+ static const String multitestMarker = "///" ;
3136
3237 static const List <String > validOutcomesList = const < String > [
33- "ok" ,
34- "compile-time error" ,
35- "runtime error" ,
36- "static type warning" ,
37- "dynamic type error" ,
38- "checked mode compile-time error" ,
39- ];
38+ "ok" ,
39+ "compile-time error" ,
40+ "runtime error" ,
41+ "static type warning" ,
42+ "dynamic type error" ,
43+ "checked mode compile-time error" ,
44+ ];
4045
4146 static final Set <String > validOutcomes =
4247 new Set <String >.from (validOutcomesList);
@@ -47,9 +52,7 @@ class MultitestTransformer
4752 errors.add (error);
4853 print (error);
4954 }
50-
51- nextTest:
52- await for (TestDescription test in stream) {
55+ nextTest: await for (TestDescription test in stream) {
5356 String contents = await test.file.readAsString ();
5457 if (! contents.contains (multitestMarker)) {
5558 yield test;
@@ -71,23 +74,20 @@ class MultitestTransformer
7174 List <String > subtestOutcomesList;
7275 if (index != - 1 ) {
7376 String annotationText =
74- line.substring (index + _multitestMarkerLength ).trim ();
77+ line.substring (index + multitestMarker.length ).trim ();
7578 index = annotationText.indexOf (":" );
7679 if (index != - 1 ) {
7780 subtestName = annotationText.substring (0 , index).trim ();
78- subtestOutcomesList = annotationText
79- .substring (index + 1 )
80- .split ("," )
81- .map ((s) => s.trim ())
82- .toList ();
81+ subtestOutcomesList = annotationText.substring (index + 1 ).split ("," )
82+ .map ((s) => s.trim ()).toList ();
8383 if (subtestName == "none" ) {
8484 reportError (test.formatError (
85- "$lineNumber : $subtestName can't be used as test name." ));
85+ "$lineNumber : $subtestName can't be used as test name." ));
8686 continue nextTest;
8787 }
8888 if (subtestOutcomesList.isEmpty) {
89- reportError (test
90- . formatError ( "$lineNumber : Expected <testname>:<outcomes>" ));
89+ reportError (test. formatError (
90+ "$lineNumber : Expected <testname>:<outcomes>" ));
9191 continue nextTest;
9292 }
9393 }
@@ -96,16 +96,16 @@ class MultitestTransformer
9696 List <String > lines = testsAsLines.putIfAbsent (subtestName,
9797 () => new List <String >.from (linesWithoutAnnotations));
9898 lines.add (line);
99- Set <String > subtestOutcomes =
100- outcomes. putIfAbsent (subtestName, () => new Set <String >());
99+ Set <String > subtestOutcomes = outcomes. putIfAbsent (subtestName,
100+ () => new Set <String >());
101101 if (subtestOutcomesList.length != 1 ||
102102 subtestOutcomesList.single != "continued" ) {
103103 for (String outcome in subtestOutcomesList) {
104104 if (validOutcomes.contains (outcome)) {
105105 subtestOutcomes.add (outcome);
106106 } else {
107107 reportError (test.formatError (
108- "$lineNumber : '$outcome ' isn't a recognized outcome." ));
108+ "$lineNumber : '$outcome ' isn't a recognized outcome." ));
109109 continue nextTest;
110110 }
111111 }
0 commit comments