tstrtabs2.nim 485 B

123456789101112131415161718192021222324252627282930313233
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c cpp js"
  4. """
  5. import std/strtabs
  6. import std/assertions
  7. macro m =
  8. var t = {"name": "John"}.newStringTable
  9. doAssert t["name"] == "John"
  10. block:
  11. var t = {"name": "John"}.newStringTable
  12. doAssert t["name"] == "John"
  13. m()
  14. proc fun()=
  15. let ret = newStringTable(modeCaseSensitive)
  16. ret["foo"] = "bar"
  17. doAssert $ret == "{foo: bar}"
  18. let b = ret["foo"]
  19. doAssert b == "bar"
  20. proc main()=
  21. static: fun()
  22. fun()
  23. main()