Merge tests into a larger file (part 5 of ∞) (#9368)

* merge magics

* merge metatype tests

* merge method tests

* merge objects tests

* change `import future` to `import sugar`

Nim in Action tests are left with `import future`, to ensure compatibility.

* merge overload tests

* merge proc tests

* merge procvar tests

* merge range tests

* merge seq tests

* merge sets tests

* remove wrong assert from `tsets3`

* fix `jsTests`

* better fix
This commit is contained in:
Miran 2018-10-16 10:50:10 +02:00 • committed by Andreas Rumpf
commit 749dbce4c6
96 changed files with 1763 additions and 1815 deletions

View file

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

View file

@ -1,18 +1,39 @@
discard """
errormsg: "type mismatch"
line: 17
file: "tprocvar.nim"
output: '''
papbpcpdpe7
'''
"""
type
TCallback = proc (a, b: int)
block genericprocvar:
proc foo[T](thing: T) =
discard thing
var a: proc (thing: int) {.nimcall.} = foo[int]
proc huh(x, y: var int) =
x = 0
y = x+1
proc so(c: TCallback) =
c(2, 4)
block tprocvar2:
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")
so(huh)
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)
block tprocvars:
proc doSomething(v: int, x: proc(v:int):int): int = return x(v)
proc doSomething(v: int, x: proc(v:int)) = x(v)
doAssert doSomething(10, proc(v: int): int = return v div 2) == 5

View file

@ -1,32 +0,0 @@
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,18 @@
discard """
errormsg: "type mismatch"
line: 17
file: "tprocvarmismatch.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

@ -1,6 +0,0 @@
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)