THRIFT-3482 Haskell JSON protocol does not encode binary field as Base64
diff --git a/lib/hs/test/BinarySpec.hs b/lib/hs/test/BinarySpec.hs
index 5039610..d692fab 100644
--- a/lib/hs/test/BinarySpec.hs
+++ b/lib/hs/test/BinarySpec.hs
@@ -66,3 +66,26 @@
         writeVal proto (TString val)
         bin <- tRead trans 7
         (LBS.unpack bin) `shouldBe` [0, 0, 0, 3, 97, 97, 97]
+
+    describe "binary" $ do
+      it "writes" $ do
+        trans <- openMemoryBuffer
+        let proto = BinaryProtocol trans
+        writeVal proto (TBinary $ LBS.pack [42, 43, 44])
+        bin <- tRead trans 100
+        (LBS.unpack bin) `shouldBe` [0, 0, 0, 3, 42, 43, 44]
+
+      it "reads" $ do
+        trans <- openMemoryBuffer
+        let proto = BinaryProtocol trans
+        tWrite trans $ LBS.pack [0, 0, 0, 3, 42, 43, 44]
+        val <- readVal proto (T_BINARY)
+        val `shouldBe` (TBinary $ LBS.pack [42, 43, 44])
+
+      prop "round trip" $ \val -> do
+        trans <- openMemoryBuffer
+        let proto = BinaryProtocol trans
+        writeVal proto (TBinary $ LBS.pack val)
+        val2 <- readVal proto (T_BINARY)
+        val2 `shouldBe` (TBinary $ LBS.pack val)
+
diff --git a/lib/hs/test/CompactSpec.hs b/lib/hs/test/CompactSpec.hs
index 22708b4..5540e7b 100644
--- a/lib/hs/test/CompactSpec.hs
+++ b/lib/hs/test/CompactSpec.hs
@@ -56,3 +56,26 @@
         writeVal proto $ TDouble val
         val2 <- readVal proto T_DOUBLE
         val2 `shouldBe` (TDouble val)
+
+    describe "binary" $ do
+      it "writes" $ do
+        trans <- openMemoryBuffer
+        let proto = CompactProtocol trans
+        writeVal proto (TBinary $ LBS.pack [42, 43, 44])
+        bin <- tRead trans 100
+        (LBS.unpack bin) `shouldBe` [3, 42, 43, 44]
+
+      it "reads" $ do
+        trans <- openMemoryBuffer
+        let proto = CompactProtocol trans
+        tWrite trans $ LBS.pack [3, 42, 43, 44]
+        val <- readVal proto (T_BINARY)
+        val `shouldBe` (TBinary $ LBS.pack [42, 43, 44])
+
+      prop "round trip" $ \val -> do
+        trans <- openMemoryBuffer
+        let proto = CompactProtocol trans
+        writeVal proto (TBinary $ LBS.pack val)
+        val2 <- readVal proto (T_BINARY)
+        val2 `shouldBe` (TBinary $ LBS.pack val)
+
diff --git a/lib/hs/test/JSONSpec.hs b/lib/hs/test/JSONSpec.hs
index 079be02..022c826 100644
--- a/lib/hs/test/JSONSpec.hs
+++ b/lib/hs/test/JSONSpec.hs
@@ -22,6 +22,7 @@
 import Test.Hspec
 import Test.Hspec.QuickCheck (prop)
 
+import qualified Data.ByteString.Lazy as LBS
 import qualified Data.ByteString.Lazy.Char8 as C
 
 import Thrift.Types
@@ -82,6 +83,35 @@
         val2 <- readVal proto (T_STRING)
         val2 `shouldBe` (TString $ C.pack val)
 
+    describe "binary" $ do
+      it "writes with padding" $ do
+        trans <- openMemoryBuffer
+        let proto = JSONProtocol trans
+        writeVal proto (TBinary $ LBS.pack [1])
+        bin <- tRead trans 100
+        (C.unpack bin) `shouldBe` "\"AQ==\""
+
+      it "reads with padding" $ do
+        trans <- openMemoryBuffer
+        let proto = JSONProtocol trans
+        tWrite trans $ C.pack "\"AQ==\""
+        val <- readVal proto (T_BINARY)
+        val `shouldBe` (TBinary $ LBS.pack [1])
+
+      it "reads without padding" $ do
+        trans <- openMemoryBuffer
+        let proto = JSONProtocol trans
+        tWrite trans $ C.pack "\"AQ\""
+        val <- readVal proto (T_BINARY)
+        val `shouldBe` (TBinary $ LBS.pack [1])
+
+      prop "round trip" $ \val -> do
+        trans <- openMemoryBuffer
+        let proto = JSONProtocol trans
+        writeVal proto (TBinary $ LBS.pack val)
+        val2 <- readVal proto (T_BINARY)
+        val2 `shouldBe` (TBinary $ LBS.pack val)
+
     describe "list" $ do
       it "writes empty list" $ do
         trans <- openMemoryBuffer