Files
Nim/tests/lookups/test.nim
2018-11-23 11:58:28 +01:00

24 lines
402 B
Nim

discard """
output: '''
[Suite] memoization
'''
"""
# This file needs to be called 'test' nim to provoke a clash
# with the unittest.test name. Issue #
import unittest, macros
# bug #4555
macro memo(n: untyped): typed =
result = n
proc fastFib(n: int): int {.memo.} = 40
proc fib(n: int): int = 40
suite "memoization":
test "recursive function memoization":
check fastFib(40) == fib(40)