Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
text
Commits
2b13adaf
Commit
2b13adaf
authored
Oct 31, 2014
by
bos
Browse files
A better test for gh-99
parent
240ce66e
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/Tests/Properties.hs
View file @
2b13adaf
...
...
@@ -741,8 +741,7 @@ tb_decimal :: (Integral a, Show a) => a -> Bool
tb_decimal
=
(
TB
.
toLazyText
.
TB
.
decimal
)
`
eq
`
(
TL
.
pack
.
show
)
tb_decimal_integer
(
a
::
Integer
)
=
tb_decimal
a
tb_decimal_integer_big
=
forAll
big
tb_decimal
where
big
=
choose
(
20
::
Int
,
200
)
>>=
\
e
->
choose
(
10
^
(
e
-
1
),
10
^
e
::
Integer
)
tb_decimal_integer_big
(
Big
a
)
=
tb_decimal
a
tb_decimal_int
(
a
::
Int
)
=
tb_decimal
a
tb_decimal_int8
(
a
::
Int8
)
=
tb_decimal
a
tb_decimal_int16
(
a
::
Int16
)
=
tb_decimal
a
...
...
tests/Tests/QuickCheckUtils.hs
View file @
2b13adaf
...
...
@@ -18,6 +18,7 @@ module Tests.QuickCheckUtils
,
unsquare
,
smallArbitrary
,
BigInt
(
..
)
,
NotEmpty
(
..
)
,
Small
(
..
)
...
...
@@ -37,6 +38,7 @@ module Tests.QuickCheckUtils
,
write_read
)
where
import
Control.Applicative
((
<$>
))
import
Control.Arrow
(
first
,
(
***
))
import
Control.DeepSeq
(
NFData
(
..
),
deepseq
)
import
Control.Exception
(
bracket
)
...
...
@@ -160,6 +162,14 @@ instance Arbitrary TL.Text where
arbitrary
=
(
TL
.
fromChunks
.
map
notEmpty
)
`
fmap
`
smallArbitrary
shrink
=
map
TL
.
pack
.
shrink
.
TL
.
unpack
newtype
BigInt
=
Big
Integer
deriving
(
Eq
,
Show
)
instance
Arbitrary
BigInt
where
arbitrary
=
choose
(
20
::
Int
,
200
)
>>=
\
e
->
Big
<$>
choose
(
10
^
(
e
-
1
),
10
^
e
)
shrink
(
Big
a
)
=
[
Big
(
a
`
div
`
2
^
(
l
-
e
))
|
e
<-
shrink
l
]
where
l
=
truncate
(
log
(
fromIntegral
a
)
/
log
2
::
Double
)
::
Integer
newtype
NotEmpty
a
=
NotEmpty
{
notEmpty
::
a
}
deriving
(
Eq
,
Ord
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment