From: charlie Date: Sun, 29 Nov 2015 19:28:41 +0000 (+0100) Subject: klaar X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=8ac0f8d2906bfb02b028465a91ffa56a0b588166;p=ap2015.git klaar --- diff --git a/a10/charlie/matcher_shallow.icl b/a10/charlie/matcher_shallow.icl index 00894ae..c439f86 100644 --- a/a10/charlie/matcher_shallow.icl +++ b/a10/charlie/matcher_shallow.icl @@ -1,10 +1,15 @@ module matcher_shallow +import qualified Text +from Text import class Text, instance Text String import StdEnv Contains :: a [a] -> Bool | == a Contains x xs = foldl (\b y . b || x == y) False xs +ContainsString :: String String -> Bool +ContainsString x y = 'Text'.indexOf x y <> -1 + EqualTo :: a a -> Bool | == a EqualTo x y = x == y @@ -36,8 +41,11 @@ a3 = AssertThat "(length [0..3]) is not 4" (length [0..3]) (Not(EqualTo 4)) a4 = AssertThat "[0..3] (Contains 2)" [0..3] (Contains 2) a5 = AssertThat "[0..3] (Contains 7)" [0..3] (Contains 7) a6 = AssertThat "[0..3] (Either (EqualTo [1]) (Contains 7))" [0..3] (EqualTo [1] Or (Contains 7)) +a7 = AssertThat "'hello world' (ContainsString 'hello')" "hello world" (ContainsString "hello") +a8 = AssertThat "'hello world' (ContainsString 'world')" "hello world" (ContainsString "world") +a9 = AssertThat "Red, yellow and blue" "Who is afraid of red, yellow and blue" (ContainsString "Red") -report = test (a1*a2*a3*a4*a5*a6) +report = test (a1*a2*a3*a4*a5*a6*a7*a8*a9) instance <<< [String] where (<<<) file [] = file diff --git a/a10/charlie/matcher_shallow.prj b/a10/charlie/matcher_shallow.prj index 76bea68..17fa6d7 100644 --- a/a10/charlie/matcher_shallow.prj +++ b/a10/charlie/matcher_shallow.prj @@ -37,6 +37,7 @@ Global ExportedNames: Paths Path: {Project} + Path: {Application}\iTasks-SDK\Dependencies\clean-platform\src\libraries\OS-Independent Precompile: Postlink: MainModule @@ -54,6 +55,20 @@ MainModule ReuseUniqueNodes: True Fusion: False OtherModules + Module + Name: Text + Dir: {Application}\iTasks-SDK\Dependencies\clean-platform\src\libraries\OS-Independent + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False Module Name: StdArray Dir: {Application}\Libraries\StdEnv