Skip to content

Utility functions for testing on Codewars with Hspec

License

Notifications You must be signed in to change notification settings

codewars/hspec-codewars

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test.Hspec.Codewars

Utility functions for testing on Codewars with Hspec.

Blacklisting

Hidden

data Hidden
  -- | Module to be hidden
  = Module {moduleName :: String}
  -- | Symbol from a module to be hidden
  | FromModule {moduleName :: String, symbolName :: String}

solutionShouldHide

solutionShouldHide :: Hidden -> Expectation

Check that solution hides a module or a symbol from a module.

solutionShouldHide $ FromModule "Prelude" "head"

solutionShouldHideAll

solutionShouldHideAll :: [Hidden] -> Expectation

Check that solution hides all of given modules and symbols.

solutionShouldHideAll [FromModule "Prelude" "head", Module "Data.Set"]

Approximate Equality

shouldBeApprox

shouldBeApprox :: (Fractional a, Ord a, Show a) => a -> a -> Expectation

Predefined approximately equal expectation with error margin 1e-6.

sqrt 2.0 `shouldBeApprox` (1.4142135 :: Double)

shouldBeApproxPrec

shouldBeApproxPrec :: (Fractional a, Ord a, Show a) => a -> a -> a -> Expectation

Create approximately equal expectation with margin.

shouldBeApprox' = shouldBeApproxPrec 1e-9