1
1
mirror of https://github.com/github/semantic.git synced 2024-11-29 02:44:36 +03:00

Use a helper to construct the expected AST values.

This commit is contained in:
Rob Rix 2017-04-07 09:14:03 -04:00
parent 8d536fa825
commit 830c8f8c94

View File

@ -10,10 +10,13 @@ spec :: Spec
spec = do
describe "stepAssignment" $ do
it "matches nodes" $ do
stepAssignment comment [Rose (Node Comment "hello") []] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
stepAssignment comment [makeCommentAST "hello"] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
it "attempts multiple alternatives" $ do
stepAssignment (if' <|> comment) [Rose (Node Comment "hello") []] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
stepAssignment (if' <|> comment) [makeCommentAST "hello"] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
it "matches in sequence" $ do
stepAssignment ((,) <$> comment <*> comment) [Rose (Node Comment "hello") [], Rose (Node Comment "world") []] `shouldBe` Just ([], (wrapU (Comment.Comment "hello"), wrapU (Comment.Comment "world")) :: (Program Syntax (), Program Syntax ()))
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) []