remove isMainModule from json,os,sequtils (#14572)

* move json.isMainModule => tjson

* move isMainModule => tos,tsequtils
This commit is contained in:
Timothee Cour 2020-06-06 02:50:46 -07:00 • committed by GitHub
commit d573581eb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 759 additions and 757 deletions

View file

@ -447,3 +447,66 @@ block isRelativeTo:
doAssert isRelativeTo("foo/bar", ".")
doAssert not isRelativeTo("foo/bar.nims", "foo/bar.nim")
doAssert not isRelativeTo("/foo2", "/foo")
block: # quoteShellWindows
assert quoteShellWindows("aaa") == "aaa"
assert quoteShellWindows("aaa\"") == "aaa\\\""
assert quoteShellWindows("") == "\"\""
block: # quoteShellWindows
assert quoteShellPosix("aaa") == "aaa"
assert quoteShellPosix("aaa a") == "'aaa a'"
assert quoteShellPosix("") == "''"
assert quoteShellPosix("a'a") == "'a'\"'\"'a'"
block: # quoteShell
when defined(posix):
assert quoteShell("") == "''"
block: # normalizePathEnd
# handle edge cases correctly: shouldn't affect whether path is
# absolute/relative
doAssert "".normalizePathEnd(true) == ""
doAssert "".normalizePathEnd(false) == ""
doAssert "/".normalizePathEnd(true) == $DirSep
doAssert "/".normalizePathEnd(false) == $DirSep
when defined(posix):
doAssert "//".normalizePathEnd(false) == "/"
doAssert "foo.bar//".normalizePathEnd == "foo.bar"
doAssert "bar//".normalizePathEnd(trailingSep = true) == "bar/"
when defined(Windows):
doAssert r"C:\foo\\".normalizePathEnd == r"C:\foo"
doAssert r"C:\foo".normalizePathEnd(trailingSep = true) == r"C:\foo\"
# this one is controversial: we could argue for returning `D:\` instead,
# but this is simplest.
doAssert r"D:\".normalizePathEnd == r"D:"
doAssert r"E:/".normalizePathEnd(trailingSep = true) == r"E:\"
doAssert "/".normalizePathEnd == r"\"
block: # isValidFilename
# Negative Tests.
doAssert not isValidFilename("abcd", maxLen = 2)
doAssert not isValidFilename("0123456789", maxLen = 8)
doAssert not isValidFilename("con")
doAssert not isValidFilename("aux")
doAssert not isValidFilename("prn")
doAssert not isValidFilename("OwO|UwU")
doAssert not isValidFilename(" foo")
doAssert not isValidFilename("foo ")
doAssert not isValidFilename("foo.")
doAssert not isValidFilename("con.txt")
doAssert not isValidFilename("aux.bat")
doAssert not isValidFilename("prn.exe")
doAssert not isValidFilename("nim>.nim")
doAssert not isValidFilename(" foo.log")
# Positive Tests.
doAssert isValidFilename("abcd", maxLen = 42.Positive)
doAssert isValidFilename("c0n")
doAssert isValidFilename("foo.aux")
doAssert isValidFilename("bar.prn")
doAssert isValidFilename("OwO_UwU")
doAssert isValidFilename("cron")
doAssert isValidFilename("ux.bat")
doAssert isValidFilename("nim.nim")
doAssert isValidFilename("foo.log")