streamly icon indicating copy to clipboard operation
streamly copied to clipboard

make sure there is at least one test for each user exposed API

Open harendra-kumar opened this issue 7 years ago • 4 comments

Sometimes we do not add tests due to lack of time and sometimes we do not add tests because an API gets tested through some other API. However, it is important to have tests, at the minimum we can add a trivial test using the symbol, this is to ensure that we do not accidentally remove an API during refactor and do not even get to know about it.

harendra-kumar avatar Dec 09 '18 12:12 harendra-kumar

src/Streamly/Prelude.hs

  • [ ] mkAsync
  • [ ] IsStream ()
  • [X] serially
  • [X] wSerially
  • [X] asyncly
  • [X] aheadly
  • [X] wAsyncly
  • [X] parallely
  • [X] zipSerially
  • [X] zipAsyncly
  • [X] adapt
  • [X] nil
  • [x] cons
  • [x] (.:)
  • [x] consM
  • [x] (|:)
  • [x] yield
  • [x] yieldM
  • [x] repeat
  • [x] repeatM
  • [X] replicate
  • [X] replicateM
  • [ ] Enumerable (..)
  • [x] enumerate
  • [x] enumerateTo
  • [x] unfoldr
  • [X] unfoldrM
  • [X] unfold
  • [X] iterate
  • [X] iterateM
  • [X] fromIndices
  • [X] fromIndicesM
  • [X] fromList
  • [x] fromListM
  • [X] fromFoldable
  • [X] fromFoldableM
  • [ ] uncons
  • [X] tail
  • [X] init
  • [X] foldrM
  • [X] foldr
  • [X] foldl'
  • [X] foldl1'
  • [X] foldlM'
  • [X] fold
  • [X] drain
  • [X] last
  • [X] length
  • [X] sum
  • [X] product
  • [X] maximumBy
  • [X] maximum
  • [X] minimumBy
  • [X] minimum
  • [X] the
  • [X] toList
  • [X] drainN
  • [x] drainWhile
  • [X] (!!)
  • [X] head
  • [x] findM
  • [X] find
  • [X] lookup
  • [X] findIndex
  • [X] elemIndex
  • [X] null
  • [X] elem
  • [X] notElem
  • [X] all
  • [X] any
  • [X] and
  • [X] or
  • [x] eqBy
  • [x] cmpBy
  • [X] isPrefixOf
  • [X] isSubsequenceOf
  • [X] stripPrefix
  • [ ] (|$)
  • [X] (|&)
  • [ ] (|$.)
  • [ ] (|&.)
  • [ ] map
  • [ ] sequence
  • [X] mapM
  • [x] mapM_
  • [x] trace
  • [X] tap
  • [X] scanl'
  • [X] scanlM'
  • [x] postscanl'
  • [x] postscanlM'
  • [X] scanl1'
  • [X] scanl1M'
  • [ ] scan
  • [ ] postscan
  • [X] filter
  • [X] filterM
  • [X] mapMaybe
  • [x] mapMaybeM
  • [X] deleteBy
  • [X] uniq
  • [X] insertBy
  • [X] intersperseM
  • [ ] intersperse
  • [ ] indexed
  • [ ] indexedR
  • [X] reverse
  • [X] take
  • [X] takeWhile
  • [x] takeWhileM
  • [X] drop
  • [X] dropWhile
  • [x] dropWhileM
  • [ ] chunksOf
  • [ ] intervalsOf
  • [X] findIndices
  • [X] elemIndices
  • [X] splitOn
  • [ ] splitOnSuffix
  • [ ] splitWithSuffix
  • [x] groups
  • [X] groupsBy
  • [x] groupsByRolling
  • [X] serial
  • [X] wSerial
  • [X] ahead
  • [X] async
  • [X] wAsync
  • [X] parallel
  • [ ] mergeBy
  • [ ] mergeByM
  • [ ] mergeAsyncBy
  • [ ] mergeAsyncByM
  • [X] zipWith
  • [X] zipWithM
  • [x] zipAsyncWith
  • [X] zipAsyncWithM
  • [ ] concatMapWith
  • [x] concatMap
  • [x] concatMapM
  • [x] concatUnfold
  • [X] concatFoldableWith
  • [X] concatMapFoldableWith
  • [X] concatForFoldableWith
  • [x] before
  • [x] after
  • [x] bracket
  • [x] onException
  • [x] finally
  • [x] handle
  • [X] maxThreads
  • [X] maxBuffer
  • [ ] Rate (..)
  • [X] rate
  • [X] avgRate
  • [ ] minRate
  • [ ] maxRate
  • [ ] constRate
  • [ ] once
  • [ ] each
  • [X] scanx
  • [X] foldx
  • [X] foldxM
  • [X] foldr1
  • [ ] runStream
  • [ ] runN
  • [ ] runWhile
  • [ ] fromHandle
  • [ ] toHandle

