@@ -4,27 +4,37 @@ open System.IO
44
55let toStreamImpl ( w : TextWriter ) param ( d : Diff ) =
66 let originalParam = param
7- let param = if originalParam.ensureFirstLineIsAligned then { originalParam with ensureFirstLineIsAligned = false } else originalParam
87
9- let addPathField path field = if path = " " then field else ( path + " ." + field)
8+ let param =
9+ if originalParam.ensureFirstLineIsAligned then
10+ { originalParam with ensureFirstLineIsAligned = false }
11+ else
12+ originalParam
13+
14+ let addPathField path field =
15+ if path = " " then field else ( path + " ." + field)
16+
1017 let addPathIndex path index = path + " [" + index + " ]"
11- let indentLike str = String.replicate ( String.length str) " "
12- let displayPath path = if path = " " then param.neutralName else path
18+
19+ let indentLike str =
20+ String.replicate ( String.length str) " "
21+
22+ let displayPath path =
23+ if path = " " then param.neutralName else path
1324
1425 let printValue indent path x1 x2 =
1526 let dpath = if path = " " then " " else path + " "
1627 w.WriteLine( $" %s {indent}%s {dpath}%s {param.x1Name} = %A {x1}" )
1728 w.WriteLine( $" %s {indent}%s {indentLike dpath}%s {param.x2Name} = %A {x2}" )
18-
29+
1930 let rec loop ( indent : string ) ( path : string ) ( d : Diff ) =
2031 match d with
21- | Diff.Value ( x1, x2) ->
22- printValue indent path x1 x2
23- | Diff.Record fields when fields.Count = 1 ->
24- loop indent ( addPathField path fields.[ 0 ]. Name) fields.[ 0 ]. Diff
32+ | Diff.Value ( x1, x2) -> printValue indent path x1 x2
33+ | Diff.Record fields when fields.Count = 1 -> loop indent ( addPathField path fields.[ 0 ]. Name) fields.[ 0 ]. Diff
2534 | Diff.Record fields ->
2635 w.WriteLine( $" %s {indent}%s {displayPath path} differs by %i {fields.Count} fields:" )
2736 let indent = indent + param.indent
37+
2838 for field in fields do
2939 loop indent ( addPathField path field.Name) field.Diff
3040 | Diff.UnionCase ( caseName1, caseName2) ->
@@ -37,35 +47,39 @@ let toStreamImpl (w: TextWriter) param (d: Diff) =
3747 | Diff.UnionField ( case, fields) ->
3848 w.WriteLine( $" %s {indent}%s {displayPath path} differs by union case %s {case} fields:" )
3949 let indent = indent + param.indent
50+
4051 for field in fields do
4152 loop indent ( addPathField path field.Name) field.Diff
4253 | Diff.Collection ( c1, c2, diffs) ->
4354 w.WriteLine( $" %s {indent}%s {displayPath path} collection differs:" )
4455 let indent = indent + param.indent
56+
4557 if c1 <> c2 then
4658 let countPath = addPathField path " Count"
4759 w.WriteLine( $" %s {indent}%s {countPath} %s {param.x1Name} = %i {c1}" )
4860 w.WriteLine( $" %s {indent}%s {indentLike countPath} %s {param.x2Name} = %i {c2}" )
61+
4962 for item in diffs do
5063 loop indent ( addPathIndex path item.Name) item.Diff
51- | Diff.Custom cd ->
52- cd.WriteTo( w, param, indent, path, loop)
64+ | Diff.Custom cd -> cd.WriteTo( w, param, indent, path, loop)
5365 | Diff.Dictionary ( keysInX1, keysInX2, common) ->
5466 w.WriteLine( $" %s {indent}%s {displayPath path} dictionary differs:" )
5567 let indent = indent + param.indent
68+
5669 for k in keysInX1 do
5770 w.WriteLine( $" %s {indent}%s {param.x2Name}[%s {k}] is missing" )
71+
5872 for k in keysInX2 do
5973 w.WriteLine( $" %s {indent}%s {param.x1Name}[%s {k}] is missing" )
74+
6075 for item in common do
6176 loop indent ( addPathIndex path item.Name) item.Diff
6277
6378 match originalParam.ensureFirstLineIsAligned, d with
6479 | true , Diff.Value ( x1, x2) ->
6580 w.WriteLine()
6681 printValue " " " " x1 x2
67- | true , Diff.Custom cd ->
68- cd.WriteTo( w, originalParam, " " , " " , loop)
82+ | true , Diff.Custom cd -> cd.WriteTo( w, originalParam, " " , " " , loop)
6983 | _ -> loop " " " " d
7084
7185let write ( param : PrintParams ) ( w : TextWriter ) ( d : Diff option ) =
0 commit comments