toverloading_typedesc.nim 688 B

12345678910111213141516171819202122232425
  1. discard """
  2. exitcode: 0
  3. disabled: '''true'''
  4. """
  5. import moverloading_typedesc
  6. import tables
  7. type
  8. LFoo = object
  9. LBar = object
  10. when isMainModule:
  11. doAssert FBar.new() == 3
  12. proc new(_: typedesc[LFoo]): int = 0
  13. proc new[T](_: typedesc[T]): int = 1
  14. proc new*(_: typedesc[seq[Table[int, seq[Table[int, typedesc]]]]]): int = 7
  15. doAssert LFoo.new() == 0 # Tests selecting more precise type
  16. doAssert LBar.new() == 1 # Tests preferring function from local scope
  17. doAssert FBar.new() == 1
  18. doAssert FFoo.new() == 2 # Tests selecting more precise type from other module
  19. doAssert seq[Table[int, seq[Table[int, string]]]].new() == 5 # Truly complex type test