1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00
semantic/test/Language/Ruby/Syntax/Spec.hs

23 lines
930 B
Haskell
Raw Normal View History

module Language.Ruby.Syntax.Spec where
2017-04-06 20:36:54 +03:00
import Data.Functor.Union
import qualified Data.Syntax.Comment as Comment
import Language.Ruby.Syntax
import Prologue
import Test.Hspec
spec :: Spec
2017-04-06 20:36:54 +03:00
spec = do
describe "stepAssignment" $ do
2017-04-06 21:13:09 +03:00
it "matches nodes" $ do
stepAssignment comment [makeCommentAST "hello"] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
it "attempts multiple alternatives" $ do
stepAssignment (if' <|> comment) [makeCommentAST "hello"] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
it "matches in sequence" $ do
stepAssignment ((,) <$> comment <*> comment) [makeCommentAST "hello", makeCommentAST "world"] `shouldBe` Just ([], (wrapU (Comment.Comment "hello"), wrapU (Comment.Comment "world")) :: (Program Syntax (), Program Syntax ()))
makeCommentAST :: ByteString -> AST Grammar
makeCommentAST s = Rose (Node Comment s) []