mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-23 15:55:23 +00:00
move tests to testament (#16101)
* move tests to testament * minor * fix random * disable test random
This commit is contained in:
@@ -68,22 +68,3 @@ macro enumerate*(x: ForLoopStmt): untyped {.since: (1, 3).} =
|
||||
result.add newFor
|
||||
# now wrap the whole macro in a block to create a new scope
|
||||
result = newBlockStmt(result)
|
||||
|
||||
when isMainModule:
|
||||
let a = @[1, 3, 5, 7]
|
||||
|
||||
block:
|
||||
var res: seq[(int, int)]
|
||||
for i, x in enumerate(a):
|
||||
res.add (i, x)
|
||||
assert res == @[(0, 1), (1, 3), (2, 5), (3, 7)]
|
||||
block:
|
||||
var res: seq[(int, int)]
|
||||
for (i, x) in enumerate(a.items):
|
||||
res.add (i, x)
|
||||
assert res == @[(0, 1), (1, 3), (2, 5), (3, 7)]
|
||||
block:
|
||||
var res: seq[(int, int)]
|
||||
for i, x in enumerate(3, a):
|
||||
res.add (i, x)
|
||||
assert res == @[(3, 1), (4, 3), (5, 5), (6, 7)]
|
||||
|
||||
@@ -152,19 +152,3 @@ proc high*(typ: typedesc[MonoTime]): MonoTime =
|
||||
proc low*(typ: typedesc[MonoTime]): MonoTime =
|
||||
## Returns the lowest representable `MonoTime`.
|
||||
MonoTime(ticks: low(int64))
|
||||
|
||||
when isMainModule:
|
||||
let d = initDuration(nanoseconds = 10)
|
||||
let t1 = getMonoTime()
|
||||
let t2 = t1 + d
|
||||
|
||||
doAssert t2 - t1 == d
|
||||
doAssert t1 == t1
|
||||
doAssert t1 != t2
|
||||
doAssert t2 - d == t1
|
||||
doAssert t1 < t2
|
||||
doAssert t1 <= t2
|
||||
doAssert t1 <= t1
|
||||
doAssert not(t2 < t1)
|
||||
doAssert t1 < high(MonoTime)
|
||||
doAssert low(MonoTime) < t1
|
||||
|
||||
@@ -267,16 +267,3 @@ proc `==`*(a, b: SecureHash): bool =
|
||||
assert a == c
|
||||
# Not a constant-time comparison, but that's acceptable in this context
|
||||
Sha1Digest(a) == Sha1Digest(b)
|
||||
|
||||
when isMainModule:
|
||||
let hash1 = secureHash("a93tgj0p34jagp9[agjp98ajrhp9aej]")
|
||||
doAssert hash1 == hash1
|
||||
doAssert parseSecureHash($hash1) == hash1
|
||||
|
||||
template checkVector(s, exp: string) =
|
||||
doAssert secureHash(s) == parseSecureHash(exp)
|
||||
|
||||
checkVector("", "da39a3ee5e6b4b0d3255bfef95601890afd80709")
|
||||
checkVector("abc", "a9993e364706816aba3e25717850c26c9cd0d89d")
|
||||
checkVector("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
||||
"84983e441c3bd26ebaae4aa1f95129e5e54670f1")
|
||||
|
||||
Reference in New Issue
Block a user