tos.nim 801 B

123456789101112131415161718192021222324
  1. # xxx consider merging this in tests/stdlib/tos.nim for increased coverage (with selecting disabling)
  2. static: doAssert defined(nodejs)
  3. import os
  4. block:
  5. doAssert "./foo//./bar/".normalizedPath == "foo/bar"
  6. doAssert relativePath(".//foo/bar", "foo") == "bar"
  7. doAssert "/".isAbsolute
  8. doAssert not "".isAbsolute
  9. doAssert not ".".isAbsolute
  10. doAssert not "foo".isAbsolute
  11. doAssert relativePath("", "bar") == ""
  12. doAssert normalizedPath(".///foo//./") == "foo"
  13. let cwd = getCurrentDir()
  14. let isWindows = '\\' in cwd
  15. # defined(windows) doesn't work with -d:nodejs but should
  16. # these actually break because of that (see https://github.com/nim-lang/Nim/issues/13469)
  17. if not isWindows:
  18. doAssert cwd.isAbsolute
  19. doAssert relativePath(getCurrentDir() / "foo", "bar") == "../foo"