new tester; all tests categorized

This commit is contained in:
Araq 2014-01-13 02:10:03 +01:00
commit 20b5f31c03
481 changed files with 794 additions and 2506 deletions

View file

@ -0,0 +1,5 @@
proc foo[T](thing: T) =
discard thing
var a: proc (thing: int) {.nimcall.} = foo[int]

View file

@ -0,0 +1,18 @@
discard """
errormsg: "type mismatch"
line: 17
file: "tprocvar.nim"
"""
type
TCallback = proc (a, b: int)
proc huh(x, y: var int) =
x = 0
y = x+1
proc so(c: TCallback) =
c(2, 4)
so(huh)

View file

@ -0,0 +1,32 @@
discard """
file: "tprocvar.nim"
output: "papbpcpdpe7"
"""
# test variables of type proc
proc pa() {.cdecl.} = write(stdout, "pa")
proc pb() {.cdecl.} = write(stdout, "pb")
proc pc() {.cdecl.} = write(stdout, "pc")
proc pd() {.cdecl.} = write(stdout, "pd")
proc pe() {.cdecl.} = write(stdout, "pe")
const
algos = [pa, pb, pc, pd, pe]
var
x: proc (a, b: int): int {.cdecl.}
proc ha(c, d: int): int {.cdecl.} =
echo(c + d)
result = c + d
for a in items(algos):
a()
x = ha
discard x(3, 4)
#OUT papbpcpdpe7

View file

@ -0,0 +1,6 @@
proc doSomething(v: Int, x: proc(v:Int):Int): Int = return x(v)
proc doSomething(v: Int, x: proc(v:Int)) = x(v)
echo doSomething(10, proc(v: Int): Int = return v div 2)