make more standard libraries work with nimPreviewSlimSystem (#20343)

* make more standard libraries work with `nimPreviewSlimSystem`

* typo

* part two

* Delete specutils.nim

* fixes more tests

* more fixes

* fixes tests

* fixes three more tests

* add formatfloat import

* fix

* last
This commit is contained in:
ringabout 2022-09-28 02:06:23 +08:00 • committed by GitHub
commit 3d2f0e2c7c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
194 changed files with 299 additions and 54 deletions

View file

@ -40,6 +40,10 @@ include "system/hti.nim"
{.pop.} {.pop.}
when defined(nimPreviewSlimSystem):
import std/assertions
type type
AnyKind* = enum ## The kind of `Any`. AnyKind* = enum ## The kind of `Any`.
akNone = 0, ## invalid akNone = 0, ## invalid

View file

@ -45,6 +45,9 @@ jkl"""
import tables, strutils import tables, strutils
when defined(nimPreviewSlimSystem):
import std/assertions
type type
Item* = object ## An Item in the list of differences. Item* = object ## An Item in the list of differences.
startA*: int ## Start Line number in Data A. startA*: int ## Start Line number in Data A.

View file

@ -172,6 +172,8 @@ import db_common
export db_common export db_common
import std/private/[since, dbutils] import std/private/[since, dbutils]
when defined(nimPreviewSlimSystem):
import std/assertions
type type
DbConn* = PSqlite3 ## Encapsulates a database connection. DbConn* = PSqlite3 ## Encapsulates a database connection.

View file

@ -66,6 +66,9 @@ from strutils import `%`
import options import options
from unicode import runeLenAt from unicode import runeLenAt
when defined(nimPreviewSlimSystem):
import std/assertions
export options export options
type type

View file

@ -34,6 +34,9 @@ runnableExamples:
import import
pcre, strutils, rtarrays pcre, strutils, rtarrays
when defined(nimPreviewSlimSystem):
import std/syncio
const const
MaxSubpatterns* = 20 MaxSubpatterns* = 20
## defines the maximum number of subpatterns that can be captured. ## defines the maximum number of subpatterns that can be captured.

View file

@ -232,6 +232,9 @@ import asyncfutures except callSoon
import nativesockets, net, deques import nativesockets, net, deques
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
export Port, SocketFlag export Port, SocketFlag
export asyncfutures except callSoon export asyncfutures except callSoon
export asyncstreams export asyncstreams

View file

@ -24,6 +24,9 @@
import asyncdispatch, os import asyncdispatch, os
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
# TODO: Fix duplication introduced by PR #4683. # TODO: Fix duplication introduced by PR #4683.
when defined(windows) or defined(nimdoc): when defined(windows) or defined(nimdoc):

View file

@ -81,6 +81,9 @@
import asyncdispatch, asyncnet, nativesockets, strutils, parseutils, os, times import asyncdispatch, asyncnet, nativesockets, strutils, parseutils, os, times
from net import BufferSize from net import BufferSize
when defined(nimPreviewSlimSystem):
import std/assertions
type type
AsyncFtpClient* = ref object AsyncFtpClient* = ref object
csock*: AsyncSocket csock*: AsyncSocket

View file

@ -13,6 +13,7 @@ import system/stacktraces
when defined(nimPreviewSlimSystem): when defined(nimPreviewSlimSystem):
import std/objectdollar # for StackTraceEntry import std/objectdollar # for StackTraceEntry
import std/assertions
# TODO: This shouldn't need to be included, but should ideally be exported. # TODO: This shouldn't need to be included, but should ideally be exported.
type type

View file

@ -44,6 +44,9 @@ import httpcore
from nativesockets import getLocalAddr, Domain, AF_INET, AF_INET6 from nativesockets import getLocalAddr, Domain, AF_INET, AF_INET6
import std/private/since import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
export httpcore except parseHeader export httpcore except parseHeader
const const

View file

@ -96,6 +96,10 @@
## ##
import std/private/since import std/private/since
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
import asyncdispatch, nativesockets, net, os import asyncdispatch, nativesockets, net, os
export SOBool export SOBool

View file

@ -11,6 +11,9 @@
import asyncfutures import asyncfutures
when defined(nimPreviewSlimSystem):
import std/assertions
import deques import deques
type type

View file

@ -32,6 +32,9 @@
import strutils, os, strtabs, cookies, uri import strutils, os, strtabs, cookies, uri
export uri.encodeUrl, uri.decodeUrl export uri.encodeUrl, uri.decodeUrl
when defined(nimPreviewSlimSystem):
import std/syncio
proc addXmlChar(dest: var string, c: char) {.inline.} = proc addXmlChar(dest: var string, c: char) {.inline.} =
case c case c

View file

@ -36,6 +36,9 @@ runnableExamples:
import std/private/since import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
type type
NodeObj[T] {.acyclic.} = object NodeObj[T] {.acyclic.} = object
byte: int ## byte index of the difference byte: int ## byte index of the difference

View file

@ -19,6 +19,9 @@ when defined(windows):
elif defined(linux): elif defined(linux):
from cpuinfo import countProcessors from cpuinfo import countProcessors
when defined(nimPreviewSlimSystem):
import std/syncio
type type
ThreadPoolAdvice* = enum ThreadPoolAdvice* = enum
doNothing, doNothing,

View file

@ -23,6 +23,9 @@ when not compileOption("threads"):
import cpuinfo, cpuload, locks, os import cpuinfo, cpuload, locks, os
when defined(nimPreviewSlimSystem):
import std/assertions
{.push stackTrace:off.} {.push stackTrace:off.}
type type

View file

@ -11,6 +11,9 @@
import strtabs, times, options import strtabs, times, options
when defined(nimPreviewSlimSystem):
import std/assertions
type type
SameSite* {.pure.} = enum ## The SameSite cookie attribute. SameSite* {.pure.} = enum ## The SameSite cookie attribute.

View file

@ -40,6 +40,8 @@ runnableExamples:
import os import os
when defined(nimPreviewSlimSystem):
import std/assertions
when not defined(windows): when not defined(windows):
type type

View file

@ -237,6 +237,9 @@ import std/[
asyncnet, asyncdispatch, asyncfile, nativesockets, asyncnet, asyncdispatch, asyncfile, nativesockets,
] ]
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
export httpcore except parseHeader # TODO: The `except` doesn't work export httpcore except parseHeader # TODO: The `except` doesn't work
type type

View file

@ -56,6 +56,9 @@ Please contribute a new implementation.""".}
import streams, typeinfo, json, intsets, tables, unicode import streams, typeinfo, json, intsets, tables, unicode
when defined(nimPreviewSlimSystem):
import std/[assertions, formatfloat]
proc ptrToInt(x: pointer): int {.inline.} = proc ptrToInt(x: pointer): int {.inline.} =
result = cast[int](x) # don't skip alignment result = cast[int](x) # don't skip alignment

