-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that
stimes
works right in corner cases.
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE BlockArguments #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
|
||
-- | Check that the definitions that are partial crash in the expected ways or | ||
-- return sensible defaults. | ||
module Tests.Properties.CornerCases (testCornerCases) where | ||
|
||
import Control.Exception | ||
import Data.Either | ||
import Data.Semigroup | ||
import Data.Text | ||
import Test.QuickCheck | ||
import Test.Tasty (TestTree, testGroup) | ||
import Test.Tasty.QuickCheck (testProperty) | ||
import Tests.QuickCheckUtils () | ||
|
||
testCornerCases :: TestTree | ||
testCornerCases = | ||
testGroup | ||
"corner cases" | ||
[ testGroup | ||
"stimes" | ||
let specimen = stimes :: Integer -> Text -> Text | ||
in [ testProperty | ||
"given a negative number, return empty text" | ||
\(Negative number) text -> do | ||
specimen number text == "" | ||
, testProperty | ||
"given a number that does not fit into Int, evaluate to error call" | ||
\(NonNegative number) text -> (ioProperty . fmap isLeft . try @ErrorCall . evaluate) do | ||
specimen | ||
(fromIntegral (number :: Int) + fromIntegral (maxBound :: Int) + 1) | ||
text | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters