@@ -23,7 +23,7 @@ import Test.Hspec
2323import Data.Greskell.AsIterator (AsIterator (IteratorItem ))
2424import Data.Greskell.AsLabel (AsLabel (.. ), lookupAsM )
2525import qualified Data.Greskell.AsLabel as As
26- import Data.Greskell.Binder (newBind , runBinder )
26+ import Data.Greskell.Binder (Binder , newBind , runBinder )
2727import Data.Greskell.Extra (gWhenEmptyInput )
2828import Data.Greskell.GMap (GMapEntry , unGMapEntry )
2929import Data.Greskell.Graph (AEdge (.. ), AProperty (.. ), AVertex (.. ),
@@ -60,6 +60,7 @@ main = hspec spec
6060spec :: Spec
6161spec = withEnv $ do
6262 spec_basics
63+ spec_binder
6364 spec_comparator
6465 spec_predicate
6566 spec_T
@@ -155,6 +156,21 @@ checkOne :: (AsIterator a, b ~ IteratorItem a, FromGraphSON b, Eq b, Show b)
155156 => Greskell a -> b -> SpecWith (String , Int )
156157checkOne input expected = checkRaw input [expected]
157158
159+ checkBinder :: (AsIterator a , b ~ IteratorItem a , FromGraphSON b , Eq b , Show b )
160+ => [b ] -> Binder (Greskell a ) -> SpecWith (String , Int )
161+ checkBinder expected binder = specify label $ withClient $ \ client -> do
162+ got <- WS. slurpResults =<< WS. submit client script (Just binding)
163+ got `shouldBe` V. fromList expected
164+ where
165+ (script, binding) = runBinder binder
166+ label = (unpack $ toGremlin script) ++ " with " ++ show binding
167+
168+ spec_binder :: SpecWith (String , Int )
169+ spec_binder = describe " server and Binder" $ do
170+ checkBinder [100 :: Int ] $ newBind (100 :: Int )
171+ checkBinder [110 :: Int ] $ do
172+ b <- newBind (100 :: Int )
173+ return $ b + (10 :: Greskell Int )
158174
159175spec_comparator :: SpecWith (String ,Int )
160176spec_comparator = do
0 commit comments