From: Michael Orlitzky Date: Wed, 16 Jul 2014 03:49:45 +0000 (-0400) Subject: Bump all dependencies and switch from test-framework to tasty for tests. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=commitdiff_plain;h=e3864f89a0cae34d4d280efeb52ea5f761ddb44a Bump all dependencies and switch from test-framework to tasty for tests. --- diff --git a/halcyon.cabal b/halcyon.cabal index e425797..a3c39bc 100644 --- a/halcyon.cabal +++ b/halcyon.cabal @@ -15,26 +15,26 @@ build-type: Simple executable halcyon build-depends: - aeson == 0.6.*, - authenticate-oauth == 1.4.*, - base == 4.*, - bytestring == 0.10.*, + aeson >= 0.7, + authenticate-oauth >= 1.5, + base >= 4.6 && < 5, + bytestring >= 0.10, cmdargs >= 0.10.5, - configurator == 0.2.*, - directory == 1.2.*, - http-client == 0.2.*, - http-client-tls == 0.2.*, + configurator >= 0.2, + directory >= 1.2, + http-client >= 0.3, + http-client-tls >= 0.2, HUnit == 1.2.*, - MissingH == 1.*, - process == 1.*, - old-locale == 1.*, + MissingH >= 1.2, + process >= 1.1, + old-locale >= 1, regex-compat == 0.*, - tagsoup == 0.13.*, - text == 0.11.*, - time == 1.*, + tagsoup >= 0.13, + text >= 1.1, + time >= 1.4, -- Test deps - test-framework == 0.8.*, - test-framework-hunit == 0.3.* + tasty >= 0.8, + tasty-hunit >= 0.3 main-is: Main.hs @@ -73,26 +73,25 @@ test-suite testsuite hs-source-dirs: src test main-is: TestSuite.hs build-depends: - aeson == 0.6.*, - authenticate-oauth == 1.4.*, - base == 4.*, - bytestring == 0.10.*, + aeson >= 0.7, + authenticate-oauth >= 1.5, + base >= 4.6 && < 5, + bytestring >= 0.10, cmdargs >= 0.10.5, - configurator == 0.2.*, - directory == 1.2.*, - http-client == 0.2.*, - http-client-tls == 0.2.*, - HUnit == 1.2.*, - MissingH == 1.*, - process == 1.*, - old-locale == 1.*, + configurator >= 0.2, + directory >= 1.2, + http-client >= 0.3, + http-client-tls >= 0.2, + MissingH >= 1.2, + process >= 1.1, + old-locale >= 1, regex-compat == 0.*, - tagsoup == 0.13.*, - text == 0.11.*, - time == 1.*, + tagsoup >= 0.13, + text >= 1.1, + time >= 1.4, -- Test deps - test-framework == 0.8.*, - test-framework-hunit == 0.3.* + tasty >= 0.8, + tasty-hunit >= 0.3 -- It's not entirely clear to me why I have to reproduce all of this. ghc-options: diff --git a/src/Html.hs b/src/Html.hs index f1671a8..59876a5 100644 --- a/src/Html.hs +++ b/src/Html.hs @@ -3,9 +3,8 @@ module Html ( replace_entities ) where -import Test.Framework ( Test, testGroup ) -import Test.Framework.Providers.HUnit ( testCase ) -import Test.HUnit ( Assertion, assertEqual ) +import Test.Tasty ( TestTree, testGroup ) +import Test.Tasty.HUnit ( (@?=), testCase ) import Text.HTML.TagSoup.Entity ( lookupEntity ) replace_entities :: String -> String @@ -18,26 +17,23 @@ replace_entities ('&':xs) = replace_entities (x:xs) = x : replace_entities xs -html_tests :: Test +html_tests :: TestTree html_tests = - testGroup "HTML Tests" [ tc1 ] - where - tc1 = testCase - "All entities are replaced correctly." - test_replace_entities + testGroup "HTML Tests" [ test_replace_entities ] + -test_replace_entities :: Assertion +test_replace_entities :: TestTree test_replace_entities = - assertEqual description expected_text actual_text + testCase description $ actual @?= expected where - description = "All entities are replaced correctly." - actual_text = + description = "all entities are replaced correctly." + actual = replace_entities $ ""The moon is gay……" " ++ "said <insert the current president of the " ++ "United States of America>. “It’s " ++ "OK—–he’s not a real doctor.”" - expected_text = + expected = "\"The moon is gay……\" said . " ++ "“It’s OK—–he’s not a real doctor.”" diff --git a/src/StringUtils.hs b/src/StringUtils.hs index 210e230..a9e2625 100644 --- a/src/StringUtils.hs +++ b/src/StringUtils.hs @@ -4,10 +4,8 @@ module StringUtils ( string_utils_tests ) where -import Test.Framework ( Test, testGroup ) -import Test.Framework.Providers.HUnit ( testCase ) -import Test.HUnit ( Assertion, assertEqual ) - +import Test.Tasty ( TestTree, testGroup ) +import Test.Tasty.HUnit ( (@?=), testCase ) -- | Takes a list of strings, call them string1, string2, etc. and -- numbers them like a list. So, @@ -28,16 +26,13 @@ listify = -- Tests -- -test_listify :: Assertion -test_listify = - assertEqual description expected_items actual_items - where - description = "All items are numbered correctly." - actual_items = listify [ "item1", "item2" ] - expected_items = ["1. item1", "2. item2" ] - -string_utils_tests :: Test +string_utils_tests :: TestTree string_utils_tests = - testGroup "StringUtils Tests" [ tc1 ] + testGroup "StringUtils Tests" [ test_listify ] + +test_listify :: TestTree +test_listify = testCase description $ actual @?= expected where - tc1 = testCase "All items are numbered correctly." test_listify + description = "all items are numbered correctly" + actual = listify [ "item1", "item2" ] + expected = ["1. item1", "2. item2" ] diff --git a/src/Twitter/Status.hs b/src/Twitter/Status.hs index 6238b68..506a2c0 100644 --- a/src/Twitter/Status.hs +++ b/src/Twitter/Status.hs @@ -22,9 +22,8 @@ import Data.Time.Clock ( UTCTime ) import Data.Time.Format ( parseTime ) import Data.Time.LocalTime ( TimeZone, utcToZonedTime ) import System.Locale ( defaultTimeLocale, rfc822DateFormat ) -import Test.Framework ( Test, testGroup ) -import Test.Framework.Providers.HUnit ( testCase ) -import Test.HUnit ( Assertion, assertEqual ) +import Test.Tasty ( TestTree, testGroup ) +import Test.Tasty.HUnit ( (@?=), testCase ) import Text.Regex ( matchRegex, mkRegex ) import Html ( replace_entities ) @@ -89,6 +88,7 @@ show_created_at mtz = -- | Returns a nicely-formatted String representing the given 'Status' -- object. +-- pretty_print :: Maybe TimeZone -> Status -> String pretty_print mtz status = concat [ name, @@ -110,6 +110,7 @@ pretty_print mtz status = -- | Given a list of statuses, returns the greatest status_id -- belonging to one of the statuses in the list. +-- get_max_status_id :: Timeline -> Integer get_max_status_id statuses = maximum status_ids @@ -118,6 +119,7 @@ get_max_status_id statuses = -- | Parse one username from a word. +-- parse_username :: String -> Maybe String parse_username word = case matches of @@ -130,13 +132,16 @@ parse_username word = -- | Parse all usernames of the form \@username from a status. +-- parse_usernames_from_status :: Status -> [String] parse_usernames_from_status status = mapMaybe parse_username status_words where status_words = splitWs (text status) + -- | Get all referenced users' timeline URLs. +-- make_user_timeline_urls :: Status -> [String] make_user_timeline_urls status = map screen_name_to_timeline_url usernames @@ -144,20 +149,17 @@ make_user_timeline_urls status = usernames = parse_usernames_from_status status -status_tests :: Test +status_tests :: TestTree status_tests = - testGroup "Status Tests" [ tc1 ] - where - tc1 = testCase "All usernames are parsed." test_parse_usernames + testGroup "Status Tests" [ test_parse_usernames ] -test_parse_usernames :: Assertion +test_parse_usernames :: TestTree test_parse_usernames = - assertEqual - "All usernames are parsed." - expected_usernames - actual_usernames + testCase description $ actual @?= expected where + description = "all usernames are parsed" + dummy_user = User { screen_name = "nobody" } dummy_text = "Hypothesis: @donsbot and @bonus500 are two " ++ "personalities belonging to the same person." @@ -169,5 +171,5 @@ test_parse_usernames = retweeted = False } - actual_usernames = parse_usernames_from_status dummy_status - expected_usernames = ["donsbot", "bonus500"] + actual = parse_usernames_from_status dummy_status + expected = ["donsbot", "bonus500"] diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 036e616..e91d3e9 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -1,16 +1,18 @@ -import Test.Framework ( - Test, - defaultMain, - ) +module Main +where -import StringUtils (string_utils_tests) -import Twitter.Status(status_tests) -import Html(html_tests) +import Test.Tasty ( TestTree, defaultMain, testGroup ) -tests :: [Test] -tests = [ html_tests, - status_tests, - string_utils_tests ] +import StringUtils ( string_utils_tests ) +import Twitter.Status ( status_tests ) +import Html ( html_tests ) + +tests :: TestTree +tests = + testGroup "All Tests" [ + html_tests, + status_tests, + string_utils_tests ] main :: IO () main = defaultMain tests