tcast.nim 469 B

12345678910111213141516171819202122
  1. discard """
  2. targets: "c cpp js"
  3. """
  4. proc main() =
  5. block: # bug #16806
  6. let
  7. a = 42u16
  8. b = cast[int16](a)
  9. doAssert a.int16 == 42
  10. doAssert b in int16.low..int16.high
  11. block: # bug #16808
  12. doAssert cast[int8](cast[uint8](int8(-12))) == int8(-12)
  13. doAssert cast[int16](cast[uint16](int16(-12))) == int16(-12)
  14. doAssert cast[int32](cast[uint32](int32(-12))) == int32(-12)
  15. doAssert cast[int8](int16.high) == -1
  16. static: main()
  17. main()