@@ -15,7 +15,7 @@
1515module Main where
1616
1717import Control.Applicative
18−import Control.Error
18+import Control.Error hiding (Script)
1919import Control.Exception (evaluate)
2020import Control.Monad
2121import Control.Monad.Catch
@@ -509,6 +509,11 @@ instance ApproxEq TemplateName
509509instance ApproxEq TemplatePattern
510510instance ApproxEq QueryString
511511instance ApproxEq FieldName
512+instance ApproxEq Script
513+instance ApproxEq ScriptLanguage
514+instance ApproxEq ScriptInline
515+instance ApproxEq ScriptId
516+instance ApproxEq ScriptParams where (=~) = (==)
512517instance ApproxEq CacheName
513518instance ApproxEq CacheKey
514519instance ApproxEq Existence
@@ -563,11 +568,8 @@ instance ApproxEq FunctionScoreQuery
563568instance ApproxEq BoostMode
564569instance ApproxEq ScoreMode
565570instance ApproxEq FunctionScoreFunctions
566−instance ApproxEq ComponentFunctionScoreFunction
567571instance ApproxEq FunctionScoreFunction
568−instance ApproxEq FunctionScoreScript
569−instance ApproxEq FunctionScoreScriptInline
570−instance ApproxEq FunctionScoreScriptParams where (=~) = (==)
572+instance ApproxEq ComponentFunctionScoreFunction
571573instance ApproxEq Weight where (=~) = (==)
572574instance ApproxEq Seed where (=~) = (==)
573575instance ApproxEq FieldValueFactor
@@ -686,8 +688,12 @@ instance (Arbitrary a, Typeable a) => Arbitrary (Hit a) where
686688 <*> arbitraryScore
687689 <*> arbitrary
688690 <*> arbitrary
691+ <*> arbitrary
689692 shrink = genericShrink
690693
694+instance Arbitrary HitFields where
695+ arbitrary = pure (HitFields M.empty)
696+ shrink = const []
691697
692698instance (Arbitrary a, Typeable a) => Arbitrary (SearchHits a) where
693699 arbitrary = reduceSize $ do
@@ -740,6 +746,27 @@ instance Arbitrary FieldName where
740746 arbitrary = FieldName . T.pack <$> listOf1 arbitraryAlphaNum
741747 shrink = genericShrink
742748
749+instance Arbitrary ScriptFields where
750+ arbitrary =
751+ pure $ ScriptFields $
752+ HM.fromList []
753+
754+ shrink = const []
755+
756+instance Arbitrary Script where arbitrary = sopArbitrary; shrink = genericShrink
757+instance Arbitrary ScriptLanguage where arbitrary = sopArbitrary; shrink = genericShrink
758+instance Arbitrary ScriptInline where arbitrary = sopArbitrary; shrink = genericShrink
759+instance Arbitrary ScriptId where arbitrary = sopArbitrary; shrink = genericShrink
760+
761+instance Arbitrary ScriptParams where
762+ arbitrary =
763+ pure $ ScriptParams $
764+ HM.fromList [ ("a", Number 42)
765+ , ("b", String "forty two")
766+ ]
767+
768+ shrink = const []
769+
743770
744771instance Arbitrary RegexpFlags where
745772 arbitrary = oneof [ pure AllRegexpFlags
@@ -885,18 +912,8 @@ instance Arbitrary FunctionScoreQuery where arbitrary = sopArbitrary; shrink = g
885912instance Arbitrary BoostMode where arbitrary = sopArbitrary; shrink = genericShrink
886913instance Arbitrary ScoreMode where arbitrary = sopArbitrary; shrink = genericShrink
887914instance Arbitrary FunctionScoreFunctions where arbitrary = sopArbitrary; shrink = genericShrink
888−instance Arbitrary ComponentFunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
889915instance Arbitrary FunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
890−instance Arbitrary FunctionScoreScript where arbitrary = sopArbitrary; shrink = genericShrink
891−instance Arbitrary FunctionScoreScriptInline where arbitrary = sopArbitrary; shrink = genericShrink
892−instance Arbitrary FunctionScoreScriptParams where
893− arbitrary =
894− pure $ FunctionScoreScriptParams $
895− HM.fromList [ ("a", Number 42)
896− , ("b", String "forty two")
897− ]
898−
899− shrink = const []
916+instance Arbitrary ComponentFunctionScoreFunction where arbitrary = sopArbitrary; shrink = genericShrink
900917instance Arbitrary Weight where arbitrary = sopArbitrary; shrink = genericShrink
901918instance Arbitrary Seed where arbitrary = sopArbitrary; shrink = genericShrink
902919instance Arbitrary FieldValueFactor where arbitrary = sopArbitrary; shrink = genericShrink
@@ -1192,7 +1209,7 @@ main = hspec $ do
11921209 let search = Search Nothing
11931210 Nothing (Just [sortSpec]) Nothing Nothing
11941211 False (From 0) (Size 10) SearchTypeQueryThenFetch Nothing Nothing
1195− Nothing
1212+ Nothing Nothing
11961213 result <- searchTweets search
11971214 let myTweet = grabFirst result
11981215 liftIO $
@@ -1659,6 +1676,11 @@ main = hspec $ do
16591676 propJSON (Proxy :: Proxy TemplatePattern)
16601677 propJSON (Proxy :: Proxy QueryString)
16611678 propJSON (Proxy :: Proxy FieldName)
1679+ propJSON (Proxy :: Proxy Script)
1680+ propJSON (Proxy :: Proxy ScriptLanguage)
1681+ propJSON (Proxy :: Proxy ScriptInline)
1682+ propJSON (Proxy :: Proxy ScriptId)
1683+ propJSON (Proxy :: Proxy ScriptParams)
16621684 propJSON (Proxy :: Proxy CacheName)
16631685 propJSON (Proxy :: Proxy CacheKey)
16641686 propJSON (Proxy :: Proxy Existence)
@@ -1713,7 +1735,6 @@ main = hspec $ do
17131735 propJSON (Proxy :: Proxy BoostMode)
17141736 propJSON (Proxy :: Proxy ScoreMode)
17151737 propJSON (Proxy :: Proxy ComponentFunctionScoreFunction)
1716− propJSON (Proxy :: Proxy FunctionScoreScript)
17171738 propJSON (Proxy :: Proxy FieldValueFactor)
17181739 propJSON (Proxy :: Proxy FactorModifier)
17191740 propJSON (Proxy :: Proxy DisMaxQuery)