@@ -20,24 +20,26 @@ object FileDiff {
20
20
if (! (new File (checkFile)).exists) Nil
21
21
else Using (Source .fromFile(checkFile, " UTF-8" ))(_.getLines().toList).get
22
22
23
- // handle check file path mismatch on windows
24
- def lineMatch (actual : String , expect : String ): Boolean = {
25
- val actual1 = actual.stripLineEnd
26
- val expect1 = expect.stripLineEnd
27
- actual1 == expect1 || File .separatorChar == '\\ ' && actual1.replace('\\ ' , '/' ) == expect1
28
- }
29
-
30
- def linesMatch =
31
- outputLines.length == checkLines.length &&
32
- outputLines.lazyZip(checkLines).forall(lineMatch)
33
-
34
- if (! linesMatch) Some (
23
+ if (! matches(outputLines, checkLines)) Some (
35
24
s """ |Output from ' $sourceTitle' did not match check file. Actual output:
36
25
| ${outputLines.mkString(EOL )}
37
26
| """ .stripMargin + " \n " )
38
27
else None
39
28
}
40
29
30
+ def matches (actual : String , expect : String ): Boolean = {
31
+ val actual1 = actual.stripLineEnd
32
+ val expect1 = expect.stripLineEnd
33
+
34
+ // handle check file path mismatch on windows
35
+ actual1 == expect1 || File .separatorChar == '\\ ' && actual1.replace('\\ ' , '/' ) == expect1
36
+ }
37
+
38
+ def matches (actual : Seq [String ], expect : Seq [String ]): Boolean = {
39
+ actual.length == expect.length
40
+ && actual.lazyZip(expect).forall(matches)
41
+ }
42
+
41
43
def dump (path : String , content : Seq [String ]): Unit = {
42
44
val outFile = dotty.tools.io.File (path)
43
45
outFile.writeAll(content.mkString(" " , EOL , EOL ))
0 commit comments