tcompiletime_range_checks.nim 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. discard """
  2. cmd: "nim check --hint:Processing:off --hint:Conf:off $file"
  3. errormsg: "18446744073709551615 can't be converted to int8"
  4. nimout: '''tcompiletime_range_checks.nim(36, 21) Error: 2147483648 can't be converted to int32
  5. tcompiletime_range_checks.nim(37, 23) Error: -1 can't be converted to uint64
  6. tcompiletime_range_checks.nim(38, 34) Error: 255 can't be converted to FullNegativeRange
  7. tcompiletime_range_checks.nim(39, 34) Error: 18446744073709551615 can't be converted to HalfNegativeRange
  8. tcompiletime_range_checks.nim(40, 34) Error: 300 can't be converted to FullPositiveRange
  9. tcompiletime_range_checks.nim(41, 30) Error: 101 can't be converted to UnsignedRange
  10. tcompiletime_range_checks.nim(42, 32) Error: -9223372036854775808 can't be converted to SemiOutOfBounds
  11. tcompiletime_range_checks.nim(44, 22) Error: nan can't be converted to int32
  12. tcompiletime_range_checks.nim(46, 23) Error: 1e+100 can't be converted to uint64
  13. tcompiletime_range_checks.nim(49, 22) Error: 18446744073709551615 can't be converted to int64
  14. tcompiletime_range_checks.nim(50, 22) Error: 18446744073709551615 can't be converted to int32
  15. tcompiletime_range_checks.nim(51, 22) Error: 18446744073709551615 can't be converted to int16
  16. tcompiletime_range_checks.nim(52, 21) Error: 18446744073709551615 can't be converted to int8
  17. '''
  18. """
  19. type
  20. UnsignedRange* = range[0'u64 .. 100'u64]
  21. SemiOutOfBounds* = range[0x7ffffffffffffe00'u64 .. 0x8000000000000100'u64]
  22. FullOutOfBounds* = range[0x8000000000000000'u64 .. 0x8000000000000200'u64]
  23. FullNegativeRange* = range[-200 .. -100]
  24. HalfNegativeRange* = range[-50 .. 50]
  25. FullPositiveRange* = range[100 .. 200]
  26. let acceptA* = int32(0x7fffffff'i64)
  27. let acceptB* = (uint64(0'i64))
  28. let acceptD* = (HalfNegativeRange(25'u64))
  29. let acceptE* = (UnsignedRange(50'u64))
  30. let acceptF* = (SemiOutOfBounds(0x7ffffffffffffe00'i64))
  31. let acceptH* = (SemiOutOfBounds(0x8000000000000000'u64))
  32. let rejectA* = int32(0x80000000'i64)
  33. let rejectB* = (uint64(-1'i64))
  34. let rejectC* = (FullNegativeRange(0xff'u32))
  35. let rejectD* = (HalfNegativeRange(0xffffffffffffffff'u64)) # internal `intVal` is `-1` which would be in range.
  36. let rejectE* = (FullPositiveRange(300'u64))
  37. let rejectF* = (UnsignedRange(101'u64))
  38. let rejectG* = (SemiOutOfBounds(0x8000000000000000'i64)) #
  39. let rejectH* = (int32(NaN))
  40. let rejectI* = (int64(1e100))
  41. let rejectJ* = (uint64(1e100))
  42. # removed cross checks from tarithm.nim
  43. let rejectK* = (int64(0xFFFFFFFFFFFFFFFF'u64))
  44. let rejectL* = (int32(0xFFFFFFFFFFFFFFFF'u64))
  45. let rejectM* = (int16(0xFFFFFFFFFFFFFFFF'u64))
  46. let rejectN* = (int8(0xFFFFFFFFFFFFFFFF'u64))