summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-10-28 20:46:20 -0400
committerJoe Crayne <joe@jerkface.net>2018-10-28 20:46:20 -0400
commitee58401f82494ea48216e77edf2d80b8741336c1 (patch)
tree67f4fdd16ca655fffcdebdb8e22b035fe34bc2a2
parente9b600cb1b1376078082a1f2511b720d1508f579 (diff)
Modified testdiff.
-rw-r--r--haskell/examples/testdiff.hs52
1 files changed, 19 insertions, 33 deletions
diff --git a/haskell/examples/testdiff.hs b/haskell/examples/testdiff.hs
index 3f6e3e2..c821bfa 100644
--- a/haskell/examples/testdiff.hs
+++ b/haskell/examples/testdiff.hs
@@ -7,45 +7,31 @@ import Text.XXD
7source :: L.ByteString 7source :: L.ByteString
8source = "It could be said that Joe was here. I don't know what to do about it." 8source = "It could be said that Joe was here. I don't know what to do about it."
9 9
10patched :: L.ByteString 10target :: L.ByteString
11patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." 11target = "It could be said that Joe, the magnificent, was here. I don't know what to do about it."
12
13source2 :: L.ByteString
14source2 = "It could be said that Joe was absolutely here. I don't know what to do about it."
15 12
16delta :: Result VCDIFF 13delta :: Result VCDIFF
17delta = computeDiff defaultConfig source patched 14delta = computeDiff defaultConfig { flags = XD3_ADLER32 } source target
18 15
19delta2 :: Result VCDIFF 16delta2 :: Result VCDIFF
20delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source patched 17delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source target
18
19dump title bs kont = do
20 putStrLn title
21 mapM_ putStrLn $ xxd2 0 (L.toStrict bs)
22 kont
21 23
22main = do 24main = do
23 putStrLn "source" 25 dump "source" source $ putStrLn ""
24 mapM_ putStrLn $ xxd2 0 (L.toStrict source) 26 dump "target" target $ putStrLn ""
25 putStrLn "" 27 go "XD3_ADLER32" delta
26 putStrLn "target" 28 go "XD3_ADLER32" delta2
27 mapM_ putStrLn $ xxd2 0 (L.toStrict patched) 29
28 putStrLn "" 30go flgs delta = do
29 case delta2 of
30 Result δ me -> do
31 let d = encodeVCDIFF δ
32 putStrLn "diff(XD3_ADLER32)"
33 mapM_ putStrLn $ xxd2 0 (L.toStrict d)
34 print me
35 putStrLn ""
36 let Result patched' pe = applyPatch defaultConfig source2 δ
37 putStrLn "patched(XD3_ADLER32)"
38 mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched')
39 print pe
40 putStrLn "" 31 putStrLn ""
41 case delta of 32 case delta of
42 Result δ me -> do 33 Result δ me -> do
43 let d = encodeVCDIFF δ 34 let dif = encodeVCDIFF δ
44 putStrLn "diff(default)" 35 dump ("diff("++flgs++ ")") dif $ print me >> putStrLn ""
45 mapM_ putStrLn $ xxd2 0 (L.toStrict d) 36 let Result patched pe = applyPatch defaultConfig source δ
46 print me 37 dump ("patched("++flgs++")") patched $ print pe
47 putStrLn ""
48 putStrLn "patched(default)"
49 let Result patched' pe = applyPatch defaultConfig source2 δ
50 mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched')
51 print pe