src/Streamly/Data/Fold.hs

The test suite is named internal, it should be renamed to just Data.Fold.

  • [ ] drain
  • [ ] drainBy
  • [X] last
  • [X] length
  • [X] sum
  • [X] product
  • [X] maximumBy
  • [X] maximum
  • [X] minimumBy
  • [X] minimum
  • [ ] mean
  • [ ] variance
  • [ ] stdDev
  • [ ] mconcat
  • [ ] foldMap
  • [ ] foldMapM
  • [X] toList
  • [X] index
  • [X] head
  • [X] find
  • [ ] lookup
  • [X] findIndex
  • [X] elemIndex
  • [X] null
  • [X] elem
  • [X] notElem
  • [X] all
  • [X] any
  • [X] and
  • [X] or
  • [ ] sequence
  • [ ] mapM
  • [ ] tee
  • [ ] distribute
  • [ ] partition
  • [ ] unzip

src/Streamly/Data/Unfold.hs

src/Streamly/Unicode/Stream.hs

  • [ ] decodeLatin1
  • [X] decodeUtf8
  • [X] decodeUtf8'
  • [ ] encodeLatin1
  • [ ] encodeLatin1'
  • [X] encodeUtf8
  • [X] encodeUtf8'

src/Streamly/Data/Array/Storable/Foreign.hs

test-suite is named array-test, should be renamed.

  • [ ] A.fromListN
  • [ ] A.fromList
  • [X] A.writeN
  • [X] A.write
  • [ ] A.toList (Used in other tests)
  • [X] A.read
  • [X] A.length

src/Streamly/FileSystem/Handle.hs

  • [ ] read
  • [ ] readWithBufferOf
  • [ ] readChunks
  • [ ] readChunksWithBufferOf
  • [ ] write
  • [ ] writeWithBufferOf
  • [ ] writeChunks

src/Streamly/Data/Unicode/Stream.hs (Deprecated)

  • [ ] decodeLatin1
  • [ ] decodeUtf8
  • [ ] encodeLatin1
  • [ ] encodeUtf8
  • [ ] decodeUtf8Lax
  • [ ] encodeLatin1Lax
  • [ ] encodeUtf8Lax

src/Streamly/Memory/Array.hs (Deprecated)

  • [ ] A.fromListN
  • [ ] A.fromList
  • [ ] A.toList
  • [ ] A.read
  • [ ] A.length

src/Streamly/Network/Socket.hs

  • [ ] SockSpec(..)
  • [ ] accept
  • [ ] read
  • [ ] readWithBufferOf
  • [ ] readChunks
  • [ ] readChunksWithBufferOf
  • [ ] write
  • [ ] writeWithBufferOf
  • [ ] writeChunks

src/Streamly/Network/Inet/TCP.hs

  • [ ] acceptOnAddr
  • [ ] acceptOnPort
  • [ ] acceptOnPortLocal
  • [ ] connect

pranaysashank avatar Oct 20 '20 11:10 pranaysashank

I wonder if there is an easier way to track/check this.

adithyaov avatar Nov 24 '21 05:11 adithyaov

We can possibly derive it from coverage data.

harendra-kumar avatar Nov 24 '21 08:11 harendra-kumar

Here is an algo to derive exposed APIs with no coverage:

  • Run bin/test.sh --coverage
  • Run cabal haddock --haddock-hoogle
  • Use streamly to read the hoogle data file e.g. dist-newstyle/build/x86_64-linux/ghc-8.10.4/streamly-0.8.1/doc/html/streamly/streamly.txt
  • Filter out the comment lines
  • Match the module line
  • Load the hpc .mix file for the module (https://hackage.haskell.org/package/hpc-0.6.0.3/docs/Trace-Hpc-Mix.html)
  • match the function signature lines in the module from the hoogle data file
  • For each function report the name if it is not found as TopLevelBox in the .mix file

We can write a fold or parser to process a single module from the hoogle data stream and then use foldMany or parseMany to process the whole file.

harendra-kumar avatar Nov 24 '21 18:11 harendra-kumar

Closing this. A lot has changed in 0.9.0, many of these will be deprecated and replaced by other ops. Created two new issues related to this #1931 and #1932.

harendra-kumar avatar Oct 12 '22 10:10 harendra-kumar