コメントの削除
こう、Haskell の練習というか HUnit の使い方確認というか。
import Test.HUnit removeComment :: String -> String removeComment = outOfComment where outOfComment ('/':'*':cs) = inComment cs outOfComment (c:cs) = c : outOfComment cs outOfComment [] = [] inComment ('*':'/':cs) = outOfComment cs inComment (c:cs) = inComment cs inComment [] = [] testData = [ t "AAA" "AAA", t "AAA/*BBB*/" "AAA", t "AAA/*BBB" "AAA", t "AAA/*BBB*/CCC" "AAACCC", t "AAA/*BBB/*CCC*/DDD*/EEE" "AAADDD*/EEE", t "AAA/a//*BB*B**/CCC" "AAA/a/CCC" ] where t input expected = expected ~=? removeComment input main :: IO Counts main = runTestTT (test testData)