From: charlie Date: Sun, 29 Nov 2015 17:57:22 +0000 (+0100) Subject: shallow uitgebreid met list stuff X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=00ab8fff6dd32a2e235174d627f4e36aa169cb75;p=ap2015.git shallow uitgebreid met list stuff --- diff --git a/a10/charlie/matcher_shallow.icl b/a10/charlie/matcher_shallow.icl index 6901305..00894ae 100644 --- a/a10/charlie/matcher_shallow.icl +++ b/a10/charlie/matcher_shallow.icl @@ -2,6 +2,9 @@ module matcher_shallow import StdEnv +Contains :: a [a] -> Bool | == a +Contains x xs = foldl (\b y . b || x == y) False xs + EqualTo :: a a -> Bool | == a EqualTo x y = x == y @@ -30,8 +33,11 @@ test x = x ++ ["\n"] a1 = AssertThat "(2*2) (Is (EqualTo (2+2)))" (2*2) (Is(EqualTo (2+2))) a2 = AssertThat "(3*3) (EqualTo (3+3))" (3*3) (EqualTo (3+3)) 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)) -report = test (a1*a2*a3) +report = test (a1*a2*a3*a4*a5*a6) instance <<< [String] where (<<<) file [] = file