66{-# LANGUAGE NoMonomorphismRestriction #-}
77{-# LANGUAGE OverloadedStrings #-}
88{-# LANGUAGE ScopedTypeVariables #-}
9+ {-# LANGUAGE TypeApplications #-}
910
1011{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
1112
@@ -29,9 +30,10 @@ import HaskellWorks.Hspec.Hedgehog
2930import Hedgehog
3031import Test.Hspec
3132
32- import qualified Data.ByteString as BS
33- import qualified Data.Vector.Storable as DVS
34- import qualified HaskellWorks.Data.TreeCursor as TC
33+ import qualified Data.ByteString as BS
34+ import qualified Data.Vector.Storable as DVS
35+ import qualified HaskellWorks.Data.FromByteString as BS
36+ import qualified HaskellWorks.Data.TreeCursor as TC
3537
3638{-# ANN module ("HLint: ignore Redundant do" :: String) #-}
3739{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
@@ -45,11 +47,11 @@ ss = TC.subtreeSize
4547
4648spec :: Spec
4749spec = describe " HaskellWorks.Data.Xml.Succinct.CursorSpec" $ do
48- genSpec " DVS.Vector Word8" (undefined :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word8 )) (SimpleBalancedParens (DVS. Vector Word8 )))
49- genSpec " DVS.Vector Word16" (undefined :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word16 )) (SimpleBalancedParens (DVS. Vector Word16 )))
50- genSpec " DVS.Vector Word32" (undefined :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word32 )) (SimpleBalancedParens (DVS. Vector Word32 )))
51- genSpec " DVS.Vector Word64" (undefined :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word64 )) (SimpleBalancedParens (DVS. Vector Word64 )))
52- genSpec " Poppy512" (undefined :: XmlCursor BS. ByteString Poppy512 (SimpleBalancedParens (DVS. Vector Word64 )))
50+ genSpec " DVS.Vector Word8" (BS. fromByteString :: BS. ByteString -> XmlCursor BS. ByteString (BitShown (DVS. Vector Word8 )) (SimpleBalancedParens (DVS. Vector Word8 )))
51+ genSpec " DVS.Vector Word16" (BS. fromByteString :: BS. ByteString -> XmlCursor BS. ByteString (BitShown (DVS. Vector Word16 )) (SimpleBalancedParens (DVS. Vector Word16 )))
52+ genSpec " DVS.Vector Word32" (BS. fromByteString :: BS. ByteString -> XmlCursor BS. ByteString (BitShown (DVS. Vector Word32 )) (SimpleBalancedParens (DVS. Vector Word32 )))
53+ genSpec " DVS.Vector Word64" (BS. fromByteString :: BS. ByteString -> XmlCursor BS. ByteString (BitShown (DVS. Vector Word64 )) (SimpleBalancedParens (DVS. Vector Word64 )))
54+ genSpec " Poppy512" (BS. fromByteString :: BS. ByteString -> XmlCursor BS. ByteString Poppy512 (SimpleBalancedParens (DVS. Vector Word64 )))
5355 it " Loads same Xml consistentally from different backing vectors" $ requireTest $ do
5456 let cursor8 = " {\n \" widget\" : {\n \" debug\" : \" on\" } }" :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word8 )) (SimpleBalancedParens (DVS. Vector Word8 ))
5557 let cursor16 = " {\n \" widget\" : {\n \" debug\" : \" on\" } }" :: XmlCursor BS. ByteString (BitShown (DVS. Vector Word16 )) (SimpleBalancedParens (DVS. Vector Word16 ))
@@ -79,12 +81,11 @@ genSpec :: forall t u.
7981 , Rank1 u
8082 , BalancedParens u
8183 , TestBit u
82- , IsString (XmlCursor BS. ByteString t u )
8384 )
84- => String -> XmlCursor BS. ByteString t u -> SpecWith ()
85- genSpec t _ = do
85+ => String -> ( BS. ByteString -> XmlCursor BS. ByteString t u ) -> SpecWith ()
86+ genSpec t mkCursor = do
8687 describe (" Cursor for (" ++ t ++ " )" ) $ do
87- let forXml (cursor :: XmlCursor BS. ByteString t u ) f = describe (" of value " ++ show cursor) (f cursor)
88+ let forXml bs f = let cursor = mkCursor bs in describe (" of value " ++ show cursor) (f cursor)
8889 forXml " [null]" $ \ cursor -> do
8990 it " depth at top" $ requireTest $ cd cursor === Just 1
9091 xit " depth at first child of array" $ requireTest $ (fc >=> cd) cursor === Just 2
@@ -97,7 +98,7 @@ genSpec t _ = do
9798 (fc >=> ns >=> fc >=> ns >=> cd) cursor === Just 3
9899
99100 describe " For sample XML" $ do
100- let cursor = " <widget debug=\" on\" > \
101+ let cursor = mkCursor " <widget debug=\" on\" > \
101102 \ <window name=\" main_window\" > \
102103 \ <dimension>500</dimension> \
103104 \ <dimension>600.01e-02</dimension> \
0 commit comments