t1.nim 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: # bug #23947
  19. template foo =
  20. let test_u64 : uint64 = 0xFF07.uint64
  21. let test_u8 : uint8 = test_u64.uint8
  22. # Error: illegal conversion from '65287' to '[0..255]'
  23. doAssert test_u8 == 7
  24. static: foo()
  25. foo()
  26. block:
  27. # bug #22085
  28. const
  29. x = uint32(uint64.high) # vm error
  30. u = uint64.high
  31. v = uint32(u) # vm error
  32. let
  33. z = uint64.high
  34. y = uint32(z) # runtime ok
  35. let
  36. w = uint32(uint64.high) # semfold error
  37. doAssert x == w
  38. doAssert v == y
  39. # bug #14522
  40. doAssert 0xFF000000_00000000.uint64 == 18374686479671623680'u64
  41. block: # bug #23954
  42. let testRT_u8 : uint8 = 0x107.uint8
  43. doAssert testRT_u8 == 7
  44. const testCT_u8 : uint8 = 0x107.uint8
  45. doAssert testCT_u8 == 7
  46. block: # issue #24104
  47. type P = distinct uint # uint, uint8, uint16, uint32, uint64
  48. let v = 0.P
  49. case v
  50. of 0.P: discard
  51. else: discard