From ee58401f82494ea48216e77edf2d80b8741336c1 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sun, 28 Oct 2018 20:46:20 -0400 Subject: Modified testdiff. --- haskell/examples/testdiff.hs | 52 ++++++++++++++++---------------------------- 1 file 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 source :: L.ByteString source = "It could be said that Joe was here. I don't know what to do about it." -patched :: L.ByteString -patched = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." - -source2 :: L.ByteString -source2 = "It could be said that Joe was absolutely here. I don't know what to do about it." +target :: L.ByteString +target = "It could be said that Joe, the magnificent, was here. I don't know what to do about it." delta :: Result VCDIFF -delta = computeDiff defaultConfig source patched +delta = computeDiff defaultConfig { flags = XD3_ADLER32 } source target delta2 :: Result VCDIFF -delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source patched +delta2 = computeDiff defaultConfig { flags = XD3_ADLER32 } source target + +dump title bs kont = do + putStrLn title + mapM_ putStrLn $ xxd2 0 (L.toStrict bs) + kont main = do - putStrLn "source" - mapM_ putStrLn $ xxd2 0 (L.toStrict source) - putStrLn "" - putStrLn "target" - mapM_ putStrLn $ xxd2 0 (L.toStrict patched) - putStrLn "" - case delta2 of - Result δ me -> do - let d = encodeVCDIFF δ - putStrLn "diff(XD3_ADLER32)" - mapM_ putStrLn $ xxd2 0 (L.toStrict d) - print me - putStrLn "" - let Result patched' pe = applyPatch defaultConfig source2 δ - putStrLn "patched(XD3_ADLER32)" - mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') - print pe + dump "source" source $ putStrLn "" + dump "target" target $ putStrLn "" + go "XD3_ADLER32" delta + go "XD3_ADLER32" delta2 + +go flgs delta = do putStrLn "" case delta of Result δ me -> do - let d = encodeVCDIFF δ - putStrLn "diff(default)" - mapM_ putStrLn $ xxd2 0 (L.toStrict d) - print me - putStrLn "" - putStrLn "patched(default)" - let Result patched' pe = applyPatch defaultConfig source2 δ - mapM_ putStrLn $ xxd2 0 (L.toStrict patched') -- $ L.take 48 patched') - print pe + let dif = encodeVCDIFF δ + dump ("diff("++flgs++ ")") dif $ print me >> putStrLn "" + let Result patched pe = applyPatch defaultConfig source δ + dump ("patched("++flgs++")") patched $ print pe -- cgit v1.2.3