1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 17:05:33 +03:00
semantic/test/Semantic/Spec.hs

33 lines
1.1 KiB
Haskell
Raw Normal View History

2018-03-13 21:10:50 +03:00
module Semantic.Spec (spec) where
2017-09-27 19:41:41 +03:00
import Data.Diff
2017-09-27 19:29:07 +03:00
import Data.Patch
import System.Exit
2018-03-13 21:10:50 +03:00
import SpecHelpers
spec :: Spec
spec = parallel $ do
describe "parseBlob" $ do
it "throws if not given a language" $ do
runTask (parseBlob SExpressionTermRenderer methodsBlob { blobLanguage = Nothing }) `shouldThrow` (\ code -> case code of
ExitFailure 1 -> True
_ -> False)
2017-05-30 17:33:48 +03:00
it "renders with the specified renderer" $ do
output <- runTask $ parseBlob SExpressionTermRenderer methodsBlob
output `shouldBe` "(Program\n (Method\n (Empty)\n (Identifier)\n ([])))\n"
describe "diffTermPair" $ do
2017-12-10 19:46:17 +03:00
it "produces an Insert when the first term is missing" $ do
result <- runTask (diffTermPair replacing (That (termIn () [])))
result `shouldBe` (Diff (Patch (Insert (In () []))) :: Diff [] () ())
2017-12-10 19:46:17 +03:00
it "produces a Delete when the second term is missing" $ do
result <- runTask (diffTermPair replacing (This (termIn () [])))
result `shouldBe` (Diff (Patch (Delete (In () []))) :: Diff [] () ())
where
2017-12-11 21:59:05 +03:00
methodsBlob = Blob "def foo\nend\n" "methods.rb" (Just Ruby)