diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-25 02:06:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 19:06:41 +0100 |
commit | cbc793b30b10b8e82af7313ac8cd438abf97f7d7 (patch) | |
tree | 84c1ee6cc25ef9f4e407d0492c9a66deac87712f /lib/std | |
parent | d306a04466b7f1129620dc3ab35443119ed4c867 (diff) | |
download | Nim-cbc793b30b10b8e82af7313ac8cd438abf97f7d7.tar.gz |
move tests to testament (#16101)
* move tests to testament * minor * fix random * disable test random
Diffstat (limited to 'lib/std')
-rw-r--r-- | lib/std/enumerate.nim | 19 | ||||
-rw-r--r-- | lib/std/monotimes.nim | 16 | ||||
-rw-r--r-- | lib/std/sha1.nim | 13 |
3 files changed, 0 insertions, 48 deletions
diff --git a/lib/std/enumerate.nim b/lib/std/enumerate.nim index 3def653c8..a8f0e1ba7 100644 --- a/lib/std/enumerate.nim +++ b/lib/std/enumerate.nim @@ -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)] diff --git a/lib/std/monotimes.nim b/lib/std/monotimes.nim index f819cbc8d..c56bf77b3 100644 --- a/lib/std/monotimes.nim +++ b/lib/std/monotimes.nim @@ -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 diff --git a/lib/std/sha1.nim b/lib/std/sha1.nim index 9763b286e..3c1674bcb 100644 --- a/lib/std/sha1.nim +++ b/lib/std/sha1.nim @@ -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") |