View file

@ -24,6 +24,10 @@ else:
import os, streams import os, streams
when defined(nimPreviewSlimSystem):
import std/[syncio, assertions]
proc newEIO(msg: string): ref IOError = proc newEIO(msg: string): ref IOError =
new(result) new(result)
result.msg = msg result.msg = msg

View file

@ -29,6 +29,10 @@ runnableExamples:
import tables import tables
from strutils import startsWith, toLowerAscii, strip from strutils import startsWith, toLowerAscii, strip
when defined(nimPreviewSlimSystem):
import std/assertions
type type
MimeDB* = object MimeDB* = object
mimes: OrderedTable[string, string] mimes: OrderedTable[string, string]

View file

@ -16,6 +16,8 @@ import os, options
import std/private/since import std/private/since
import std/strbasics import std/strbasics
when defined(nimPreviewSlimSystem):
import std/[assertions, syncio]
when hostOS == "solaris": when hostOS == "solaris":
{.passl: "-lsocket -lnsl".} {.passl: "-lsocket -lnsl".}

View file

@ -90,6 +90,9 @@ runnableExamples("-r:off"):
import std/private/since import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
import nativesockets import nativesockets
import os, strutils, times, sets, options, std/monotimes import os, strutils, times, sets, options, std/monotimes
import ssl_config import ssl_config

