1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 01:42:43 +03:00

Test that children assignments nest.

This commit is contained in:
Rob Rix 2017-04-10 10:35:39 -04:00
parent c9cf3d0bb8
commit c2482a0610

View File

@ -46,6 +46,13 @@ spec = do
it "does not match if its subrule does not match" $
runAssignment (children red) [ast Blue "b" [ast Green "a" []]] `shouldBe` Nothing
it "matches nested children" $ do
runAssignment
(rule 'A' *> children (rule 'B' *> children (rule 'C' *> content)))
[ ast 'A' "" [ ast 'B' "" [ ast 'C' "1" [] ] ] ]
`shouldBe`
Just ([], "1")
ast :: grammar -> ByteString -> [AST grammar] -> AST grammar
ast g s c = Rose (Node g s) c