Skip to content

Commit

Permalink
Revert primitiver stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Dec 2, 2024
1 parent f9d0dc8 commit 22d75d0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ jobs:
githubToken: ${{ github.token }}
install: |
apt-get update -y
apt-get install -y git ghc libghc-primitive-dev libghc-tasty-smallcheck-dev libghc-tasty-hunit-dev libghc-splitmix-dev curl
apt-get install -y git ghc libghc-tasty-smallcheck-dev libghc-tasty-hunit-dev libghc-splitmix-dev curl
run: |
git clone https://github.com/Bodigrim/data-array-byte
cp -r data-array-byte/Data .
Expand Down
1 change: 0 additions & 1 deletion random.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ test-suite spec
build-depends:
base,
bytestring,
primitive >=0.8,
random,
smallcheck >=1.2 && <1.3,
stm,
Expand Down
1 change: 1 addition & 0 deletions stack-old.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extra-deps:
- tasty-1.3.1@sha256:01e35c97f7ee5ccbc28f21debea02a38cd010d53b4c3087f5677c5d06617a507,2520
- ansi-wl-pprint-0.6.8.2@sha256:a890b713942c1aa0109fb632e9fee581ceb5b0763fd936ae8cae22e5f91a0877,2178
- ansi-terminal-0.9.1@sha256:48f53532d0f365ffa568c8cf0adc84c66f800a7d80d3329e4f04fa75392f4af1,3225
- wcwidth-0.0.2@sha256:77531eb6683c505c22ab3fa11bbc43d3ce1e7dac21401d4d5a19677d348bb5f3,1998
- tasty-bench-0.2.3@sha256:daa2221a1b1c65990633a51236f1cb4a52cba8ef0f0731f653e712a8bab07616,1319
- inspection-testing-0.4.5.0@sha256:938e7ce2ef42033071a5e60198c6e19ab61c411f5879b85821247a504f131768,8058
- tasty-inspection-testing-0.1@sha256:9c5e76345168fd3a59b43d305eebf8df3c792ce324c66bbdee45b54aa7d2c0ad,1214
Expand Down
1 change: 0 additions & 1 deletion stack.lts-18.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ packages:
- .
extra-deps:
- data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989
- primitive-0.9.0.0@sha256:de20bf4eff1f972088854c8efda6eaca2d3147aff62232c3707f059152638759,3203
12 changes: 6 additions & 6 deletions test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import qualified Data.ByteString.Short as SBS
import Data.Int
import Data.List (sortOn)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Primitive.ByteArray (newByteArray, unsafeFreezeByteArray, writeByteArray)
import Data.Typeable
import Data.Void
import Data.Word
Expand All @@ -26,6 +25,7 @@ import GHC.Generics
import GHC.Exts (fromList)
import Numeric.Natural (Natural)
import System.Random.Stateful
import System.Random.Internal (newMutableByteArray, freezeMutableByteArray, writeWord8)
import Test.SmallCheck.Series as SC
import Test.Tasty
import Test.Tasty.HUnit
Expand Down Expand Up @@ -151,18 +151,18 @@ fillMutableByteArraySpec =
[ SC.testProperty "Same as uniformByteArray" $
forAll $ \isPinned -> seededWithLen $ \n g ->
let baFilled = runST $ do
mba <- newByteArray n
mba <- newMutableByteArray n
g' <- uniformFillMutableByteArray mba 0 n g
ba <- unsafeFreezeByteArray mba
ba <- freezeMutableByteArray mba
pure (ba, g')
in baFilled == uniformByteArray isPinned n g
, SC.testProperty "Safe uniformFillMutableByteArray" $
forAll $ \isPinned offset count -> seededWithLen $ \sz g ->
let (baFilled, gf) = runST $ do
mba <- newByteArray sz
forM_ [0 .. sz - 1] (\i -> writeByteArray mba i (0 :: Word8))
mba <- newMutableByteArray sz
forM_ [0 .. sz - 1] (\i -> writeWord8 mba i 0)
g' <- uniformFillMutableByteArray mba offset count g
ba <- unsafeFreezeByteArray mba
ba <- freezeMutableByteArray mba
pure (ba, g')
(baGen, gu) = uniformByteArray isPinned count' g
offset' = min sz (max 0 offset)
Expand Down

0 comments on commit 22d75d0

Please sign in to comment.