View file

@ -15,6 +15,9 @@
import strutils, lexbase import strutils, lexbase
import std/private/decode_helpers import std/private/decode_helpers
when defined(nimPreviewSlimSystem):
import std/assertions
# ------------------- scanner ------------------------------------------------- # ------------------- scanner -------------------------------------------------
type type

View file

@ -149,6 +149,9 @@ an HTML document contains.
import import
strutils, lexbase, streams, unicode strutils, lexbase, streams, unicode
when defined(nimPreviewSlimSystem):
import std/assertions
# the parser treats ``<br />`` as ``<br></br>`` # the parser treats ``<br />`` as ``<br></br>``
# xmlElementCloseEnd, ## ``/>`` # xmlElementCloseEnd, ## ``/>``

View file

@ -75,6 +75,9 @@ runnableExamples:
import algorithm, math import algorithm, math
import std/private/since import std/private/since
when defined(nimPreviewSlimSystem):
import std/assertions
include system/inclrtl include system/inclrtl
{.push debugger: off.} {.push debugger: off.}

View file

@ -22,6 +22,8 @@ runnableExamples:
doAssert r1 / r2 == -2 // 3 doAssert r1 / r2 == -2 // 3
import math, hashes import math, hashes
when defined(nimPreviewSlimSystem):
import std/assertions
type Rational*[T] = object type Rational*[T] = object
## A rational number, consisting of a numerator `num` and a denominator `den`. ## A rational number, consisting of a numerator `num` and a denominator `den`.

View file

@ -20,7 +20,7 @@ include system/inclrtl
import streams import streams
when defined(nimPreviewSlimSystem): when defined(nimPreviewSlimSystem):
import std/syncio import std/[syncio, formatfloat, assertions]
{.push debugger: off.} # the user does not want to trace a part {.push debugger: off.} # the user does not want to trace a part
# of the standard library! # of the standard library!

View file

@ -29,6 +29,9 @@
import os, nativesockets import os, nativesockets
when defined(nimPreviewSlimSystem):
import std/assertions
const hasThreadSupport = compileOption("threads") and defined(threadsafe) const hasThreadSupport = compileOption("threads") and defined(threadsafe)
const ioselSupportedPlatform* = defined(macosx) or defined(freebsd) or const ioselSupportedPlatform* = defined(macosx) or defined(freebsd) or

View file

@ -55,6 +55,9 @@ runnableExamples:
from math import FloatClass, sqrt, pow, round from math import FloatClass, sqrt, pow, round
when defined(nimPreviewSlimSystem):
import std/[assertions, formatfloat]
{.push debugger: off.} # the user does not want to trace a part {.push debugger: off.} # the user does not want to trace a part
# of the standard library! # of the standard library!
{.push checks: off, line_dir: off, stack_trace: off.} {.push checks: off, line_dir: off, stack_trace: off.}

View file

@ -108,6 +108,9 @@
import std/private/since import std/private/since
import std/exitprocs import std/exitprocs
when defined(nimPreviewSlimSystem):
import std/assertions
import macros, strutils, streams, times, sets, sequtils import macros, strutils, streams, times, sets, sequtils
when declared(stdout): when declared(stdout):

View file

@ -3,6 +3,9 @@
when not defined(js): when not defined(js):
{.fatal: "Module jsbigints is designed to be used with the JavaScript backend.".} {.fatal: "Module jsbigints is designed to be used with the JavaScript backend.".}
when defined(nimPreviewSlimSystem):
import std/assertions
type JsBigIntImpl {.importjs: "bigint".} = int # https://github.com/nim-lang/Nim/pull/16606 type JsBigIntImpl {.importjs: "bigint".} = int # https://github.com/nim-lang/Nim/pull/16606
type JsBigInt* = distinct JsBigIntImpl ## Arbitrary precision integer for JavaScript target. type JsBigInt* = distinct JsBigIntImpl ## Arbitrary precision integer for JavaScript target.

