mirror of
https://github.com/github/semantic.git
synced 2025-01-03 04:51:57 +03:00
Generalize the fixture builder.
This commit is contained in:
parent
2b460b223c
commit
c44fb8a5c3
@ -10,13 +10,13 @@ spec :: Spec
|
||||
spec = do
|
||||
describe "stepAssignment" $ do
|
||||
it "matches nodes" $ do
|
||||
stepAssignment comment [makeCommentAST "hello"] `shouldBe` Just ([], wrapU (Comment.Comment "hello") :: Program Syntax ())
|
||||
stepAssignment comment [ast Comment "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 ())
|
||||
stepAssignment (if' <|> comment) [ast Comment "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 ()))
|
||||
stepAssignment ((,) <$> comment <*> comment) [ast Comment "hello" [], ast Comment "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) []
|
||||
ast :: Grammar -> ByteString -> [AST Grammar] -> AST Grammar
|
||||
ast g s c = Rose (Node g s) c
|
||||
|
Loading…
Reference in New Issue
Block a user