1

I have problem with this code, I tried to generate list of non-Empty string like this:

let! x = Arb.generate<string> |> Gen.filter(fun (x) -> x<>null && x <>""&& x<>" ")|>Gen.nonEmptyListOf 

after running my code I am getting this output:

val it : string list [] =
  [|["""; ")"; ":}E"; "B"; "!"; "v"; "re"; "Dv-"; ""; "";
     "eALyb|>Jn %;a="v`m:<="; ""; ""; ""]|]

as you can see my code is generating empty string!

Please could you tell me how can I fix this problem?

1 Answers1

4

I think the result you get does not actually contain an empty string, but instead, contains a string with an invisible character.

To test this, you can try running the following:

let gen = 
  Arb.generate<string> 
  |> Gen.filter(fun (x) -> x<>null && x <>""&& x<>" ")|>Gen.nonEmptyListOf 
let res = Gen.eval 1000 (Random.mkStdGen(42L)) gen

Using 42 as my seed, I get a string value at offset 80 that is rendered as "", but it is actually an invisible character. Here is the F# Interactive session:

> res.[80];;
val it : string = ""

> res.[80].ToCharArray();;
val it : char [] = [|'\014'|]
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553