Why the Faker.Lorem.sentence() does not handle negative input?

By using the latest Faker library, I’ve typed

iex> Faker.Lorem.sentence(-1)

which just stuck the iex, along with a high cpu usage in backgroud.

IMO its such a obvious bug, so why the exception is not handled? Is it designed on purpose or just a bug?

I am gonna wager that locking up the process in an infinite loop is not a desired outcome.

I agree with @benwilson512 though that is perfect example of garbage in, garbage out principle.

1 Like

It ends up trying to find the last element of a Stream.repeatedly, which is going to take a while… :stuck_out_tongue:

3 Likes

You mean that I may should start an issue?

Even better, send PR instead.

1 Like