@@ -10,7 +10,7 @@ module Tests.Regressions
1010 tests
1111 ) where
1212
13- import Control.Exception (SomeException , handle )
13+ import Control.Exception (ErrorCall , SomeException , handle , evaluate )
1414import Data.Char (isLetter , chr )
1515import GHC.Exts (Int (.. ), sizeofByteArray #)
1616import System.IO
@@ -19,6 +19,7 @@ import Test.Tasty.HUnit (assertBool, assertEqual, assertFailure)
1919import qualified Data.ByteString as B
2020import Data.ByteString.Char8 ()
2121import qualified Data.ByteString.Lazy as LB
22+ import Data.Semigroup (stimes )
2223import qualified Data.Text as T
2324import qualified Data.Text.Array as TA
2425import qualified Data.Text.Encoding as TE
@@ -181,6 +182,14 @@ t559 = do
181182 T. filter undefined (T. filter (const False ) " a" ) @?= " "
182183 LT. filter undefined (LT. filter (const False ) " a" ) @?= " "
183184
185+ -- Github #633
186+ -- stimes checked for an `a` to `Int` to `a` roundtrip, but the `a` and `Int` values could represent different integers.
187+ t633 :: IO ()
188+ t633 =
189+ handle (\ (_ :: ErrorCall ) -> return () ) $ do
190+ _ <- evaluate (stimes (maxBound :: Word ) " a" :: T. Text )
191+ assertFailure " should fail"
192+
184193tests :: F. TestTree
185194tests = F. testGroup " Regressions"
186195 [ F. testCase " hGetContents_crash" hGetContents_crash
@@ -199,4 +208,5 @@ tests = F.testGroup "Regressions"
199208 , F. testCase " t528" t528
200209 , F. testCase " t529" t529
201210 , F. testCase " t559" t559
211+ , F. testCase " t633" t633
202212 ]
0 commit comments