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
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:
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
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 <insert " ++
"the current president of the United States of America>. " ++
"“It’s OK—–he’s not a real doctor.”"
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,
-- 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" ]
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 )
-- | Returns a nicely-formatted String representing the given 'Status'
-- object.
+--
pretty_print :: Maybe TimeZone -> Status -> String
pretty_print mtz status =
concat [ name,
-- | 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
-- | Parse one username from a word.
+--
parse_username :: String -> Maybe String
parse_username word =
case matches of
-- | 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
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."
retweeted = False
}
- actual_usernames = parse_usernames_from_status dummy_status
- expected_usernames = ["donsbot", "bonus500"]
+ actual = parse_usernames_from_status dummy_status
+ expected = ["donsbot", "bonus500"]
-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