X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMisc.hs;h=16b0ead151ad1b29190028db01aa98ef34d6b797;hb=9849853e69c46b46996e8c775d15661b2aba27a8;hp=b9220cbbcefa7bf52ea9ec6c76b5f5d09467d4b6;hpb=c3d4eba6aa5ada928b351e9ec7c12c3077808ba7;p=spline3.git diff --git a/src/Misc.hs b/src/Misc.hs index b9220cb..16b0ead 100644 --- a/src/Misc.hs +++ b/src/Misc.hs @@ -4,6 +4,11 @@ module Misc where import Data.List (intersect) +import Test.Framework (Test, testGroup) +import Test.Framework.Providers.HUnit (testCase) +import Test.Framework.Providers.QuickCheck2 (testProperty) +import Test.HUnit +import Test.QuickCheck -- | The standard factorial function. See @@ -75,3 +80,30 @@ all_equal xs = disjoint :: (Eq a) => [a] -> [a] -> Bool disjoint xs ys = intersect xs ys == [] + + + +prop_factorial_greater :: Int -> Property +prop_factorial_greater n = + n <= 20 ==> factorial n >= n + + +test_flatten1 :: Assertion +test_flatten1 = + assertEqual "flatten actually works" expected_list actual_list + where + target = [[[1::Int]], [[2, 3]]] + expected_list = [1, 2, 3] + actual_list = flatten target + + +misc_tests :: Test.Framework.Test +misc_tests = + testGroup "Misc Tests" [ + testCase "flatten (1)" test_flatten1 ] + + +misc_properties :: Test.Framework.Test +misc_properties = + testGroup "Misc Properties" [ + testProperty "factorial greater" prop_factorial_greater ]