on master help sign in
Add tests for parsing large and deeply nested lists
commite7ab7da204a0754e4ad422a6ffc51c065a41158f authorSimon Hengel <sol@typeful.net> dateMon 27 Aug 2018, 18:37 (8 years ago) parentdb33895
1 file changed+10
test/Data/Yaml/IncludeSpec.hs+10
test/Data/Yaml/IncludeSpec.hs+10
@@ -4,6 +4,7 @@ module Data.Yaml.IncludeSpec (main, spec) where
44
55import Test.Hspec
66import Data.List (isPrefixOf)
7+import qualified Data.ByteString.Lazy as LB
78import Data.Aeson
89import Data.Aeson.Internal (JSONPathElement(..))
910import Data.Yaml (ParseException(InvalidYaml))
@@ -52,6 +53,15 @@ spec = do
5253 it "throws Left (InvalidYaml (Just (YamlException \"Yaml file not found: ...\")))" $ do
5354 (decodeFile "./does_not_exist.yaml" :: IO (Maybe Value)) `shouldThrow` isYamlFileNotFoundException
5455
56+ context "with a 1K stack size limit" $ around_ inTempDirectory $ do
57+ context "with a large list" $ do
58+ it "succeeds" $ do
59+ let
60+ xs :: [Value]
61+ xs = replicate 5000 (Number 23)
62+ LB.writeFile "foo.yaml" (encode xs)
63+ decodeFile "foo.yaml" `shouldReturn` Just xs
64+
5565 describe "decodeFileEither" $ do
5666 context "when file does not exist" $ do
5767 it "returns Left (InvalidYaml (Just (YamlException \"Yaml file not found: ...\")))" $ do