tident.nim 585 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. output: '''
  3. Length correct
  4. Correct
  5. Correct
  6. Correct
  7. Correct
  8. Correct
  9. Correct
  10. Correct
  11. Correct
  12. '''
  13. """
  14. type
  15. TIdObj* = object of RootObj
  16. id*: int # unique id; use this for comparisons and not the pointers
  17. PIdObj* = ref TIdObj
  18. PIdent* = ref TIdent
  19. TIdent*{.acyclic.} = object
  20. s*: string
  21. proc myNewString(L: int): string {.inline.} =
  22. result = newString(L)
  23. if result.len == L: echo("Length correct")
  24. else: echo("bug")
  25. for i in 0..L-1:
  26. if result[i] == '\0':
  27. echo("Correct")
  28. else:
  29. echo("Wrong")
  30. var s = myNewString(8)