1

I am trying to do TDD in haskell using HSpec. So while writing special case scenario for division operator for example:

  • 3 / 0 => Infinity
  • 0 / 0 => Nan

How to test the above cases using Hspec ?

Bakuriu
  • 98,325
  • 22
  • 197
  • 231
phoenix
  • 81
  • 1
  • 9

1 Answers1

7

Use the functions isInfinite and isNaN:

Prelude> isInfinite (3 / 0.0)
True
Prelude> isNaN (0.0/0.0)
True
ErikR
  • 51,541
  • 9
  • 73
  • 124