{- ==== This provides a classification tree to test Google geoservice. The service is tested through a test-interface; see its implementation in src/CTy. Below we also define a combination rule; from which we generate a (generic) test-suite. From the latter we then generate concrete test-suites. ==== -} module GGCT where import CTy.DSL import CTy.TestVal import CTy.Concretization import CTy.CRule import CTy.TCgen import CTy.ExampleRestApp import List -- a function to fill in class with some dummy test-value, and weigth addr_ :: Address -> TestVal addr_ a = Frag (show a) mode_ m = Frag (show m) type Address = (String,String,String,Int) -- -- Classification tree -- ct :: Address -> CTree TestVal ct a = tree [address,countryMode,cityMode,streetMode,numberMode,order] where address = "Address" <== ["Address" %= addr_ a] countryMode = "CountryMode" <== [ "CoCorrect" %= mode_ Correct, "CoSwapped2" %= mode_ Swapped2, "CoDropLast" %= mode_ DropLast, "CoEmpty" %= mode_ Empty ] cityMode = "CityMode" <== [ "CiCorrect" %= mode_ Correct, "CiSwapped2" %= mode_ Swapped2, "CiDropLast" %= mode_ DropLast, "CiEmpty" %= mode_ Empty ] -- street will never be deleted streetMode = "StreetMode" <== [ "StCorrect" %= mode_ Correct, "StSwapped2" %= mode_ Swapped2, "StDropLast" %= mode_ DropLast ] numberMode = "NrMode" <== [ "NrCorrect" %= mode_ NCorrect, "NrEmpty" %= mode_ NEmpty ] order = "ArgsOrder" <== [ "CommonOrder" %= mode_ CommonO, "CoCiSN" %= mode_ CoCiSN, "NSCiCo" %= mode_ NSCiCo, "CoNSCi" %= mode_ CoNSCi ] address1 = ("netherland","utrecht","padualaan",14) -- #384 fullsuite = allf (ct address1) -- -- A rule specifying the combinations we want. -- r1 = incl ["StCorrect"] &&* incl "ArgsOrder" &&* incl "CityMode" |+| neg (incl ["StCorrect"]) &&- incl "ArgsOrder" &&- incl "CityMode" -- # 160 -- A suite obtained by full padding on r1. suite1f a = ct a $$ rule r1 >>= paddingf >>= fixorder >>= lift_ . strip -- # 20 -- And this one with minimal padding on r1. suite1m a = ct a $$ rule r1 >>= paddingm >>= fixorder >>= lift_ . strip mydir = "e:/workshop/PROJECTS/CTy/v2/src/CTy/" -- -- Given an address, this generate a concrete test-suite for testing -- that address. -- genCTS a = translate HaskellTargetLang suite (mydir ++ "TemplateExampleRestApp") (mydir ++ name ++ ".hs") ("CTy." ++ name) where suite = suite1m a (co,ci,str,n) = a name = ("ExampleRestAppTest_" ++) . concat . intersperse "_" $ [co,ci,str,show n] -- -- As examples, generating two concrete suites. -- concreteSuite1 = genCTS address1 concreteSuite2 = genCTS ("netherlands","utrecht","leuvenplein",1)