diff options
Diffstat (limited to 'tests/vm/tsignaturehash.nim')
-rw-r--r-- | tests/vm/tsignaturehash.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/vm/tsignaturehash.nim b/tests/vm/tsignaturehash.nim new file mode 100644 index 000000000..972ec6fb0 --- /dev/null +++ b/tests/vm/tsignaturehash.nim @@ -0,0 +1,20 @@ +# 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) |