diff options
author | Joe Crayne <joe@jerkface.net> | 2018-10-28 20:26:11 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-10-28 20:26:11 -0400 |
commit | e9b600cb1b1376078082a1f2511b720d1508f579 (patch) | |
tree | 7dc84c850d45f13e4aba2a2b7430325c33d93f54 /haskell | |
parent | b344e040b82cfbdb8b82bebd397f18661d7f88c7 (diff) |
Buggy test program.
Diffstat (limited to 'haskell')
-rw-r--r-- | haskell/examples/bug.hs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/haskell/examples/bug.hs b/haskell/examples/bug.hs new file mode 100644 index 0000000..c09adbe --- /dev/null +++ b/haskell/examples/bug.hs | |||
@@ -0,0 +1,56 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
2 | |||
3 | import qualified Data.ByteString.Lazy as L | ||
4 | import Data.VCDIFF | ||
5 | import Text.XXD | ||
6 | |||
7 | source :: L.ByteString | ||
8 | source = "It could be said that Joe was here. I don't know what to do about it." | ||
9 | |||
10 | target :: L.ByteString | ||
11 | target = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." | ||
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 | |||
16 | delta :: Result VCDIFF | ||
17 | delta = computeDiff defaultConfig { flags = XD3_ADLER32 } source target | ||
18 | |||
19 | delta2 :: Result VCDIFF | ||
20 | delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source target | ||
21 | |||
22 | main = do | ||
23 | putStrLn "source" | ||
24 | mapM_ putStrLn $ xxd2 0 (L.toStrict source) | ||
25 | putStrLn "" | ||
26 | putStrLn "target" | ||
27 | mapM_ putStrLn $ xxd2 0 (L.toStrict target) | ||
28 | putStrLn "" | ||
29 | case delta of | ||
30 | Result δ me -> do | ||
31 | let d = encodeVCDIFF δ | ||
32 | putStrLn "diff(default)" | ||
33 | mapM_ putStrLn $ xxd2 0 (L.toStrict d) | ||
34 | print me | ||
35 | {- | ||
36 | putStrLn "" | ||
37 | putStrLn "patched(default)" | ||
38 | let Result patched pe = applyPatch defaultConfig source2 δ | ||
39 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched) -- $ L.take 48 target') | ||
40 | print pe | ||
41 | -} | ||
42 | return () | ||
43 | putStrLn $ "source = " ++ show source | ||
44 | putStrLn $ "target = " ++ show target | ||
45 | putStrLn "" | ||
46 | case delta2 of | ||
47 | Result δ me -> do | ||
48 | let d = encodeVCDIFF δ | ||
49 | putStrLn "diff(XD3_ADLER32)" | ||
50 | mapM_ putStrLn $ xxd2 0 (L.toStrict d) | ||
51 | print me | ||
52 | putStrLn "" | ||
53 | let Result patched pe = applyPatch defaultConfig source2 δ | ||
54 | putStrLn "patched(XD3_ADLER32)" | ||
55 | mapM_ putStrLn $ xxd2 0 (L.toStrict patched) -- $ L.take 48 target') | ||
56 | print pe | ||