From 58338d6af2255590fe3e4270c14f4c1773142bd7 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 26 Sep 2017 09:50:50 -0400 Subject: [PATCH] Add tests that we recover before/after states through forward/backward permutations. --- test/DiffSpec.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/DiffSpec.hs b/test/DiffSpec.hs index e194da3a6..7dca7a786 100644 --- a/test/DiffSpec.hs +++ b/test/DiffSpec.hs @@ -27,11 +27,31 @@ spec = parallel $ do \ a b -> let diff = diffTerms a b :: Diff ListableSyntax (Record '[]) (Record '[]) in beforeTerm diff `shouldBe` Just a + prop "recovers the before term from forward permutations" $ + \ a b -> let wrap = termIn Nil . inj + c = wrap [a] in + beforeTerm (diffTerms (wrap [a, b, c]) (wrap [c, a, b :: Term ListableSyntax (Record '[])])) `shouldBe` Just (wrap [a, b, c]) + + prop "recovers the before term from backward permutations" $ + \ a b -> let wrap = termIn Nil . inj + c = wrap [a] in + beforeTerm (diffTerms (wrap [a, b, c]) (wrap [b, c, a :: Term ListableSyntax (Record '[])])) `shouldBe` Just (wrap [a, b, c]) + describe "afterTerm" $ do prop "recovers the after term" $ \ a b -> let diff = diffTerms a b :: Diff ListableSyntax (Record '[]) (Record '[]) in afterTerm diff `shouldBe` Just b + prop "recovers the after term from forward permutations" $ + \ a b -> let wrap = termIn Nil . inj + c = wrap [a] in + afterTerm (diffTerms (wrap [a, b, c]) (wrap [c, a, b :: Term ListableSyntax (Record '[])])) `shouldBe` Just (wrap [c, a, b]) + + prop "recovers the after term from backward permutations" $ + \ a b -> let wrap = termIn Nil . inj + c = wrap [a] in + afterTerm (diffTerms (wrap [a, b, c]) (wrap [b, c, a :: Term ListableSyntax (Record '[])])) `shouldBe` Just (wrap [b, c, a]) + prop "forward permutations are changes" $ \ a b -> let wrap = termIn Nil . inj c = wrap [a] in