Skip to content

Add tests for operations in Streamly.Prelude.#783

Merged
pranaysashank merged 19 commits intomasterfrom
tests/Prelude
Dec 6, 2020
Merged

Add tests for operations in Streamly.Prelude.#783
pranaysashank merged 19 commits intomasterfrom
tests/Prelude

Conversation

@pranaysashank
Copy link
Copy Markdown
Member

Added basic tests for

  • cons, consM, (.:), (|:)
  • yield, yieldM, repeat, repeatM
  • enumerate, enumerateTo
  • unfoldr
  • fromListM
  • drainWhile
  • findM
  • eqBy, cmpBy
  • mapM_, trace
  • postscanl', postscanlM'
  • mapMaybeM
  • dropWhileM
  • groups, groupsByRolling
  • zipAsyncWith
  • concatMapM, concatUnfold
  • before, after, bracket, onException, finally, handle

@pranaysashank pranaysashank force-pushed the tests/Prelude branch 2 times, most recently from 2fee505 to 39559f6 Compare November 26, 2020 11:53
Copy link
Copy Markdown
Member

@harendra-kumar harendra-kumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update hie.yaml for all the test components.
fix hlint issues in the new code, if any.

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
unfoldStep seed =
if seed > fromIntegral len
then Nothing
else Just (seed, seed + 1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting.

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
strm <-
run $
S.toList . op . S.take (fromIntegral len) $
foldr cons S.nil (repeat 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run
    $ S.toList . op . S.take (fromIntegral len)
    $ foldr cons S.nil (repeat 0)

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
strm <-
run $
S.toList . op . S.take (fromIntegral len) $
foldMap S.yield (repeat 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting.

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
prop (desc <> " postscanlM'") $ transform (tail . scanl' (const id) 0) t
(S.postscanlM' (\_ a -> return a) (return 0))
prop (desc <> " scanl") $ transform (scanl' (const id) 0) t
(S.scanl' (const id) 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated test, same as the scanl' test.

strm <-
run $
S.toList . t $ S.before (writeIORef ioRef True) (S.fromList vec)
refValue <- run $ readIORef ioRef
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not making sure that it is actually happening before.

strm <-
run $
S.toList . t $ S.after (writeIORef ioRef True) (S.fromList vec)
refValue <- run $ readIORef ioRef
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as before.

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
refValue <- run $ readIORef ioRef
assert $ refValue == 1

-- XXX This test fails
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will push a fix for this.

describe "Construction" $ do
parallelOps $ prop "parallely replicateM" . constructWithReplicateM
parallelOps $ prop "parallely cons" . constructWithCons S.cons
-- parallelOps $ prop "parallely consM" . constructWithConsM S.consM sort
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this disabled?

@@ -468,13 +492,26 @@ main = hspec
serialOps $ prop "serially iterate" . constructWithIterate
-- XXX test for all types of streams
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this comment now.

-- (toListSerial mzero) `shouldReturn` ([] :: [Int])

describe "Construction" $ do
-- Add all the construction tests for all stream types.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this comment.

Comment thread test/Streamly/Test/Prelude/Common.hs Outdated
foldr cons S.nil (repeat 0)
strm <- run
$ S.toList . op . S.take (fromIntegral len)
$ foldr cons S.nil (repeat 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In such cases we put run on the next line:

        strm <-
            run 
                $ S.toList . op . S.take (fromIntegral len)
                $ foldr cons S.nil (repeat 0)

@pranaysashank pranaysashank merged commit 425adca into master Dec 6, 2020
@pranaysashank pranaysashank deleted the tests/Prelude branch January 11, 2021 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants