some test cleanups & category reorganization (#22010)

* clean up some test categories

* mention exact slice issue

* magics into system

* move trangechecks into overflow

* move tmemory to system

* try fix CI

* try fix CI

* final CI fix
This commit is contained in:
metagn
2023-06-06 07:54:07 +03:00
committed by GitHub
parent 2ab948ce53
commit b97d603cd0
134 changed files with 189 additions and 374 deletions

View File

@@ -0,0 +1,16 @@
import std/[assertions, distros]
when defined(windows):
doAssert detectOs(Windows) == true
doAssert detectOs(Linux) == false
doAssert detectOs(MacOSX) == false
when defined(linux):
doAssert detectOs(Linux) == true
doAssert detectOs(Windows) == false
doAssert detectOs(MacOSX) == false
when defined(macosx):
doAssert detectOs(MacOSX) == true
doAssert detectOs(Windows) == false
doAssert detectOs(Linux) == false

View File

@@ -1,16 +0,0 @@
import std/assertions
block: # cmpMem
type
SomeHash = array[15, byte]
var
a: SomeHash
b: SomeHash
a[^1] = byte(1)
let c = a
doAssert cmpMem(a.addr, b.addr, sizeof(SomeHash)) > 0
doAssert cmpMem(b.addr, a.addr, sizeof(SomeHash)) < 0
doAssert cmpMem(a.addr, c.addr, sizeof(SomeHash)) == 0

View File

@@ -1,18 +0,0 @@
discard """
disabled: true
output: '''
just exiting...
'''
joinable: false
"""
# Test `addQuitProc` (now deprecated by `addExitProc`)
import std/syncio
proc myExit() {.noconv.} =
write(stdout, "just exiting...\n")
{.push warning[deprecated]: off.}
addQuitProc(myExit)
{.pop.}

View File

@@ -0,0 +1,9 @@
discard """
errormsg: '''type mismatch: got'''
file: "trat_float.nim"
line: "9,19"
"""
import rationals
var
# this fails - no floats as num or den
r = initRational(1.0'f, 1.0'f)

View File

@@ -0,0 +1,14 @@
discard """
output: '''true'''
"""
import rationals
var
z = Rational[int](num: 0, den: 1)
o = initRational(num=1, den=1)
a = initRational(1, 2)
try:
var
r = initRational(1, 0) # this fails - no zero denominator
except AssertionDefect:
echo "true"

23
tests/stdlib/treadln.nim Normal file
View File

@@ -0,0 +1,23 @@
discard """
output: '''
test the improved readline handling that does not care whether its
Macintosh, Unix or Windows text format.
'''
"""
import std/syncio
# test the improved readline handling that does not care whether its
# Macintosh, Unix or Windows text format.
var
inp: File
line: string
if open(inp, "tests/stdlib/treadln.nim"):
while not endOfFile(inp):
line = readLine(inp)
if line.len >= 2 and line[0] == '#' and line[1] == ' ':
echo line[2..^1]
close(inp)

View File

@@ -15,3 +15,18 @@ block:
doAssert t["name"] == "John"
m()
proc fun()=
let ret = newStringTable(modeCaseSensitive)
ret["foo"] = "bar"
doAssert $ret == "{foo: bar}"
let b = ret["foo"]
doAssert b == "bar"
proc main()=
static: fun()
fun()
main()