t1.nim 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. discard """
  2. targets: "c cpp"
  3. """
  4. doAssert typeOf(1.int64 + 1.int) is int64
  5. doAssert typeOf(1.uint64 + 1.uint) is uint64
  6. doAssert int64 is SomeNumber
  7. doAssert int64 is (SomeNumber and not(uint32|uint64|uint|int))
  8. doAssert int64 is (not(uint32|uint64|uint|int))
  9. doAssert int isnot int64
  10. doAssert int64 isnot int
  11. var myInt16 = 5i16
  12. var myInt: int
  13. doAssert typeOf(myInt16 + 34) is int16 # of type `int16`
  14. doAssert typeOf(myInt16 + myInt) is int # of type `int`
  15. doAssert typeOf(myInt16 + 2i32) is int32 # of type `int32`
  16. doAssert int32 isnot int64
  17. doAssert int32 isnot int
  18. block:
  19. # bug #22085
  20. const
  21. x = uint32(uint64.high) # vm error
  22. u = uint64.high
  23. v = uint32(u) # vm error
  24. let
  25. z = uint64.high
  26. y = uint32(z) # runtime ok
  27. let
  28. w = uint32(uint64.high) # semfold error
  29. doAssert x == w
  30. doAssert v == y
  31. # bug #14522
  32. doAssert 0xFF000000_00000000.uint64 == 18374686479671623680'u64
  33. block: # bug #23954
  34. let testRT_u8 : uint8 = 0x107.uint8
  35. doAssert testRT_u8 == 7
  36. const testCT_u8 : uint8 = 0x107.uint8
  37. doAssert testCT_u8 == 7
  38. block: # issue #24104
  39. type P = distinct uint # uint, uint8, uint16, uint32, uint64
  40. let v = 0.P
  41. case v
  42. of 0.P: discard
  43. else: discard