trat_init.nim 265 B

123456789101112131415
  1. discard """
  2. output: '''true'''
  3. """
  4. import rationals
  5. var
  6. z = Rational[int](num: 0, den: 1)
  7. o = initRational(num=1, den=1)
  8. a = initRational(1, 2)
  9. try:
  10. var
  11. r = initRational(1, 0) # this fails - no zero denominator
  12. except AssertionDefect:
  13. echo "true"