@@ -3,6 +3,7 @@
33{-# LANGUAGE ScopedTypeVariables #-}
44{-# LANGUAGE OverloadedStrings #-}
55{-# LANGUAGE TemplateHaskell #-}
6+{-# LANGUAGE TupleSections #-}
67
78module Data.YamlSpec (main, spec) where
89
@@ -29,6 +30,7 @@ import qualified Data.HashMap.Strict as M
2930import qualified Data.Text as T
3031import Data.Aeson.TH
3132import Data.Text (Text)
33+import Data.Text.Encoding (decodeUtf8)
3234import Data.Vector (Vector)
3335import qualified Data.Vector as V
3436import Data.HashMap.Strict (HashMap)
@@ -166,6 +168,19 @@ spec = do
166168
167169 it "truncates files" caseTruncatesFiles
168170
171+ it "quoting keys #137" $ do
172+ let keys = T.words "true false NO YES 1.2 1e5 null"
173+ bs = D.encode $ M.fromList $ map (, ()) keys
174+ text = decodeUtf8 bs
175+ forM_ keys $ \key -> do
176+ let quoted = T.concat ["'", key, "'"]
177+ unless (quoted `T.isInfixOf` text) $ error $ concat
178+ [ "Could not find quoted key: "
179+ , T.unpack quoted
180+ , "\n\n"
181+ , T.unpack text
182+ ] :: IO ()
183+
169184
170185specialStrings :: [T.Text]
171186specialStrings =