mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
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:
16
tests/stdlib/tdistros_detect.nim
Normal file
16
tests/stdlib/tdistros_detect.nim
Normal 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
|
||||
@@ -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
|
||||
@@ -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.}
|
||||
9
tests/stdlib/trat_float.nim
Normal file
9
tests/stdlib/trat_float.nim
Normal 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)
|
||||
14
tests/stdlib/trat_init.nim
Normal file
14
tests/stdlib/trat_init.nim
Normal 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
23
tests/stdlib/treadln.nim
Normal 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)
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user