summary refs log tree commit diff stats
path: root/lib/pure/nimprof.nim.cfg
blob: 1589e7394bd829536f7259680c50ceba7ceb4c9d (plain) (blame)
1
--profiler:on
7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# This test is included from within tunittests
import unittest

test "loop variables are captured by ref":
  var funcs: seq[proc (): int {.closure.}] = @[]

  for i in 0..10:
    let ii = i
    funcs.add do -> int: return ii * ii

  check funcs[0]() == 100
  check funcs[3]() == 100

test "loop variables in closureScope are captured by copy":
  var funcs: seq[proc (): int {.closure.}] = @[]

  for i in 0..10:
    closureScope:
      let ii = i
      funcs.add do -> int: return ii * ii

  check funcs[0]() == 0
  check funcs[3]() == 9