mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-31 04:29:02 +00:00
fix deprecations and other warnings (#13748)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -104,7 +104,7 @@ block:
|
||||
import sets
|
||||
|
||||
block:
|
||||
var x = initSet[int]()
|
||||
var x = initHashSet[int]()
|
||||
x.incl 5
|
||||
try:
|
||||
echo x[6]
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user