packages feed

yaml 0.8.8.1 → 0.8.8.2

raw patch · 3 files changed

+15/−9 lines, 3 files

Files

Data/Yaml.hs view
@@ -66,7 +66,6 @@ import Data.Aeson.Types (Pair, parseMaybe, parseEither, Parser) import Text.Libyaml hiding (encode, decode, encodeFile, decodeFile) import Data.ByteString (ByteString)-import qualified Data.ByteString.Char8 as S8 import qualified Data.Map as Map import System.IO.Unsafe (unsafePerformIO) import Control.Exception (try, throwIO, fromException, Exception, SomeException, AsyncException)@@ -88,8 +87,13 @@ import Data.Text.Read #if MIN_VERSION_aeson(0, 7, 0) import Data.Scientific (fromFloatDigits)+import qualified Data.Text.Encoding as TE+import qualified Data.Text.Lazy as TL+import Data.Text.Lazy.Builder (toLazyText)+import Data.Aeson.Encode (encodeToTextBuilder) #else import Data.Attoparsec.Number+import qualified Data.ByteString.Char8 as S8 #endif import Control.Monad.Trans.Resource (ResourceT, runResourceT) @@ -140,7 +144,12 @@ objToEvents' Null rest = EventScalar "null" NullTag PlainNoTag Nothing : rest objToEvents' (Bool True) rest = EventScalar "true" BoolTag PlainNoTag Nothing : rest objToEvents' (Bool False) rest = EventScalar "false" BoolTag PlainNoTag Nothing : rest+#if MIN_VERSION_aeson(0,7,0)+-- Use aeson's implementation which gets rid of annoying decimal points+objToEvents' n@Number{} rest = EventScalar (TE.encodeUtf8 $ TL.toStrict $ toLazyText $ encodeToTextBuilder n) IntTag PlainNoTag Nothing : rest+#else objToEvents' (Number n) rest = EventScalar (S8.pack $ show n) IntTag PlainNoTag Nothing : rest+#endif  pairToEvents :: Pair -> [Y.Event] -> [Y.Event] pairToEvents (k, v) rest =
test/main.hs view
@@ -74,6 +74,7 @@         it "parses as string when quoted" caseQuotedNumber         it "parses as number when unquoted" caseUnquotedNumber         it "parses as number !!str is present" caseAttribNumber+        it "integers have no decimals" caseIntegerDecimals     describe "booleans" $ do         it "parses when all lowercase" caseLowercaseBool         it "parses when all uppercase" caseUppercaseBool@@ -91,12 +92,7 @@      describe "pretty output" $ do         it "simple nulls" $ D.encode (object ["foo" .= D.Null]) `shouldBe` "foo: null\n"-        it "simple numbers" $ D.encode (object ["foo" .= (4 :: Int)]) `shouldBe`-#if MIN_VERSION_aeson(0, 7, 0)-            "foo: 4.0\n" -- FIXME should this be reported as a bug upstream to aeson?-#else-            "foo: 4\n"-#endif+        it "simple numbers" $ D.encode (object ["foo" .= (4 :: Int)]) `shouldBe` "foo: 4\n"         it "True" $ D.encode (object ["foo" .= True]) `shouldBe` "foo: true\n"         it "False" $ D.encode (object ["foo" .= False]) `shouldBe` "foo: false\n"         it "simple string" $ D.encode (object ["foo" .= ("bar" :: T.Text)]) `shouldBe` "foo: bar\n"@@ -391,10 +387,11 @@         , ("null", D.Null)         ] -caseQuotedNumber, caseUnquotedNumber, caseAttribNumber :: Assertion+caseQuotedNumber, caseUnquotedNumber, caseAttribNumber, caseIntegerDecimals :: Assertion caseQuotedNumber = D.decode "foo: \"1234\"" @?= Just (object [("foo", D.String "1234")]) caseUnquotedNumber = D.decode "foo: 1234" @?= Just (object [("foo", D.Number 1234)]) caseAttribNumber = D.decode "foo: !!str 1234" @?= Just (object [("foo", D.String "1234")])+caseIntegerDecimals = D.encode (1 :: Int) @?= "1\n...\n"  obj :: Maybe D.Value obj = Just (object [("foo", D.Bool False), ("bar", D.Bool True), ("baz", D.Bool True)])
yaml.cabal view
@@ -1,5 +1,5 @@ name:            yaml-version:         0.8.8.1+version:         0.8.8.2 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov