From b8ba07522b48025e67ef62eebb17073f3ec8c374 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 27 Jun 2016 15:28:11 -0400 Subject: [PATCH] Test that Interpreter produces correct diffs. --- test/InterpreterSpec.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/InterpreterSpec.hs b/test/InterpreterSpec.hs index 936aa2b3e..fe6d3764c 100644 --- a/test/InterpreterSpec.hs +++ b/test/InterpreterSpec.hs @@ -1,13 +1,17 @@ +{-# LANGUAGE DataKinds #-} module InterpreterSpec where import Category import Diff import Data.Record +import Data.Record.Arbitrary () import Interpreter import Patch import Prologue import Syntax +import Term.Arbitrary import Test.Hspec +import Test.Hspec.QuickCheck spec :: Spec spec = parallel $ do @@ -16,3 +20,7 @@ spec = parallel $ do let termA = cofree $ (StringLiteral .: RNil) :< Leaf "t\776" termB = cofree $ (StringLiteral .: RNil) :< Leaf "\7831" in diffTerms (free . Free) ((==) `on` extract) diffCost termA termB `shouldBe` free (Pure (Replace termA termB)) + + prop "produces correct diffs" $ + \ a b -> let diff = diffTerms (free . Free) ((==) `on` extract) diffCost (toTerm a) (toTerm b) :: Diff Text (Record '[Category]) in + (beforeTerm diff, afterTerm diff) `shouldBe` (Just (toTerm a), Just (toTerm b))