test_nimscript.nims 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # This nimscript is used to test if the following modules can be imported
  2. # http://nim-lang.org/docs/nims.html
  3. {.warning[UnusedImport]: off.}
  4. from stdtest/specialpaths import buildDir
  5. import std/[
  6. # Core:
  7. bitops, typetraits, lenientops, macros, volatile,
  8. # fails: typeinfo, endians
  9. # works but shouldn't: cpuinfo, rlocks, locks
  10. # Algorithms:
  11. algorithm, sequtils,
  12. # Collections:
  13. critbits, deques, heapqueue, intsets, lists, options, sets,
  14. sharedlist, tables,
  15. # fails: sharedtables
  16. # Strings:
  17. editdistance, wordwrap, parseutils, ropes,
  18. pegs, punycode, strformat, strmisc, strscans, strtabs,
  19. strutils, unicode, unidecode,
  20. # works but shouldn't: cstrutils, encodings
  21. # Time handling:
  22. # fails: monotimes, times
  23. # but times.getTime() implemented for VM
  24. # Generic operator system services:
  25. os, streams,
  26. # fails: distros, dynlib, marshal, memfiles, osproc, terminal
  27. # Math libraries:
  28. complex, math, mersenne, random, rationals, stats, sums,
  29. # works but shouldn't: fenv
  30. # Internet protocols:
  31. httpcore, mimetypes, uri,
  32. # fails: asyncdispatch, asyncfile, asyncftpclient, asynchttpserver,
  33. # asyncnet, cgi, cookies, httpclient, nativesockets, net, selectors, smtp
  34. # works but shouldn't test: asyncstreams, asyncfutures
  35. # Threading:
  36. # fails: threadpool
  37. # Parsers:
  38. htmlparser, json, lexbase, parsecfg, parsecsv, parsesql, parsexml,
  39. parseopt,
  40. # XML processing:
  41. xmltree, xmlparser,
  42. # Generators:
  43. htmlgen,
  44. # Hashing:
  45. base64, hashes,
  46. # fails: md5, oids, sha1
  47. # Miscellaneous:
  48. colors, sugar, varints,
  49. # fails: browsers, coro, logging (times), segfaults, unittest (uses methods)
  50. # Modules for JS backend:
  51. # fails: asyncjs, dom, jsconsole, jscore, jsffi,
  52. # Unlisted in lib.html:
  53. decls, compilesettings, with, wrapnils
  54. ]
  55. import stdlib/trandom
  56. echo "Nimscript imports are successful."
  57. block:
  58. doAssert "./foo//./bar/".normalizedPath == "foo/bar".unixToNativePath
  59. block:
  60. doAssert $3'u == "3"
  61. doAssert $3'u64 == "3"
  62. block: # #14142
  63. discard dirExists("/usr")
  64. discard fileExists("/usr/foo")
  65. discard findExe("nim")
  66. block:
  67. doAssertRaises(AssertionDefect): doAssert false
  68. try: doAssert false
  69. except Exception as e:
  70. discard
  71. block: # cpDir, cpFile, dirExists, fileExists, mkDir, mvDir, mvFile, rmDir, rmFile
  72. const dname = buildDir/"D20210121T175016"
  73. const subDir = dname/"sub"
  74. const subDir2 = dname/"sub2"
  75. const fpath = subDir/"f"
  76. const fpath2 = subDir/"f2"
  77. const fpath3 = subDir2/"f"
  78. mkDir(subDir)
  79. writeFile(fpath, "some text")
  80. cpFile(fpath, fpath2)
  81. doAssert fileExists(fpath2)
  82. rmFile(fpath2)
  83. cpDir(subDir, subDir2)
  84. doAssert fileExists(fpath3)
  85. rmDir(subDir2)
  86. mvFile(fpath, fpath2)
  87. doAssert not fileExists(fpath)
  88. doAssert fileExists(fpath2)
  89. mvFile(fpath2, fpath)
  90. mvDir(subDir, subDir2)
  91. doAssert not dirExists(subDir)
  92. doAssert dirExists(subDir2)
  93. mvDir(subDir2, subDir)
  94. rmDir(dname)
  95. block:
  96. # check parseopt can get command line:
  97. discard initOptParser()