2018-03-13 21:10:50 +03:00
|
|
|
module Semantic.Spec (spec) where
|
2017-04-22 00:10:50 +03:00
|
|
|
|
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
|
2017-09-29 22:09:58 +03:00
|
|
|
import System.Exit
|
2018-03-13 21:10:50 +03:00
|
|
|
|
|
|
|
import SpecHelpers
|
|
|
|
|
2017-04-22 00:10:50 +03:00
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = parallel $ do
|
2017-05-31 19:25:40 +03:00
|
|
|
describe "parseBlob" $ do
|
2018-08-30 22:51:29 +03:00
|
|
|
it "returns error if given an unknown language (json)" $ do
|
|
|
|
output <- fmap runBuilder . runTask $ runParse JSONTermRenderer [ methodsBlob { blobLanguage = Unknown } ]
|
|
|
|
output `shouldBe` "{\"trees\":[{\"error\":{\"path\":\"methods.rb\",\"language\":\"Unknown\",\"message\":\"NoLanguageForBlob \\\"methods.rb\\\"\"}}]}\n"
|
|
|
|
|
|
|
|
it "drops results for sexpression output" $ do
|
|
|
|
output <- fmap runBuilder . runTask $ runParse SExpressionTermRenderer [ methodsBlob { blobLanguage = Unknown } ]
|
|
|
|
output `shouldBe` ""
|
2017-04-22 00:10:50 +03:00
|
|
|
|
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]
|
2018-06-01 21:44:03 +03:00
|
|
|
output `shouldBe` "(Statements\n (Method\n (Empty)\n (Identifier)\n (Statements)))\n"
|
2017-04-22 00:10:50 +03:00
|
|
|
where
|
2018-06-05 01:26:47 +03:00
|
|
|
methodsBlob = Blob "def foo\nend\n" "methods.rb" Ruby
|