fix deprecations and other warnings (#13748)

This commit is contained in:
Miran
2020-03-25 19:15:34 +01:00
committed by GitHub
parent 182d3c16e3
commit 5b55aa52d0
22 changed files with 63 additions and 66 deletions

View File

@@ -14,7 +14,7 @@ const manualTests = false
proc makeIPv6HttpServer(hostname: string, port: Port,
message: string): AsyncFD =
let fd = newNativeSocket(AF_INET6)
let fd = createNativeSocket(AF_INET6)
setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
var aiList = getAddrInfo(hostname, port, AF_INET6)
if bindAddr(fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:

View File

@@ -22,58 +22,58 @@ suite "random int":
var set = initHashSet[int](128)
for i in 1..1000:
incl(set, random(high(int)))
incl(set, rand(high(int)))
check len(set) == 1000
test "single number bounds work":
var rand: int
for i in 1..1000:
rand = random(1000)
rand = rand(1000)
check rand < 1000
check rand > -1
test "slice bounds work":
var rand: int
for i in 1..1000:
rand = random(100..1000)
rand = rand(100..1000)
check rand < 1000
check rand >= 100
test " again gives new numbers":
var rand1 = random(1000000)
var rand1 = rand(1000000)
os.sleep(200)
var rand2 = random(1000000)
var rand2 = rand(1000000)
check rand1 != rand2
suite "random float":
test "there might be some randomness":
var set = initSet[float](128)
var set = initHashSet[float](128)
for i in 1..100:
incl(set, random(1.0))
incl(set, rand(1.0))
check len(set) == 100
test "single number bounds work":
var rand: float
for i in 1..1000:
rand = random(1000.0)
rand = rand(1000.0)
check rand < 1000.0
check rand > -1.0
test "slice bounds work":
var rand: float
for i in 1..1000:
rand = random(100.0..1000.0)
rand = rand(100.0..1000.0)
check rand < 1000.0
check rand >= 100.0
test " again gives new numbers":
var rand1:float = random(1000000.0)
var rand1:float = rand(1000000.0)
os.sleep(200)
var rand2:float = random(1000000.0)
var rand2:float = rand(1000000.0)
check rand1 != rand2
suite "cumsum":
@@ -144,4 +144,4 @@ suite "^":
check: compiles(5.5 ^ 2.int8)
check: compiles(5.5 ^ 2.uint)
check: compiles(5.5 ^ 2.uint8)
check: not compiles(5.5 ^ 2.2)
check: not compiles(5.5 ^ 2.2)

View File

@@ -104,7 +104,7 @@ block:
import sets
block:
var x = initSet[int]()
var x = initHashSet[int]()
x.incl 5
try:
echo x[6]

View File

@@ -12,7 +12,7 @@ import os, net, nativesockets, asyncdispatch
const port = Port(28431)
proc initIPv6Server(hostname: string, port: Port): AsyncFD =
let fd = newNativeSocket(AF_INET6)
let fd = createNativeSocket(AF_INET6)
setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
var aiList = getAddrInfo(hostname, port, AF_INET6)
if bindAddr(fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:

View File

@@ -47,7 +47,7 @@ when defined(case_testfile): # compiled test file for child process
else:
import os, osproc, strutils, posix
import os, osproc, strutils
const nim = getCurrentCompilerExe()
block execShellCmdTest:
@@ -74,7 +74,7 @@ else:
block execProcessTest:
let dir = parentDir(currentSourcePath())
let (outp, err) = execCmdEx(nim & " c " & quoteShell(dir / "osproctest.nim"))
let (_, err) = execCmdEx(nim & " c " & quoteShell(dir / "osproctest.nim"))
doAssert err == 0
let exePath = dir / addFileExt("osproctest", ExeExt)
let outStr1 = execProcess(exePath, workingDir = dir, args = ["foo",