]> gitweb.michael.orlitzky.com - dead/halcyon.git/blobdiff - src/Html.hs
Clean up imports.
[dead/halcyon.git] / src / Html.hs
index 1c9a4285541c720c2c413166f606cb15d5abdc46..f1671a8e57f0fb0401ec7cea8ec5d765a42a6ba3 100644 (file)
@@ -1,34 +1,43 @@
-module Html
+module Html (
+  html_tests,
+  replace_entities )
 where
 
-import Test.HUnit
-import Text.HTML.TagSoup.Entity (lookupEntity)
+import Test.Framework ( Test, testGroup )
+import Test.Framework.Providers.HUnit ( testCase )
+import Test.HUnit ( Assertion, assertEqual )
+import Text.HTML.TagSoup.Entity ( lookupEntity )
 
 replace_entities :: String -> String
 replace_entities [] = []
 replace_entities ('&':xs) =
   let (b, a) = break (== ';') xs in
   case (lookupEntity b, a) of
-    (Just c, ';':as) ->  c  : replace_entities as
+    (Just s, ';':as) ->  s ++ replace_entities as
     _                -> '&' : replace_entities xs
 replace_entities (x:xs) = x : replace_entities xs
 
 
-html_tests :: [Test]
-html_tests = [ test_replace_entities ]
+html_tests :: Test
+html_tests =
+  testGroup "HTML Tests" [ tc1 ]
+  where
+    tc1 = testCase
+            "All entities are replaced correctly."
+            test_replace_entities
 
-test_replace_entities :: Test
+test_replace_entities :: Assertion
 test_replace_entities =
-    TestCase $ assertEqual description expected_text actual_text
-    where
-      description = "All entities are replaced correctly."
-      actual_text =
-        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 =
-        "\"The moon is gay……\" said <insert " ++
-        "the current president of the United States of America>. " ++
-        "“It’s OK—–he’s not a real doctor.”"
+  assertEqual description expected_text actual_text
+  where
+    description = "All entities are replaced correctly."
+    actual_text =
+      replace_entities $
+        "&quot;The moon is gay&#8230;&hellip;&quot; " ++
+        "said &lt;insert the current president of the " ++
+        "United States of America&gt;. &ldquo;It&#8217;s " ++
+        "OK&mdash;&ndash;he&#8217;s not a real doctor.&rdquo;"
+    expected_text =
+      "\"The moon is gay……\" said <insert " ++
+      "the current president of the United States of America>. " ++
+      "“It’s OK—–he’s not a real doctor.”"