gdb_pretty_printer_test_program.nim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import tables
  2. type
  3. MyEnum = enum
  4. meOne,
  5. meTwo,
  6. meThree,
  7. meFour,
  8. MyOtherEnum = enum
  9. moOne,
  10. moTwo,
  11. moThree,
  12. moFoure,
  13. MyObj = object
  14. a*: int
  15. b*: string
  16. var counter = 0
  17. proc myDebug[T](arg: T): void =
  18. counter += 1
  19. proc testProc(): void =
  20. var myEnum = meTwo
  21. myDebug(myEnum) #1
  22. # create a string, but don't allocate it
  23. var myString: string
  24. myDebug(myString) #2
  25. # create a string object but also make the NTI for MyEnum is generated
  26. myString = $myEnum
  27. myDebug(myString) #3
  28. var mySet = {meOne,meThree}
  29. myDebug(mySet) #4
  30. # for MyOtherEnum there is no NTI. This tests the fallback for the pretty printer.
  31. var moEnum = moTwo
  32. myDebug(moEnum) #5
  33. var moSet = {moOne,moThree}
  34. myDebug(moSet) #6
  35. let myArray = [1,2,3,4,5]
  36. myDebug(myArray) #7
  37. # implicitly initialized seq test
  38. var mySeq: seq[string]
  39. myDebug(mySeq) #8
  40. # len not equal to capacity
  41. let myOtherSeq = newSeqOfCap[string](10)
  42. myDebug(myOtherSeq) #9
  43. let myOtherArray = ["one","two"]
  44. myDebug(myOtherArray) #10
  45. # numeric sec
  46. var mySeq3 = @[1,2,3]
  47. myDebug(mySeq3) #11
  48. # seq had to grow
  49. var mySeq4 = @["one","two","three"]
  50. myDebug(mySeq4) #12
  51. var myTable = initTable[int, string]()
  52. myTable[4] = "four"
  53. myTable[5] = "five"
  54. myTable[6] = "six"
  55. myDebug(myTable) #13
  56. var myOtherTable = {"one": 1, "two": 2, "three": 3}.toTable
  57. myDebug(myOtherTable) #14
  58. var obj = MyObj(a: 1, b: "some string")
  59. myDebug(obj) #15
  60. var tup = ("hello", 42)
  61. myDebug(tup) # 16
  62. assert counter == 16
  63. testProc()