1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00
semantic/test/DiffSummarySpec.hs
2016-05-17 17:34:27 -04:00

35 lines
1022 B
Haskell

module DiffSummarySpec where
import Test.Hspec
import Diff
import Info
import Syntax
import Control.Comonad.Trans.Cofree
import Control.Monad.Trans.Free
import Patch
import Range
import Category
import Data.Set
import DiffSummary
arrayInfo :: Info
arrayInfo = Info (rangeAt 0) (singleton ArrayLiteral) 2
literalInfo :: Info
literalInfo = Info (rangeAt 1) (singleton StringLiteral) 1
testDiff :: Diff String Info
testDiff = free $ Free (pure arrayInfo :< Indexed [ free $ Pure (Insert (cofree $ literalInfo :< Leaf "a")) ])
testSummary :: DiffSummary Char
testSummary = DiffSummary { patch = Insert (DiffInfo "string literal"), parentAnnotations = [] }
spec :: Spec
spec = parallel $ do
describe "diffSummary" $ do
it "outputs a diff summary" $ do
diffSummary testDiff `shouldBe` [ DiffSummary { patch = Insert (DiffInfo "string literal"), parentAnnotations = [ DiffInfo "array literal" ] } ]
describe "show" $ do
it "should print adds" $
show testSummary `shouldBe` "Added an 'a' expression"