sql-words/test: add commutativity property about (<++>).

This commit is contained in:
Kei Hibino 2018-05-25 14:31:48 +09:00
parent 626701279c
commit aa44a82481

View File

@ -1,6 +1,7 @@
{-# OPTIONS -fno-warn-orphans #-} {-# OPTIONS -fno-warn-orphans #-}
import Language.SQL.Keyword (Keyword, DString) import Language.SQL.Keyword
(Keyword (Sequence), DString, (<++>))
import Data.Monoid (Monoid, mempty, (<>)) import Data.Monoid (Monoid, mempty, (<>))
import Data.String (fromString) import Data.String (fromString)
@ -44,6 +45,12 @@ kwAssoc = assoc
instance Arbitrary Keyword where instance Arbitrary Keyword where
arbitrary = fmap fromString arbitrary arbitrary = fmap fromString arbitrary
concatCommutative :: DString -> DString -> Bool
concatCommutative x y =
Sequence x <++> Sequence y
==
Sequence (x <> y)
tests :: [Test] tests :: [Test]
tests = [ prop "DString left Id" dsLeftId tests = [ prop "DString left Id" dsLeftId
, prop "DString right Id" dsRightId , prop "DString right Id" dsRightId
@ -51,6 +58,7 @@ tests = [ prop "DString left Id" dsLeftId
, prop "Keyword left Id" kwLeftId , prop "Keyword left Id" kwLeftId
, prop "Keyword right Id" kwRightId , prop "Keyword right Id" kwRightId
, prop "Keyword associativity" kwAssoc , prop "Keyword associativity" kwAssoc
, prop "concat commutative" concatCommutative
] ]
main :: IO () main :: IO ()