test.nim 402 B

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