himari-1.1.6.4: test/Spec/HlintBaseSpec.hs
module Spec.HlintBaseSpec (tests) where
import Himari
import HlintRunner
import Test.Sandwich
tests :: TopSpec
tests = do
describe "hlint base library rules" . withSample "BasePartial.hs" $ do
describe "Data.List partial functions" $ do
it "head through Himari should warn (partial function)" $
shouldWarnFunction "useHead" "head" "headMay"
it "Data.List.head should warn (partial function)" $
shouldWarnFunction "useHeadQualified" "L.head" "headMay"
describe "NonEmpty.head should be safe" $ do
it "Data.List.NonEmpty.head should NOT warn (it's safe)" $
shouldNotWarnFunctionIn "useNonEmptyHead"
describe "Debug.Trace functions suggest pTrace*" $ do
it "Debug.Trace.trace should suggest pTrace" $
shouldSuggestIn "useTrace" "Use pTrace"
it "Debug.Trace.traceShow should suggest pTraceShow" $
shouldSuggestIn "useTraceShow" "Use pTraceShow"
it "Debug.Trace.traceM should suggest pTraceM" $
shouldSuggestIn "useTraceM" "Use pTraceM"
describe "Numeric integer-showing functions are partial" $ do
it "showHex should warn (partial function)" $
shouldWarnFunction "useShowHex" "showHex" "non-negative"
it "showInt should warn (partial function)" $
shouldWarnFunction "useShowInt" "showInt" "non-negative"
it "showOct should warn (partial function)" $
shouldWarnFunction "useShowOct" "showOct" "non-negative"
it "showBin should warn (partial function)" $
shouldWarnFunction "useShowBin" "showBin" "non-negative"
it "showIntAtBase should warn (partial function)" $
shouldWarnFunction "useShowIntAtBase" "showIntAtBase" "base > 1"
describe "Data.Char partial functions" $ do
it "intToDigit should warn (partial function)" $
shouldWarnFunction "useShowIntAtBase" "intToDigit" "intToDigitMay"