View file

@ -62,6 +62,9 @@ when not defined(js):
when defined(posix): when defined(posix):
import posix import posix
when defined(nimPreviewSlimSystem):
import std/assertions
const const
batchImplOS = defined(freebsd) or defined(openbsd) or defined(zephyr) or (defined(macosx) and not defined(ios)) batchImplOS = defined(freebsd) or defined(openbsd) or defined(zephyr) or (defined(macosx) and not defined(ios))
batchSize {.used.} = 256 batchSize {.used.} = 256

View file

@ -13,6 +13,9 @@
import std/[macros, isolation, typetraits] import std/[macros, isolation, typetraits]
import system/ansi_c import system/ansi_c
when defined(nimPreviewSlimSystem):
import std/assertions
export isolation export isolation

View file

@ -19,6 +19,8 @@ See also:
import os, random import os, random
when defined(nimPreviewSlimSystem):
import std/syncio
const const
maxRetry = 10000 maxRetry = 10000

View file

@ -8,6 +8,9 @@
# #
# The generic ``repr`` procedure for the javascript backend. # The generic ``repr`` procedure for the javascript backend.
when defined(nimPreviewSlimSystem):
import std/formatfloat
proc reprInt(x: int64): string {.compilerproc.} = $x proc reprInt(x: int64): string {.compilerproc.} = $x
proc reprFloat(x: float): string {.compilerproc.} = $x proc reprFloat(x: float): string {.compilerproc.} = $x

View file

@ -25,6 +25,9 @@
# #
from strutils import startsWith from strutils import startsWith
when defined(nimPreviewSlimSystem):
import std/syncio
when defined(nimHasStyleChecks): when defined(nimHasStyleChecks):
{.push styleChecks: off.} {.push styleChecks: off.}

View file

@ -13,6 +13,8 @@ import compiler/nimpaths
]# ]#
import os import os
when defined(nimPreviewSlimSystem):
import std/assertions
# Note: all the const paths defined here are known at compile time and valid # Note: all the const paths defined here are known at compile time and valid
# so long Nim repo isn't relocated after compilation. # so long Nim repo isn't relocated after compilation.

View file

@ -1,3 +1,6 @@
import std/assertions
proc mismatch*[T](lhs: T, rhs: T): string = proc mismatch*[T](lhs: T, rhs: T): string =
## Simplified version of `unittest.require` that satisfies a common use case, ## Simplified version of `unittest.require` that satisfies a common use case,
## while avoiding pulling too many dependencies. On failure, diagnostic ## while avoiding pulling too many dependencies. On failure, diagnostic

View file

@ -1,6 +1,8 @@
# test atomic operations # test atomic operations
import std/[atomics, bitops] import std/[atomics, bitops]
import std/assertions
type type
Object = object Object = object

View file

@ -2,6 +2,7 @@ discard """
targets: "c cpp" targets: "c cpp"
""" """
import std/atomics import std/atomics
import std/assertions
block testSize: # issue 12726 block testSize: # issue 12726
type type

View file

@ -1,2 +1,3 @@
switch("styleCheck", "usages") switch("styleCheck", "usages")
switch("styleCheck", "error") switch("styleCheck", "error")
switch("define", "nimPreviewSlimSystem")

View file

@ -1,4 +1,5 @@
import std/intsets import std/intsets
import std/assertions
proc test1*[]() = proc test1*[]() =
let a = initIntSet() let a = initIntSet()

View file

@ -5,6 +5,7 @@ discard """
""" """
import os import os
import std/assertions
# consider moving this inside tosproc (taking care that it's for cpp mode) # consider moving this inside tosproc (taking care that it's for cpp mode)

View file

@ -1,4 +1,5 @@
import heapqueue import std/heapqueue
import std/assertions
var test_queue : HeapQueue[int] var test_queue : HeapQueue[int]

View file

@ -1,4 +1,5 @@
import strutils import std/strutils
import std/assertions
type type
MyEnum = enum MyEnum = enum

View file

