new tester; all tests categorized
This commit is contained in:
parent
51ee524109
commit
20b5f31c03
481 changed files with 794 additions and 2506 deletions
5
tests/procvar/tgenericprocvar.nim
Normal file
5
tests/procvar/tgenericprocvar.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
proc foo[T](thing: T) =
|
||||
discard thing
|
||||
|
||||
var a: proc (thing: int) {.nimcall.} = foo[int]
|
||||
|
||||
18
tests/procvar/tprocvar.nim
Normal file
18
tests/procvar/tprocvar.nim
Normal 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)
|
||||
|
||||
32
tests/procvar/tprocvar2.nim
Normal file
32
tests/procvar/tprocvar2.nim
Normal 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
|
||||
|
||||
|
||||
|
||||
6
tests/procvar/tprocvars.nim
Normal file
6
tests/procvar/tprocvars.nim
Normal 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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue