Skip to content

Commit d3a6424

Browse files
committed
arbitrary instance for convenience
1 parent 9d89e0e commit d3a6424

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
"dependencies": {
1212
"purescript-maybe": "^4.0.0",
1313
"purescript-math": "^2.1.1",
14-
"purescript-generics-rep": "^6.1.1"
14+
"purescript-generics-rep": "^6.1.1",
15+
"purescript-quickcheck": "^6.1.0"
1516
},
1617
"devDependencies": {
17-
"purescript-quickcheck-laws": "git://github.com/athanclark/purescript-quickcheck-laws.git#a19fbf646918fa201ddbeafe2653b2c1d83e6dd0",
18+
"purescript-quickcheck-laws": "v5.0.1",
1819
"purescript-psci-support": "^4.0.0"
1920
},
2021
"license": "MIT",

src/Data/UInt.purs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import Data.Show (class Show)
3838
import Data.Function ((<<<))
3939
import Data.Semigroup ((<>))
4040
import Data.Generic.Rep (class Generic, Constructor (..), Argument (..))
41+
import Test.QuickCheck (class Arbitrary, arbitrary)
42+
import Prelude ((<$>))
4143
import Math as Math
4244

4345

@@ -50,6 +52,8 @@ instance genericUInt :: Generic UInt (Constructor "UInt" (Argument Number)) wher
5052
from x = Constructor (Argument (toNumber x))
5153
to (Constructor (Argument x)) = fromNumber x
5254

55+
instance arbitraryUInt :: Arbitrary UInt where
56+
arbitrary = fromInt <$> arbitrary
5357

5458

5559
-- | Cast an `Int` to an `UInt` turning negative `Int`s into `UInt`s

test/Main.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Prelude
55
import Effect (Effect)
66
import Data.UInt (UInt, fromNumber)
77
import Data.UInt.Gen (genUInt)
8-
import Test.QuickCheck.Arbitrary (class Arbitrary, arbitrary)
8+
import Test.QuickCheck.Arbitrary (class Arbitrary)
99
import Test.QuickCheck.Laws.Data as Data
1010
import Type.Proxy (Proxy(..))
1111

@@ -26,10 +26,10 @@ derive newtype instance euclideanRingTestUInt :: EuclideanRing TestUInt
2626
main :: Effect Unit
2727
main = do
2828
let prxUInt = Proxy Proxy TestUInt
29-
Data.checkEqShow prxUInt
30-
Data.checkOrdShow prxUInt
31-
Data.checkSemiringShow prxUInt
32-
Data.checkRingShow prxUInt
33-
Data.checkEuclideanRingShow prxUInt
34-
Data.checkBoundedShow prxUInt
35-
Data.checkCommutativeRingShow prxUInt
29+
Data.checkEq prxUInt
30+
Data.checkOrd prxUInt
31+
Data.checkSemiring prxUInt
32+
Data.checkRing prxUInt
33+
Data.checkEuclideanRing prxUInt
34+
Data.checkBounded prxUInt
35+
Data.checkCommutativeRing prxUInt

0 commit comments

Comments
 (0)