@ -6,6 +6,7 @@ discard """
#12928,10456 #12928,10456
import std/[sequtils, algorithm, json, sugar] import std/[sequtils, algorithm, json, sugar]
import std/assertions
proc test() = proc test() =
try: try:

View file

@ -1,7 +1,7 @@
discard """ discard """
targets: "c cpp js" targets: "c cpp js"
""" """
import std/assertions
# TODO: in future work move existing arithmetic tests (tests/arithm/*) into this file # TODO: in future work move existing arithmetic tests (tests/arithm/*) into this file
# FYI https://github.com/nim-lang/Nim/pull/17767 # FYI https://github.com/nim-lang/Nim/pull/17767

View file

@ -7,6 +7,7 @@ discard """
import strutils import strutils
from net import TimeoutError from net import TimeoutError
import std/assertions
import httpclient, asynchttpserver, asyncdispatch, asyncfutures import httpclient, asynchttpserver, asyncdispatch, asyncfutures

View file

@ -8,6 +8,7 @@ import net
import std/asyncnet import std/asyncnet
import std/nativesockets import std/nativesockets
import std/assertions
const postBegin = """ const postBegin = """
POST / HTTP/1.1 POST / HTTP/1.1

View file

@ -1,7 +1,7 @@
discard """ discard """
targets: "c js" targets: "c js"
""" """
import std/assertions
import std/base64 import std/base64
template main() = template main() =

View file

@ -5,6 +5,7 @@ OK
''' '''
""" """
import bitops import bitops
import std/assertions
proc main() = proc main() =
const U8 = 0b0011_0010'u8 const U8 = 0b0011_0010'u8

View file

@ -1,4 +1,5 @@
import std/private/bitops_utils import std/private/bitops_utils
import std/assertions
template chk(a, b) = template chk(a, b) =
let a2 = castToUnsigned(a) let a2 = castToUnsigned(a)

View file

@ -1,5 +1,6 @@
import std/unittest import std/unittest
import std/[cgi, strtabs, sugar] import std/[cgi, strtabs, sugar]
import std/assertions
block: # Test cgi module block: # Test cgi module
const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space" const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space"

View file

@ -4,6 +4,7 @@ discard """
""" """
import std/os import std/os
import std/assertions
var params = paramCount() var params = paramCount()
doAssert params == 0 doAssert params == 0

View file

@ -1,5 +1,5 @@
import std/[complex, math] import std/[complex, math]
import std/assertions
proc `=~`[T](x, y: Complex[T]): bool = proc `=~`[T](x, y: Complex[T]): bool =
result = abs(x.re-y.re) < 1e-6 and abs(x.im-y.im) < 1e-6 result = abs(x.re-y.re) < 1e-6 and abs(x.im-y.im) < 1e-6

View file

@ -4,6 +4,7 @@ discard """
import std/[cookies, times, strtabs] import std/[cookies, times, strtabs]
import std/assertions
let expire = fromUnix(0) + 1.seconds let expire = fromUnix(0) + 1.seconds

View file

@ -3,6 +3,7 @@ discard """
""" """
import std/[sequtils,critbits] import std/[sequtils,critbits]
import std/assertions
template main = template main =
var r: CritBitTree[void] var r: CritBitTree[void]

View file

@ -5,6 +5,7 @@ discard """
from std/sugar import collect from std/sugar import collect
from stdtest/testutils import whenRuntimeJs, whenVMorJs from stdtest/testutils import whenRuntimeJs, whenVMorJs
import std/assertions
template testMitems() = template testMitems() =
block: block:

View file

