File: CompletionTests.hs

package info (click to toggle)
haskell-yi-core 0.19.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 756 kB
  • sloc: haskell: 10,038; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Yi.CompletionTests (testSuite) where

import Data.Maybe(isJust)
import Data.Monoid
import Data.Text.Arbitrary()
import Test.Tasty
import Test.Tasty.QuickCheck
import Yi.Completion as C
import qualified Data.Text as T

testSuite :: TestTree
testSuite = testGroup "Completion" [propertyTests]

propertyTests :: TestTree
propertyTests = testGroup "properties"
  [ testProperty "infixUptoEndMatch needle (pre <> needle <> post) == Just (needle <> post) if needle and post not empty and needle not in pre" $
      \pre needle post ->
           not (needle `T.isInfixOf` pre) ==>
           not (T.null post) ==>
             infixUptoEndMatch needle (pre <> needle <> post) == Just (needle <> post)
  , testProperty "infixUptoEndMatch \"\" x == Just x" $
      \x -> infixUptoEndMatch T.empty x == Just x
  , testProperty "isJust (infixUptoEndMatch needle haystack) == needle `Data.Text.isInfixOf` haystack" $
      \needle haystack ->
            isJust (infixUptoEndMatch needle haystack) == needle `T.isInfixOf` haystack
  ]