1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Only allow comparisons between terms with the same category.

This commit is contained in:
Rob Rix 2016-06-28 15:02:41 -04:00
parent be3f43702b
commit 83a88d0e32

View File

@ -29,8 +29,9 @@ spec = parallel $ do
\ (grams, d) -> length (featureVector d (fromList (grams :: [Gram Text]))) `shouldBe` d
describe "rws" $ do
let compare a b = if extract a == extract b then Just (pure (Replace a b)) else Nothing
prop "produces correct diffs" $
\ as bs -> let tas = toTerm <$> as
tbs = toTerm <$> bs
diff = free (Free (pure Program :< Indexed (rws ((Just .) . (pure .) . Replace) identity tas tbs :: [Diff Text Category]))) in
diff = free (Free (pure Program :< Indexed (rws compare identity tas tbs :: [Diff Text Category]))) in
(beforeTerm diff, afterTerm diff) `shouldBe` (Just (cofree (Program :< Indexed tas)), Just (cofree (Program :< Indexed tbs)))