@ -3,7 +3,7 @@ discard """
""" """
import std/cstrutils import std/cstrutils
import std/assertions
proc main() = proc main() =
let s = cstring "abcdef" let s = cstring "abcdef"

View file

@ -1,4 +1,5 @@
import std/db_mysql import std/db_mysql
import std/assertions
doAssert dbQuote("SELECT * FROM foo WHERE col1 = 'bar_baz'") == "'SELECT * FROM foo WHERE col1 = \\'bar_baz\\''" doAssert dbQuote("SELECT * FROM foo WHERE col1 = 'bar_baz'") == "'SELECT * FROM foo WHERE col1 = \\'bar_baz\\''"
doAssert dbQuote("SELECT * FROM foo WHERE col1 LIKE '%bar_baz%'") == "'SELECT * FROM foo WHERE col1 LIKE \\'%bar_baz%\\''" doAssert dbQuote("SELECT * FROM foo WHERE col1 LIKE '%bar_baz%'") == "'SELECT * FROM foo WHERE col1 LIKE \\'%bar_baz%\\''"

View file

@ -1,7 +1,7 @@
discard """ discard """
targets: "c cpp js" targets: "c cpp js"
""" """
import std/assertions
import std/decls import std/decls
template fun() = template fun() =

View file

@ -1,5 +1,5 @@
import std/private/decode_helpers import std/private/decode_helpers
import std/assertions
block: block:
var i = 0 var i = 0

View file

@ -5,7 +5,7 @@ discard """
import std/deques import std/deques
from std/sequtils import toSeq from std/sequtils import toSeq
import std/assertions
block: block:
proc index(self: Deque[int], idx: Natural): int = proc index(self: Deque[int], idx: Natural): int =

View file

@ -4,6 +4,7 @@ discard """
import experimental/diff import experimental/diff
import std/strutils import std/strutils
import std/assertions
proc testHelper(f: seq[Item]): string = proc testHelper(f: seq[Item]): string =
for it in f: for it in f:

View file

@ -9,6 +9,7 @@ discard """
import ../../lib/packages/docutils/[rstast, rst, dochelpers] import ../../lib/packages/docutils/[rstast, rst, dochelpers]
import unittest import unittest
import std/assertions
proc testMsgHandler(filename: string, line, col: int, msgkind: MsgKind, proc testMsgHandler(filename: string, line, col: int, msgkind: MsgKind,
arg: string) = arg: string) =

View file

@ -1,4 +1,5 @@
import std/editdistance import std/editdistance
import std/assertions
doAssert editDistance("", "") == 0 doAssert editDistance("", "") == 0
doAssert editDistance("kitten", "sitting") == 3 # from Wikipedia doAssert editDistance("kitten", "sitting") == 3 # from Wikipedia

View file

@ -1,4 +1,5 @@
import std/encodings import std/encodings
import std/assertions
var fromGBK = open("utf-8", "gbk") var fromGBK = open("utf-8", "gbk")
var toGBK = open("gbk", "utf-8") var toGBK = open("gbk", "utf-8")

View file

@ -1,4 +1,5 @@
import std/enumerate import std/enumerate
import std/assertions
let a = @[1, 3, 5, 7] let a = @[1, 3, 5, 7]

View file

@ -4,6 +4,7 @@ discard """
import std/enumutils import std/enumutils
from std/sequtils import toSeq from std/sequtils import toSeq
import std/assertions
template main = template main =
block: # items block: # items

View file

@ -7,6 +7,7 @@ discard """
import std/envvars import std/envvars
from std/sequtils import toSeq from std/sequtils import toSeq
import stdtest/testutils import stdtest/testutils
import std/assertions
# "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386) # "LATIN CAPITAL LETTER AE" in UTF-8 (0xc386)
const unicodeUtf8 = "\xc3\x86" const unicodeUtf8 = "\xc3\x86"

View file

@ -7,6 +7,9 @@ discard """
import os, osproc, strutils, nativesockets, net, selectors, memfiles, import os, osproc, strutils, nativesockets, net, selectors, memfiles,
asyncdispatch, asyncnet asyncdispatch, asyncnet
import std/[assertions, syncio]
when defined(windows): when defined(windows):
import winlean import winlean
@ -56,7 +59,7 @@ proc isValidHandle(f: int): bool =
proc main() = proc main() =
if paramCount() == 0: if paramCount() == 0:
# Parent process # Parent process
let f = system.open("__test_fdleak", fmReadWrite) let f = syncio.open("__test_fdleak", fmReadWrite)
defer: close f defer: close f
leakCheck(f.getOsFileHandle, "system.open()") leakCheck(f.getOsFileHandle, "system.open()")

View file

@ -3,6 +3,7 @@ joinable: false
""" """
import os, osproc, strutils import os, osproc, strutils
import std/assertions
const Iterations = 200 const Iterations = 200

View file

@ -1,4 +1,5 @@
import std/fenv import std/fenv
import std/assertions
func is_significant(x: float): bool = func is_significant(x: float): bool =

View file

@ -3,6 +3,7 @@ discard """
""" """
import std/math import std/math
import std/assertions
const manualTest = false const manualTest = false

