packages feed

ruby-marshal 0.1.2 → 0.1.3

raw patch · 4 files changed

+132/−6 lines, 4 filesdep ~cerealdep ~containers

Dependency ranges changed: cereal, containers

Files

CHANGELOG.md view
@@ -1,3 +1,11 @@+# 0.1.3++- Relaxed version bounds.++# 0.1.2++- Relaxed version bounds.+ # 0.1.1  - Added some minor style changes.
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015 Philip Cunningham+Copyright (c) 2015-2017 Philip Cunningham  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
ruby-marshal.cabal view
@@ -1,5 +1,5 @@ name: ruby-marshal-version: 0.1.2+version: 0.1.3 synopsis: Parse a subset of Ruby objects serialised with Marshal.dump. description: Parse a subset of Ruby objects serialised with Marshal.dump. homepage: https://github.com/filib/ruby-marshal@@ -9,7 +9,7 @@ maintainer: hello@filib.io category: Data build-type: Simple-tested-with: GHC == 7.8, GHC == 7.10+tested-with: GHC == 7.8, GHC == 7.10, GHC == 8.6.5 cabal-version: >= 1.10 extra-source-files: CHANGELOG.md @@ -25,9 +25,9 @@     src   build-depends:       base        >= 4.7    && <= 5-    , cereal      >= 0.4.0  && <  0.5.5+    , cereal      >= 0.4.0  && <  0.6.0     , bytestring  >= 0.9.0  && <= 0.12.0-    , containers  >= 0.5.0  && <= 0.6.0+    , containers  >= 0.5.0  && <= 0.7.0     , string-conv >= 0.1    && <= 0.2     , mtl         >= 2.1.0  && <= 2.3.0     , vector      >= 0.10.0 && <  0.12.1@@ -60,7 +60,14 @@   default-language:     Haskell2010   other-modules:-    Spec+    Data.Ruby.Marshal+    Data.Ruby.Marshal.Encoding+    Data.Ruby.Marshal.Get+    Data.Ruby.Marshal.Int+    Data.Ruby.Marshal.Monad+    Data.Ruby.Marshal.RubyObject+    Data.Ruby.Marshal.Types+    MarshalSpec   main-is:     Spec.hs   type:
+ test/MarshalSpec.hs view
@@ -0,0 +1,111 @@+{-# LANGUAGE OverloadedStrings #-}++module MarshalSpec (spec) where++import Data.Ruby.Marshal+import Test.Hspec++import qualified Data.ByteString as BS+import qualified Data.Vector     as V++loadBin :: FilePath -> IO (Maybe RubyObject)+loadBin path = do+    bs <- BS.readFile path+    return $ decode bs++spec :: Spec+spec = describe "load" $ do+  context "when we have nil" $+    it "should parse" $ do+      object <- loadBin "test/bin/nil.bin"+      object `shouldBe` Just RNil++  context "when we have true" $+    it "should parse" $ do+      object <- loadBin "test/bin/true.bin"+      object `shouldBe` Just (RBool True)++  context "when we have false" $+    it "should parse" $ do+      object <- loadBin "test/bin/false.bin"+      object `shouldBe` Just (RBool False)++  context "when we have 0" $+    it "should parse" $ do+      object <- loadBin "test/bin/0.bin"+      object `shouldBe` Just (RFixnum 0)++  context "when we have -42" $+    it "should parse" $ do+      object <- loadBin "test/bin/neg42.bin"+      object `shouldBe` Just (RFixnum (-42))++  context "when we have 42" $+    it "should parse" $ do+      object <- loadBin "test/bin/42.bin"+      object `shouldBe` Just (RFixnum 42)++  context "when we have -2048" $+    it "should parse" $ do+      object <- loadBin "test/bin/neg2048.bin"+      object `shouldBe` Just (RFixnum (-2048))++  context "when we have 2048" $+    it "should parse" $ do+      object <- loadBin "test/bin/2048.bin"+      object `shouldBe` Just (RFixnum 2048)++  context "when we have [nil]" $+    it "should parse" $ do+      object <- loadBin "test/bin/nilArray.bin"+      object `shouldBe` Just (RArray $ V.fromList [RNil])++  context "when we have [true, false]" $+    it "should parse" $ do+      object <- loadBin "test/bin/boolArray.bin"+      object `shouldBe` Just (RArray $ V.fromList [RBool True, RBool False])++  context "when we have [-2048, -42, 0, 42, 2048]" $+    it "should parse" $ do+      object <- loadBin "test/bin/fixnumArray.bin"+      object `shouldBe` Just (RArray $ V.fromList [RFixnum (-2048), RFixnum (-42), RFixnum 0, RFixnum 42, RFixnum 2048])++  context "when we have ['hello', 'haskell', 'hello', 'haskell']" $+    it "should parse" $ do+      object <- loadBin "test/bin/stringArray.bin"+      object `shouldBe` Just (RArray $ V.fromList [RIVar (RString "hello", UTF_8), RIVar (RString "haskell", UTF_8), RIVar (RString "hello", UTF_8), RIVar (RString "haskell", UTF_8)])++  context "when we have [:hello, :haskell, :hello, :haskell]" $+    it "should parse" $ do+      object <- loadBin "test/bin/symbolArray.bin"+      object `shouldBe` Just (RArray $ V.fromList [RSymbol "hello", RSymbol "haskell", RSymbol "hello", RSymbol "haskell"])++  context "when we have { 0 => false, 1 => true }" $+    it "should parse" $ do+      object <- loadBin "test/bin/fixnumHash.bin"+      object `shouldBe` Just (RHash $ V.fromList [(RFixnum 0, RBool False), (RFixnum 1, RBool True)])++  context "when we have 'hello haskell'" $+    it "should parse" $ do+      object <- loadBin "test/bin/UTF_8_String.bin"+      object `shouldBe` Just (RIVar (RString "hello haskell", UTF_8))++  context "when we have 'hello haskell' in US-ASCII" $+    it "should parse" $ do+      object <- loadBin "test/bin/US_ASCII_String.bin"+      object `shouldBe` Just (RIVar (RString "hello haskell", US_ASCII))++  context "when we have 'hello haskell' in SHIFT_JIS" $+    it "should parse" $ do+      object <- loadBin "test/bin/Shift_JIS_String.bin"+      object `shouldBe` Just (RIVar (RString "hello haskell", Shift_JIS))++  context "when we have 3.33333" $+    it "should parse" $ do+      object <- loadBin "test/bin/float.bin"+      object `shouldBe` Just (RFloat 3.33333)++  context "when we have :hello_haskell" $+    it "should parse" $ do+      object <- loadBin "test/bin/symbol.bin"+      object `shouldBe` Just (RSymbol "hello_haskell")