ttypeclasses.nim 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. type
  2. R = ref
  3. V = var
  4. D = distinct
  5. P = ptr
  6. T = type
  7. S = static
  8. OBJ = object
  9. TPL = tuple
  10. SEQ = seq
  11. var i: int
  12. var x: ref int
  13. var y: distinct int
  14. var z: ptr int
  15. const C = @[1, 2, 3]
  16. static:
  17. doAssert x is ref
  18. doAssert y is distinct
  19. doAssert z is ptr
  20. doAssert C is static
  21. doAssert C[1] is static[int]
  22. doAssert C[0] is static[SomeInteger]
  23. doAssert C isnot static[string]
  24. doAssert C is SEQ|OBJ
  25. doAssert C isnot OBJ|TPL
  26. doAssert int is int
  27. doAssert int is T
  28. doAssert int is SomeInteger
  29. doAssert seq[int] is type
  30. doAssert seq[int] is type[seq]
  31. doAssert seq[int] isnot type[seq[float]]
  32. doAssert i isnot type[int]
  33. doAssert type(i) is type[int]
  34. doAssert x isnot T
  35. doAssert y isnot S
  36. doAssert z isnot enum
  37. doAssert x isnot object
  38. doAssert y isnot tuple
  39. doAssert z isnot seq
  40. # XXX: These cases don't work properly at the moment:
  41. # doAssert type[int] isnot int
  42. # doAssert type(int) isnot int