View file

@ -7,6 +7,7 @@ discard """
import std/genasts import std/genasts
import std/macros import std/macros
from std/strformat import `&` from std/strformat import `&`
import std/assertions
import ./mgenast import ./mgenast
proc main = proc main =

View file

@ -6,6 +6,7 @@ discard """
# bug: https://github.com/nim-lang/Nim/issues/10198 # bug: https://github.com/nim-lang/Nim/issues/10198
import nativesockets import nativesockets
import std/assertions
block DGRAM_UDP: block DGRAM_UDP:
let aiList = getAddrInfo("127.0.0.1", 999.Port, AF_INET, SOCK_DGRAM, IPPROTO_UDP) let aiList = getAddrInfo("127.0.0.1", 999.Port, AF_INET, SOCK_DGRAM, IPPROTO_UDP)

View file

@ -4,6 +4,7 @@ discard """
""" """
import os, strutils import os, strutils
import std/syncio
# Cases # Cases
# 1 - String : Existing File : Symlink true # 1 - String : Existing File : Symlink true
# 2 - String : Existing File : Symlink false # 2 - String : Existing File : Symlink false

View file

@ -1,4 +1,5 @@
import nativesockets import nativesockets
import std/assertions
doAssert getProtoByName("ipv6") == 41 doAssert getProtoByName("ipv6") == 41
doAssert getProtoByName("tcp") == 6 doAssert getProtoByName("tcp") == 6

View file

@ -1,4 +1,5 @@
import std/private/globs import std/private/globs
import std/assertions
template main = template main =
when defined(windows): when defined(windows):

View file

@ -4,6 +4,7 @@ discard """
import std/hashes import std/hashes
from stdtest/testutils import disableVm, whenVMorJs from stdtest/testutils import disableVm, whenVMorJs
import std/assertions
when not defined(js) and not defined(cpp): when not defined(js) and not defined(cpp):
block: block:

View file

@ -1,5 +1,5 @@
import std/heapqueue import std/heapqueue
import std/assertions
proc toSortedSeq[T](h: HeapQueue[T]): seq[T] = proc toSortedSeq[T](h: HeapQueue[T]): seq[T] =
var tmp = h var tmp = h

View file

@ -11,7 +11,7 @@ import htmlparser
import xmltree import xmltree
import strutils import strutils
from streams import newStringStream from streams import newStringStream
import std/assertions
block t2813: block t2813:
const const

View file

