From aa44a82481850241281d999a01ecfa1cac37fb81 Mon Sep 17 00:00:00 2001 From: Kei Hibino Date: Fri, 25 May 2018 14:31:48 +0900 Subject: [PATCH] sql-words/test: add commutativity property about (<++>). --- sql-words/test/monoidLaw.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sql-words/test/monoidLaw.hs b/sql-words/test/monoidLaw.hs index 56fd8dfe..c715ff0c 100644 --- a/sql-words/test/monoidLaw.hs +++ b/sql-words/test/monoidLaw.hs @@ -1,6 +1,7 @@ {-# OPTIONS -fno-warn-orphans #-} -import Language.SQL.Keyword (Keyword, DString) +import Language.SQL.Keyword + (Keyword (Sequence), DString, (<++>)) import Data.Monoid (Monoid, mempty, (<>)) import Data.String (fromString) @@ -44,6 +45,12 @@ kwAssoc = assoc instance Arbitrary Keyword where arbitrary = fmap fromString arbitrary +concatCommutative :: DString -> DString -> Bool +concatCommutative x y = + Sequence x <++> Sequence y + == + Sequence (x <> y) + tests :: [Test] tests = [ prop "DString left Id" dsLeftId , prop "DString right Id" dsRightId @@ -51,6 +58,7 @@ tests = [ prop "DString left Id" dsLeftId , prop "Keyword left Id" kwLeftId , prop "Keyword right Id" kwRightId , prop "Keyword associativity" kwAssoc + , prop "concat commutative" concatCommutative ] main :: IO ()