https://github.com/codewars/hspec-codewars
Utility functions for testing on Codewars with Hspec
https://github.com/codewars/hspec-codewars
code-runner haskell hspec test-helpers
Last synced: 3 months ago
JSON representation
Utility functions for testing on Codewars with Hspec
- Host: GitHub
- URL: https://github.com/codewars/hspec-codewars
- Owner: codewars
- License: mit
- Created: 2019-02-07T22:45:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-10T08:00:19.000Z (over 4 years ago)
- Last Synced: 2025-01-10T05:36:08.435Z (4 months ago)
- Topics: code-runner, haskell, hspec, test-helpers
- Language: Haskell
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Test.Hspec.Codewars
Utility functions for testing on Codewars with Hspec.
### Blacklisting
#### `Hidden`
```haskell
data Hidden
-- | Module to be hidden
= Module {moduleName :: String}
-- | Symbol from a module to be hidden
| FromModule {moduleName :: String, symbolName :: String}
```#### `solutionShouldHide`
```haskell
solutionShouldHide :: Hidden -> Expectation
```Check that solution hides a module or a symbol from a module.
```haskell
solutionShouldHide $ FromModule "Prelude" "head"
```#### `solutionShouldHideAll`
```haskell
solutionShouldHideAll :: [Hidden] -> Expectation
```Check that solution hides all of given modules and symbols.
```haskell
solutionShouldHideAll [FromModule "Prelude" "head", Module "Data.Set"]
```### Approximate Equality
#### `shouldBeApprox`
```haskell
shouldBeApprox :: (Fractional a, Ord a, Show a) => a -> a -> Expectation
```Predefined approximately equal expectation with error margin `1e-6`.
```haskell
sqrt 2.0 `shouldBeApprox` (1.4142135 :: Double)
```#### `shouldBeApproxPrec`
```haskell
shouldBeApproxPrec :: (Fractional a, Ord a, Show a) => a -> a -> a -> Expectation
```Create approximately equal expectation with margin.
```haskell
shouldBeApprox' = shouldBeApproxPrec 1e-9
```