@ -14,6 +14,8 @@ from net import TimeoutError
import nativesockets, os, httpclient, asyncdispatch import nativesockets, os, httpclient, asyncdispatch
import std/[assertions, syncio]
const manualTests = false const manualTests = false
proc makeIPv6HttpServer(hostname: string, port: Port, proc makeIPv6HttpServer(hostname: string, port: Port,

View file

@ -15,7 +15,7 @@ discard """
when not defined(windows): when not defined(windows):
# Disabled on Windows due to old OpenSSL version # Disabled on Windows due to old OpenSSL version
import std/[formatfloat, syncio]
import import
httpclient, httpclient,
net, net,

View file

@ -4,6 +4,8 @@ discard """
import asynchttpserver, httpclient, asyncdispatch, strutils, net import asynchttpserver, httpclient, asyncdispatch, strutils, net
import std/assertions
block: # bug #16436 block: # bug #16436
proc startServer(): AsyncHttpServer = proc startServer(): AsyncHttpServer =
result = newAsyncHttpServer() result = newAsyncHttpServer()

View file

@ -1,4 +1,5 @@
import httpcore, strutils import httpcore, strutils
import std/assertions
block: block:
block HttpCode: block HttpCode:

View file

@ -2,6 +2,7 @@
import std/os import std/os
from stdtest/specialpaths import buildDir from stdtest/specialpaths import buildDir
import std/[assertions, syncio]
block: # readChars block: # readChars
let file = buildDir / "D20201118T205105.txt" let file = buildDir / "D20201118T205105.txt"

View file

@ -4,7 +4,7 @@ discard """
""" """
import std/[isolation, json] import std/[isolation, json]
import std/[assertions, objectdollar]
proc main(moveZeroesOut: static bool) = proc main(moveZeroesOut: static bool) =

View file

@ -2,7 +2,7 @@ discard """
targets: "js" targets: "js"
""" """
import std/jsbigints import std/[jsbigints, assertions]
let big1: JsBigInt = big"2147483647" let big1: JsBigInt = big"2147483647"

View file

@ -14,6 +14,7 @@ when not defined(js):
import std/streams import std/streams
import stdtest/testutils import stdtest/testutils
from std/fenv import epsilon from std/fenv import epsilon
import std/[assertions, objectdollar]
proc testRoundtrip[T](t: T, expected: string) = proc testRoundtrip[T](t: T, expected: string) =
# checks that `T => json => T2 => json2` is such that json2 = json # checks that `T => json => T2 => json2` is such that json2 = json

View file

@ -4,6 +4,7 @@ discard """
""" """
import json, strutils, options, tables import json, strutils, options, tables
import std/assertions
# The definition of the `%` proc needs to be here, since the `% c` calls below # The definition of the `%` proc needs to be here, since the `% c` calls below
# can only find our custom `%` proc for `Pix` if defined in global scope. # can only find our custom `%` proc for `Pix` if defined in global scope.

View file

@ -7,6 +7,7 @@ import std/json
from std/math import isNaN, signbit from std/math import isNaN, signbit
from std/fenv import epsilon from std/fenv import epsilon
from stdtest/testutils import whenRuntimeJs from stdtest/testutils import whenRuntimeJs
import std/[assertions, objectdollar]
proc testRoundtrip[T](t: T, expected: string) = proc testRoundtrip[T](t: T, expected: string) =
# checks that `T => json => T2 => json2` is such that json2 = json # checks that `T => json => T2 => json2` is such that json2 = json

View file

@ -3,6 +3,7 @@ discard """
""" """
import std/[lists, sequtils] import std/[lists, sequtils]
import std/assertions
const const
data = [1, 2, 3, 4, 5, 6] data = [1, 2, 3, 4, 5, 6]

View file

@ -5,6 +5,7 @@ discard """
#bug #6049 #bug #6049
import uselocks import uselocks
import std/assertions
var m = createMyType[int]() var m = createMyType[int]()
doAssert m.use() == 3 doAssert m.use() == 3

View file

@ -5,6 +5,7 @@ See also:
]# ]#
import std/macros import std/macros
import std/assertions
block: # hasArgOfName block: # hasArgOfName
macro m(u: untyped): untyped = macro m(u: untyped): untyped =

View file

@ -3,6 +3,7 @@ discard """
""" """
import std/marshal import std/marshal
import std/[assertions, objectdollar]
# TODO: add static tests # TODO: add static tests

View file

@ -7,6 +7,8 @@ discard """
# but it requires disabling certain lines with `when not defined(nimTmathCase2)` # but it requires disabling certain lines with `when not defined(nimTmathCase2)`
import std/math import std/math
import std/assertions
# Function for approximate comparison of floats # Function for approximate comparison of floats
proc `==~`(x, y: float): bool = abs(x - y) < 1e-9 proc `==~`(x, y: float): bool = abs(x - y) < 1e-9

View file

@ -3,6 +3,7 @@ discard """
""" """
import md5 import md5
import std/assertions
proc main() {.raises: [].} = proc main() {.raises: [].} =
doAssert(getMD5("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern") == doAssert(getMD5("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern") ==

Some files were not shown because too many files have changed in this diff Show more