mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-29 02:33:58 +00:00
* fix #16256: nimout: <empty> should give error (vacuously true); improve some tests * renamed: tests/stdlib/t9710.nim -> tests/misc/t9710.nim * improve tests * fix non-DRY tests * improve $nim_prs_D/tests/stdlib/t9091.nim * renamed: tests/stdlib/t9091.nim -> tests/misc/t9091.nim * fixup * address comment: doAssert => result.parseErrors
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
discard """
|
||||
targets: "c"
|
||||
output: "test AObj"
|
||||
action: "compile"
|
||||
exitcode: 0
|
||||
timeout: 60.0
|
||||
"""
|
||||
import streams
|
||||
|
||||
block:
|
||||
type Mine = ref object
|
||||
a: int
|
||||
|
||||
proc write(io: Stream, t: Mine) =
|
||||
io.write("sure")
|
||||
|
||||
let str = newStringStream()
|
||||
let mi = new Mine
|
||||
|
||||
str.write(mi)
|
||||
|
||||
block:
|
||||
type
|
||||
AObj = object
|
||||
x: int
|
||||
|
||||
proc foo(a: int): string = ""
|
||||
|
||||
proc test(args: varargs[string, foo]) =
|
||||
echo "varargs"
|
||||
|
||||
proc test(a: AObj) =
|
||||
echo "test AObj"
|
||||
|
||||
let x = AObj()
|
||||
test(x)
|
||||
@@ -1,11 +0,0 @@
|
||||
discard """
|
||||
cmd: "nim c -r --debugger:native --panics:on $options $file"
|
||||
targets: "c"
|
||||
nimout: ""
|
||||
action: "run"
|
||||
exitcode: 0
|
||||
timeout: 60.0
|
||||
"""
|
||||
|
||||
for i in 1 || 200:
|
||||
discard i
|
||||
@@ -1,15 +1,5 @@
|
||||
discard """
|
||||
cmd: "nim c -r --styleCheck:hint --panics:on $options $file"
|
||||
targets: "c"
|
||||
nimout: ""
|
||||
action: "run"
|
||||
exitcode: 0
|
||||
timeout: 60.0
|
||||
"""
|
||||
|
||||
import nativesockets
|
||||
|
||||
|
||||
when not defined(netbsd):
|
||||
# Ref: https://github.com/nim-lang/Nim/issues/15452 - NetBSD doesn't define an `ip` protocol
|
||||
doAssert getProtoByName("ip") == 0
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
discard """
|
||||
cmd: "nim c -r --styleCheck:hint --panics:on $options $file"
|
||||
targets: "c"
|
||||
nimout: ""
|
||||
action: "run"
|
||||
exitcode: 0
|
||||
timeout: 60.0
|
||||
"""
|
||||
|
||||
import nativesockets
|
||||
import std/nativesockets
|
||||
import stdtest/testutils
|
||||
|
||||
block:
|
||||
let hostname = getHostname()
|
||||
doAssert hostname.len > 0
|
||||
|
||||
when defined(windows):
|
||||
doAssert toInt(IPPROTO_IP) == 0.cint
|
||||
doAssert toInt(IPPROTO_ICMP) == 1.cint
|
||||
doAssert toInt(IPPROTO_TCP) == 6.cint
|
||||
doAssert toInt(IPPROTO_UDP) == 17.cint
|
||||
doAssert toInt(IPPROTO_IPV6) == 41.cint
|
||||
doAssert toInt(IPPROTO_ICMPV6) == 58.cint
|
||||
doAssert toInt(IPPROTO_RAW) == 20.cint
|
||||
assertAll:
|
||||
toInt(IPPROTO_IP) == 0
|
||||
toInt(IPPROTO_ICMP) == 1
|
||||
toInt(IPPROTO_TCP) == 6
|
||||
toInt(IPPROTO_UDP) == 17
|
||||
toInt(IPPROTO_IPV6) == 41
|
||||
toInt(IPPROTO_ICMPV6) == 58
|
||||
toInt(IPPROTO_RAW) == 20
|
||||
|
||||
# no changes to enum value
|
||||
doAssert ord(IPPROTO_TCP) == 6
|
||||
doAssert ord(IPPROTO_UDP) == 17
|
||||
doAssert ord(IPPROTO_IP) == 18
|
||||
doAssert ord(IPPROTO_IPV6) == 19
|
||||
doAssert ord(IPPROTO_RAW) == 20
|
||||
doAssert ord(IPPROTO_ICMP) == 21
|
||||
doAssert ord(IPPROTO_ICMPV6) == 22
|
||||
# no changes to enum value
|
||||
ord(IPPROTO_TCP) == 6
|
||||
ord(IPPROTO_UDP) == 17
|
||||
ord(IPPROTO_IP) == 18
|
||||
ord(IPPROTO_IPV6) == 19
|
||||
ord(IPPROTO_RAW) == 20
|
||||
ord(IPPROTO_ICMP) == 21
|
||||
ord(IPPROTO_ICMPV6) == 22
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
discard """
|
||||
cmd: "nim c -r --styleCheck:hint --panics:on $options $file"
|
||||
matrix: "-d:danger; -d:release"
|
||||
targets: "c cpp"
|
||||
nimout: ""
|
||||
action: "run"
|
||||
exitcode: 0
|
||||
timeout: 60.0
|
||||
"""
|
||||
|
||||
import std/varints
|
||||
|
||||
# xxx doesn't work with js: tvarints.nim(18, 14) `wrLen == rdLen` [AssertionDefect]
|
||||
|
||||
block:
|
||||
var dest: array[50, byte]
|
||||
@@ -39,46 +30,39 @@ block:
|
||||
block:
|
||||
var hugeIntArray: array[50, byte]
|
||||
var readedInt: uint64
|
||||
doAssert writeVu64(hugeIntArray, 0.uint64) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == 0.uint64
|
||||
doAssert writeVu64(hugeIntArray, uint64.high) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == uint64.high
|
||||
doAssert writeVu64(hugeIntArray, uint64(int64.high)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == uint64(int64.high)
|
||||
doAssert writeVu64(hugeIntArray, uint64(int32.high)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == uint64(int32.high)
|
||||
doAssert writeVu64(hugeIntArray, uint64(int16.high)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == uint64(int16.high)
|
||||
doAssert writeVu64(hugeIntArray, uint64(int8.high)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == uint64(int8.high)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](0.0)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](0.0)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](-0.0)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](-0.0)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](0.1)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](0.1)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](0.9555555555555555555555501)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](0.9555555555555555555555501)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](+Inf)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](+Inf)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](NegInf)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](NegInf)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](Nan)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](Nan)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](3.1415926535897932384626433)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](3.1415926535897932384626433)
|
||||
doAssert writeVu64(hugeIntArray, cast[uint64](2.71828182845904523536028747)) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == cast[uint64](2.71828182845904523536028747)
|
||||
|
||||
template chk(a) =
|
||||
let b = cast[uint64](a)
|
||||
doAssert writeVu64(hugeIntArray, b) == readVu64(hugeIntArray, readedInt)
|
||||
doAssert readedInt == b
|
||||
|
||||
chk 0
|
||||
chk uint64.high
|
||||
chk int64.high
|
||||
chk int32.high
|
||||
chk int16.high
|
||||
chk int16.high
|
||||
chk int8.high
|
||||
chk 0.0
|
||||
chk -0.0
|
||||
chk 0.1
|
||||
chk Inf
|
||||
chk NegInf
|
||||
chk Nan
|
||||
chk 3.1415926535897932384626433
|
||||
|
||||
block:
|
||||
doAssert encodeZigzag(decodeZigzag(0.uint64)) == 0.uint64
|
||||
doAssert encodeZigzag(decodeZigzag(uint64(uint32.high))) == uint64(uint32.high)
|
||||
doAssert encodeZigzag(decodeZigzag(uint64(int32.high))) == uint64(int32.high)
|
||||
doAssert encodeZigzag(decodeZigzag(uint64(int16.high))) == uint64(int16.high)
|
||||
doAssert encodeZigzag(decodeZigzag(uint64(int8.high))) == uint64(int8.high)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](0.0))) == cast[uint64](0.0)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](0.1))) == cast[uint64](0.1)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](0.9555555555555555555555501))) == cast[uint64](0.9555555555555555555555501)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](+Inf))) == cast[uint64](+Inf)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](3.1415926535897932384626433))) == cast[uint64](3.1415926535897932384626433)
|
||||
doAssert encodeZigzag(decodeZigzag(cast[uint64](2.71828182845904523536028747))) == cast[uint64](2.71828182845904523536028747)
|
||||
template chk(a) =
|
||||
let b = cast[uint64](a)
|
||||
doAssert encodeZigzag(decodeZigzag(b)) == b
|
||||
chk 0
|
||||
chk uint32.high
|
||||
chk int32.high
|
||||
chk int16.high
|
||||
chk int8.high
|
||||
chk 0.0
|
||||
chk 0.1
|
||||
chk 0.9555555555555555555555501
|
||||
chk Inf
|
||||
chk 3.1415926535897932384626433
|
||||
chk 2.71828182845904523536028747
|
||||
|
||||
Reference in New Issue
Block a user