diff options
Diffstat (limited to 'haskell/examples/testdiff.hs')
-rw-r--r-- | haskell/examples/testdiff.hs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/haskell/examples/testdiff.hs b/haskell/examples/testdiff.hs index 7e20dc5..3f6e3e2 100644 --- a/haskell/examples/testdiff.hs +++ b/haskell/examples/testdiff.hs | |||
@@ -10,22 +10,42 @@ source = "It could be said that Joe was here. I don't know what to do about it." | |||
10 | patched :: L.ByteString | 10 | patched :: L.ByteString |
11 | patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." | 11 | patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." |
12 | 12 | ||
13 | source2 :: L.ByteString | ||
14 | source2 = "It could be said that Joe was absolutely here. I don't know what to do about it." | ||
15 | |||
13 | delta :: Result VCDIFF | 16 | delta :: Result VCDIFF |
14 | delta = computeDiff defaultConfig source patched | 17 | delta = computeDiff defaultConfig source patched |
15 | 18 | ||
19 | delta2 :: Result VCDIFF | ||
20 | delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source patched | ||
21 | |||
16 | main = do | 22 | main = do |
23 | putStrLn "source" | ||
17 | mapM_ putStrLn $ xxd2 0 (L.toStrict source) | 24 | mapM_ putStrLn $ xxd2 0 (L.toStrict source) |
18 | putStrLn "" | 25 | putStrLn "" |
26 | putStrLn "target" | ||
19 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched) | 27 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched) |
20 | putStrLn "" | 28 | putStrLn "" |
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 "" | ||
21 | case delta of | 41 | case delta of |
22 | Result δ@(VCDIFF d) me -> do | 42 | Result δ me -> do |
23 | -- mapM_ (mapM_ putStrLn . xxd2 0) (chunksOf 16 d) | 43 | let d = encodeVCDIFF δ |
44 | putStrLn "diff(default)" | ||
24 | mapM_ putStrLn $ xxd2 0 (L.toStrict d) | 45 | mapM_ putStrLn $ xxd2 0 (L.toStrict d) |
25 | print me | 46 | print me |
26 | putStrLn "" | 47 | putStrLn "" |
27 | let Result patched' pe = applyPatch defaultConfig source δ | 48 | putStrLn "patched(default)" |
49 | let Result patched' pe = applyPatch defaultConfig source2 δ | ||
28 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') | 50 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') |
29 | print pe | 51 | print pe |
30 | print ("source",source) | ||
31 | print ("patched",patched) | ||