tstrtabs.nim 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. sortoutput: true
  4. output: '''
  5. key1: value1
  6. key2: value2
  7. key_0: value0
  8. key_10: value10
  9. key_11: value11
  10. key_12: value12
  11. key_13: value13
  12. key_14: value14
  13. key_15: value15
  14. key_16: value16
  15. key_17: value17
  16. key_18: value18
  17. key_19: value19
  18. key_20: value20
  19. key_21: value21
  20. key_22: value22
  21. key_23: value23
  22. key_24: value24
  23. key_25: value25
  24. key_26: value26
  25. key_27: value27
  26. key_28: value28
  27. key_29: value29
  28. key_30: value30
  29. key_31: value31
  30. key_32: value32
  31. key_33: value33
  32. key_34: value34
  33. key_35: value35
  34. key_36: value36
  35. key_37: value37
  36. key_38: value38
  37. key_39: value39
  38. key_3: value3
  39. key_40: value40
  40. key_41: value41
  41. key_42: value42
  42. key_43: value43
  43. key_44: value44
  44. key_45: value45
  45. key_46: value46
  46. key_47: value47
  47. key_48: value48
  48. key_49: value49
  49. key_4: value4
  50. key_50: value50
  51. key_51: value51
  52. key_52: value52
  53. key_53: value53
  54. key_54: value54
  55. key_55: value55
  56. key_56: value56
  57. key_57: value57
  58. key_58: value58
  59. key_59: value59
  60. key_5: value5
  61. key_60: value60
  62. key_61: value61
  63. key_62: value62
  64. key_63: value63
  65. key_64: value64
  66. key_65: value65
  67. key_66: value66
  68. key_67: value67
  69. key_68: value68
  70. key_69: value69
  71. key_6: value6
  72. key_70: value70
  73. key_71: value71
  74. key_72: value72
  75. key_73: value73
  76. key_74: value74
  77. key_75: value75
  78. key_76: value76
  79. key_77: value77
  80. key_78: value78
  81. key_79: value79
  82. key_7: value7
  83. key_80: value80
  84. key_8: value8
  85. key_9: value9
  86. length of table 0
  87. length of table 81
  88. value1 = value2
  89. '''
  90. """
  91. import std/[strtabs, assertions, syncio]
  92. var tab = newStringTable({"key1": "val1", "key2": "val2"},
  93. modeStyleInsensitive)
  94. for i in 0..80:
  95. tab["key_" & $i] = "value" & $i
  96. for key, val in pairs(tab):
  97. writeLine(stdout, key, ": ", val)
  98. writeLine(stdout, "length of table ", $tab.len)
  99. writeLine(stdout, `%`("$key1 = $key2", tab, {useEnvironment}))
  100. tab.clear
  101. writeLine(stdout, "length of table ", $tab.len)
  102. block:
  103. var x = {"k": "v", "11": "22", "565": "67"}.newStringTable
  104. doAssert x["k"] == "v"
  105. doAssert x["11"] == "22"
  106. doAssert x["565"] == "67"
  107. x["11"] = "23"
  108. doAssert x["11"] == "23"
  109. x.clear(modeCaseInsensitive)
  110. x["11"] = "22"
  111. doAssert x["11"] == "22"