1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 05:41:54 +03:00
semantic/test/Semantic/Spec.hs

26 lines
1023 B
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
2018-05-15 01:39:41 +03:00
import Semantic.Parse
import System.Exit
2018-03-13 21:10:50 +03:00
import SpecHelpers
spec :: Spec
spec = parallel $ do
describe "parseBlob" $ do
it "returns error if given an unknown language (json)" $ do
output <- fmap runBuilder . runTask $ runParse JSONTermRenderer [ methodsBlob { blobLanguage = Unknown } ]
output `shouldBe` "{\"trees\":[{\"path\":\"methods.rb\",\"error\":\"NoLanguageForBlob \\\"methods.rb\\\"\",\"language\":\"Unknown\"}]}\n"
2018-09-25 22:04:58 +03:00
it "throws if given an unknown language for sexpression output" $ do
2018-09-27 00:55:34 +03:00
runTask (runParse SExpressionTermRenderer [methodsBlob { blobLanguage = Unknown }]) `shouldThrow` (== ExitFailure 1)
2017-05-30 17:33:48 +03:00
it "renders with the specified renderer" $ do
2018-05-15 01:39:41 +03:00
output <- fmap runBuilder . runTask $ runParse SExpressionTermRenderer [methodsBlob]
output `shouldBe` "(Statements\n (Method\n (Empty)\n (Identifier)\n (Statements)))\n"
where
2018-06-05 01:26:47 +03:00
methodsBlob = Blob "def foo\nend\n" "methods.rb" Ruby