12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- # bug #4462
- import macros
- block:
- proc foo(t: typedesc) {.compileTime.} =
- assert sameType(getType(t), getType(int))
- static:
- foo(int)
- # #4412
- block:
- proc default[T](t: typedesc[T]): T {.inline.} = discard
- static:
- var x = default(type(0))
- # #6379
- static:
- import algorithm
-
- var numArray = [1, 2, 3, 4, -1]
- numArray.sort(cmp)
- assert numArray == [-1, 1, 2, 3, 4]
- var str = "cba"
- str.sort(cmp)
- assert str == "abc"
- # #6086
- import math, sequtils, future
- block:
- proc f: int =
- toSeq(10..<10_000).filter(
- a => a == ($a).map(
- d => (d.ord-'0'.ord).int^4
- ).sum
- ).sum
- var a = f()
- const b = f()
- assert a == b
- block:
- proc f(): seq[char] =
- result = "hello".map(proc(x: char): char = x)
- var runTime = f()
- const compTime = f()
- assert runTime == compTime
- # #6083
- block:
- proc abc(): seq[int] =
- result = @[0]
- result.setLen(2)
- var tmp: int
-
- for i in 0 .. <2:
- inc tmp
- result[i] = tmp
- const fact1000 = abc()
- assert fact1000 == @[1, 2]
|