1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

🔥 Use empty records in DiffSpec.

This commit is contained in:
Rob Rix 2017-09-25 19:54:34 -04:00
parent bd4dee20d5
commit 86ede39a58

View File

@ -11,7 +11,6 @@ import qualified Data.Syntax.Statement as Statement
import Data.Record import Data.Record
import Data.Union import Data.Union
import Diff import Diff
import Info
import Interpreter import Interpreter
import RWS import RWS
import Term import Term
@ -31,20 +30,18 @@ type Syntax = Union
spec :: Spec spec :: Spec
spec = parallel $ do spec = parallel $ do
let decorate = defaultFeatureVectorDecorator (category . termAnnotation)
prop "equality is reflexive" $ prop "equality is reflexive" $
\ diff -> diff `shouldBe` (diff :: Diff Syntax (Record '[Category]) (Record '[Category])) \ diff -> diff `shouldBe` (diff :: Diff Syntax (Record '[]) (Record '[]))
prop "equal terms produce identity diffs" $ prop "equal terms produce identity diffs" $
\ a -> let term = decorate (a :: Term Syntax (Record '[Category])) in \ term -> diffCost (diffTerms term (term :: Term Syntax (Record '[]))) `shouldBe` 0
diffCost (diffTerms term term) `shouldBe` 0
describe "beforeTerm" $ do describe "beforeTerm" $ do
prop "recovers the before term" $ prop "recovers the before term" $
\ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in \ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[]) (Record '[]) in
beforeTerm diff `shouldBe` Just a beforeTerm diff `shouldBe` Just a
describe "afterTerm" $ do describe "afterTerm" $ do
prop "recovers the after term" $ prop "recovers the after term" $
\ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[Category]) (Record '[Category]) in \ a b -> let diff = diffTerms a b :: Diff Syntax (Record '[]) (Record '[]) in
afterTerm diff `shouldBe` Just b afterTerm diff `shouldBe` Just b