summary refs log tree commit diff stats
path: root/tests/vm/tsignaturehash.nim
blob: 42e0a1571233f75020e8985acb234d2e219a78dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# test sym digest is computable at compile time

import macros, algorithm
import 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)