Skip to content

Commit

Permalink
Adjust markCharsRedAtIndices according to property
Browse files Browse the repository at this point in the history
1) Cardano.CLI.markCharsRedAtIndices generates strings of expected length
     Falsifiable (after 1 test):
       []
       ""
       4 /= 0

Fix by removing uncessary trailing reset ansi code

1) Cardano.CLI.markCharsRedAtIndices generates strings of expected length
     Falsifiable (after 7 tests and 8 shrinks):
       [1,0]
       "aa"
       aa
       11 /= 20

Fix by using sort in markCharsRedAtIndices

1) Cardano.CLI.markCharsRedAtIndices generates strings of expected length
     Falsifiable (after 8 tests and 6 shrinks):
       [3,2,2]
       "aaaa"
       aaaa
       13 /= 22

Fix by using nub in markCharsRedAtIndices
  • Loading branch information
Anviking committed May 7, 2020
1 parent a7396a6 commit 72d5bb9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cli/src/Cardano/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ import Data.Char
( toLower )
import Data.Either
( isRight )
import Data.List
( nub, sort )
import Data.List.Extra
( enumerate )
import Data.List.NonEmpty
Expand Down Expand Up @@ -520,7 +522,7 @@ decodeKey = \case
unCharPos (CharPosition x) = x

markCharsRedAtIndices :: Integral i => [i] -> String -> String
markCharsRedAtIndices ixs txt = go 0 ixs txt ++ def
markCharsRedAtIndices ixs = go 0 (sort $ nub ixs)
where
go _c [] [] = mempty
go c (i:is) (s:ss)
Expand Down

0 comments on commit 72d5bb9

Please sign in to comment.