mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
* move sha1, md5 to nimble packages * boot the compiler * fixes tests * build the documentation * fixes docs * lol, I forgot koch.nim * add `nimHasChecksums` define * clone checksums but maybe copying is better * bump nimble hash * use ChecksumsStableCommit * fixes tests * deprecate them * fixes paths * fixes koch
21 lines
568 B
Nim
21 lines
568 B
Nim
# test sym digest is computable at compile time
|
|
|
|
import macros, algorithm
|
|
import ../../dist/checksums/src/checksums/md5
|
|
|
|
macro testmacro(s: typed{nkSym}): string =
|
|
let s = getMD5(signaturehash(s) & " - " & symBodyHash(s))
|
|
result = newStrLitNode(s)
|
|
|
|
macro testmacro(s: typed{nkOpenSymChoice|nkClosedSymChoice}): string =
|
|
var str = ""
|
|
for sym in s:
|
|
str &= symBodyHash(sym)
|
|
result = newStrLitNode(getMD5(str))
|
|
|
|
# something recursive and/or generic
|
|
discard testmacro(testmacro)
|
|
discard testmacro(`[]`)
|
|
discard testmacro(binarySearch)
|
|
discard testmacro(sort)
|