test.nim 349 B

123456789101112131415161718
  1. # This file needs to be called 'test' nim to provoke a clash
  2. # with the unittest.test name. Issue #
  3. import unittest, macros
  4. # bug #4555
  5. macro memo(n: untyped): typed =
  6. result = n
  7. proc fastFib(n: int): int {.memo.} = 40
  8. proc fib(n: int): int = 40
  9. suite "memoization":
  10. test "recursive function memoization":
  11. check fastFib(40) == fib(40)