Remove deprecated stuff from stdlib (#14699)

* update to the latest Jester

* remove deprecated procs from some stdlib modules

* 'criterion' is not maintained anymore and relies on obsolete stuff
This commit is contained in:
Miran 2020-06-17 15:25:02 +02:00 • committed by GitHub
commit e7f280bd26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 155 additions and 519 deletions

View file

@ -996,12 +996,6 @@ macro dumpAstGen*(s: untyped): untyped = echo s.astGenRepr
##
## Also see ``dumpTree`` and ``dumpLisp``.
macro dumpTreeImm*(s: untyped): untyped {.deprecated.} = echo s.treeRepr
## Deprecated. Use `dumpTree` instead.
macro dumpLispImm*(s: untyped): untyped {.deprecated.} = echo s.lispRepr
## Deprecated. Use `dumpLisp` instead.
proc newEmptyNode*(): NimNode {.compileTime, noSideEffect.} =
## Create a new empty node.
result = newNimNode(nnkEmpty)

View file

@ -483,13 +483,6 @@ proc multiReplace*(s: string, subs: openArray[
# copy the rest:
add(result, substr(s, i))
proc parallelReplace*(s: string, subs: openArray[
tuple[pattern: Regex, repl: string]]): string {.deprecated:
"Deprecated since v0.18.0: Use ``multiReplace`` instead.".} =
## Returns a modified copy of ``s`` with the substitutions in ``subs``
## applied in parallel.
result = multiReplace(s, subs)
proc transformFile*(infile, outfile: string,
subs: openArray[tuple[pattern: Regex, repl: string]]) =
## reads in the file ``infile``, performs a parallel replacement (calls

View file

@ -223,10 +223,6 @@ proc binarySearch*[T](a: openArray[T], key: T): int =
assert binarySearch([0, 1, 4, 2, 3], 4) == 2
binarySearch(a, key, cmp[T])
proc smartBinarySearch*[T](a: openArray[T], key: T): int {.deprecated:
"Deprecated since v0.18.1; Use 'binarySearch'".} =
binarySearch(a, key, cmp[T])
const
onlySafeCode = true

View file

@ -285,7 +285,7 @@ when defined(windows) or defined(nimdoc):
new result
result.ioPort = createIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 1)
result.handles = initHashSet[AsyncFD]()
result.timers.newHeapQueue()
result.timers.clear()
result.callbacks = initDeque[proc () {.closure, gcsafe.}](64)
var gDisp{.threadvar.}: owned PDispatcher ## Global dispatcher

View file

@ -183,14 +183,6 @@ proc `$`*[T](heap: HeapQueue[T]): string =
result.addQuoted(x)
result.add("]")
proc newHeapQueue*[T](): HeapQueue[T] {.deprecated:
"Deprecated since v0.20.0: use 'initHeapQueue' instead.".} =
initHeapQueue[T]()
proc newHeapQueue*[T](heap: var HeapQueue[T]) {.deprecated:
"Deprecated since v0.20.0: use 'clear' instead.".} =
heap.clear()
when isMainModule:
proc toSortedSeq[T](h: HeapQueue[T]): seq[T] =
var tmp = h

View file

@ -111,9 +111,7 @@ proc init*[A](s: var HashSet[A], initialSize = defaultInitialSize) =
## * `toHashSet proc <#toHashSet,openArray[A]>`_
runnableExamples:
var a: HashSet[int]
assert(not a.isValid)
init(a)
assert a.isValid
initImpl(s, initialSize)
@ -647,9 +645,7 @@ proc init*[A](s: var OrderedSet[A], initialSize = defaultInitialSize) =
## * `toOrderedSet proc <#toOrderedSet,openArray[A]>`_
runnableExamples:
var a: OrderedSet[int]
assert(not a.isValid)
init(a)
assert a.isValid
initImpl(s, initialSize)
@ -923,21 +919,6 @@ iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
proc isValid*[A](s: OrderedSet[A]): bool {.deprecated:
"Deprecated since v0.20; sets are initialized by default".} =
##
## Returns `true` if the set has been initialized (with `initHashSet proc
## <#initOrderedSet,int>`_ or `init proc <#init,OrderedSet[A],int>`_).
##
## **Examples:**
##
## .. code-block ::
## proc savePreferences(options: OrderedSet[string]) =
## assert options.isValid, "Pass an initialized set!"
## # Do stuff here, may crash in release builds!
result = s.data.len > 0
# -----------------------------------------------------------------------
@ -945,16 +926,8 @@ proc isValid*[A](s: OrderedSet[A]): bool {.deprecated:
when isMainModule and not defined(release):
proc testModule() =
## Internal micro test to validate docstrings and such.
block isValidTest: # isValid is deprecated
var options: HashSet[string]
proc savePreferences(options: HashSet[string]) =
assert options.isValid, "Pass an initialized set!"
options = initHashSet[string]()
options.savePreferences
block lenTest:
var values: HashSet[int]
assert(not values.isValid)
assert values.len == 0
assert values.card == 0
@ -1046,16 +1019,8 @@ when isMainModule and not defined(release):
var b = a.map(proc (x: int): string = $x)
assert b == toHashSet(["1", "2", "3"])
block isValidTest: # isValid is deprecated
var cards: OrderedSet[string]
proc saveTarotCards(cards: OrderedSet[string]) =
assert cards.isValid, "Pass an initialized set!"
cards = initOrderedSet[string]()
cards.saveTarotCards
block lenTest:
var values: OrderedSet[int]
assert(not values.isValid)
assert values.len == 0
assert values.card == 0
@ -1119,7 +1084,7 @@ when isMainModule and not defined(release):
a.init(4)
a.incl(2)
a.init
assert a.len == 0 and a.isValid
assert a.len == 0
a = initOrderedSet[int](4)
a.incl(2)
assert a.len == 1
@ -1128,7 +1093,7 @@ when isMainModule and not defined(release):
b.init(4)
b.incl(2)
b.init
assert b.len == 0 and b.isValid
assert b.len == 0
b = initHashSet[int](4)
b.incl(2)
assert b.len == 1

View file

@ -88,7 +88,7 @@ when not defined(testing) and isMainModule and not defined(nimdoc):
proc busyLoop() =
while true:
discard random(80)
discard rand(80)
os.sleep(100)
spawn busyLoop()

View file

@ -435,7 +435,7 @@ proc `[]=`*(p: MultipartData, name: string,
proc getBoundary(p: MultipartData): string =
if p == nil or p.content.len == 0: return
while true:
result = $random(int.high)
result = $rand(int.high)
for i, entry in p.content:
if result in entry.content: break
elif i == p.content.high: return

View file

@ -196,17 +196,6 @@ proc nextPowerOfTwo*(x: int): int {.noSideEffect.} =
result = result or (result shr 1)
result += 1 + ord(x <= 0)
proc countBits32*(n: int32): int {.noSideEffect, deprecated:
"Deprecated since v0.20.0; use 'bitops.countSetBits' instead".} =
runnableExamples:
doAssert countBits32(7) == 3
doAssert countBits32(8) == 1
doAssert countBits32(15) == 4
doAssert countBits32(16) == 1
doAssert countBits32(17) == 2
bitops.countSetBits(n)
proc sum*[T](x: openArray[T]): T {.noSideEffect.} =
## Computes the sum of the elements in ``x``.
##
@ -611,13 +600,6 @@ when not defined(js): # C
## echo gamma(4.0) # 6.0
## echo gamma(11.0) # 3628800.0
## echo gamma(-1.0) # nan
proc tgamma*(x: float32): float32
{.deprecated: "Deprecated since v0.19.0; use 'gamma' instead",
importc: "tgammaf", header: "<math.h>".}
proc tgamma*(x: float64): float64
{.deprecated: "Deprecated since v0.19.0; use 'gamma' instead",
importc: "tgamma", header: "<math.h>".}
## The gamma function
proc lgamma*(x: float32): float32 {.importc: "lgammaf", header: "<math.h>".}
proc lgamma*(x: float64): float64 {.importc: "lgamma", header: "<math.h>".}
## Computes the natural log of the gamma function for ``x``.
@ -750,12 +732,6 @@ when not defined(js): # C
## echo trunc(PI) # 3.0
## echo trunc(-1.85) # -1.0
proc fmod*(x, y: float32): float32 {.deprecated: "Deprecated since v0.19.0; use 'mod' instead",
importc: "fmodf", header: "<math.h>".}
proc fmod*(x, y: float64): float64 {.deprecated: "Deprecated since v0.19.0; use 'mod' instead",
importc: "fmod", header: "<math.h>".}
## Computes the remainder of ``x`` divided by ``y``.
proc `mod`*(x, y: float32): float32 {.importc: "fmodf", header: "<math.h>".}
proc `mod`*(x, y: float64): float64 {.importc: "fmod", header: "<math.h>".}
## Computes the modulo operation for float values (the remainder of ``x`` divided by ``y``).
@ -1111,7 +1087,6 @@ when isMainModule and not defined(js) and not windowsCC89:
# check gamma function
assert(gamma(5.0) == 24.0) # 4!
assert($tgamma(5.0) == $24.0) # 4!
assert(lgamma(1.0) == 0.0) # ln(1.0) == 0.0
assert(erf(6.0) > erf(5.0))
assert(erfc(6.0) < erfc(5.0))
@ -1133,20 +1108,6 @@ when isMainModule:
doAssert round(-54.652) ==~ -55.0
doAssert round(-54.352) ==~ -54.0
doAssert round(0.0) ==~ 0.0
# Round to positive decimal places
doAssert round(-547.652, 1) ==~ -547.7
doAssert round(547.652, 1) ==~ 547.7
doAssert round(-547.652, 2) ==~ -547.65
doAssert round(547.652, 2) ==~ 547.65
# Round to negative decimal places
doAssert round(547.652, -1) ==~ 550.0
doAssert round(547.652, -2) ==~ 500.0
doAssert round(547.652, -3) ==~ 1000.0
doAssert round(547.652, -4) ==~ 0.0
doAssert round(-547.652, -1) ==~ -550.0
doAssert round(-547.652, -2) ==~ -500.0
doAssert round(-547.652, -3) ==~ -1000.0
doAssert round(-547.652, -4) ==~ 0.0
block: # splitDecimal() tests
doAssert splitDecimal(54.674).intpart ==~ 54.0

View file

@ -233,22 +233,6 @@ proc createNativeSocket*(domain: Domain = AF_INET,
## by child processes.
createNativeSocket(toInt(domain), toInt(sockType), toInt(protocol), inheritable)
proc newNativeSocket*(domain: Domain = AF_INET,
sockType: SockType = SOCK_STREAM,
protocol: Protocol = IPPROTO_TCP): SocketHandle
{.deprecated: "deprecated since v0.18.0; use 'createNativeSocket' instead".} =
## Creates a new socket; returns `osInvalidSocket` if an error occurs.
createNativeSocket(domain, sockType, protocol)
proc newNativeSocket*(domain: cint, sockType: cint,
protocol: cint): SocketHandle
{.deprecated: "deprecated since v0.18.0; use 'createNativeSocket' instead".} =
## Creates a new socket; returns `osInvalidSocket` if an error occurs.
##
## Use this overload if one of the enums specified above does
## not contain what you need.
createNativeSocket(domain, sockType, protocol)
proc bindAddr*(socket: SocketHandle, name: ptr SockAddr,
namelen: SockLen): cint =
result = bindSocket(socket, name, namelen)

View file

@ -206,30 +206,6 @@ proc skipRandomNumbers*(s: var Rand) =
s.a0 = s0
s.a1 = s1
proc random*(max: int): int {.benign, deprecated:
"Deprecated since v0.18.0; use 'rand' instead".} =
while true:
let x = next(state)
if x < randMax - (randMax mod Ui(max)):
return int(x mod uint64(max))
proc random*(max: float): float {.benign, deprecated:
"Deprecated since v0.18.0; use 'rand' instead".} =
let x = next(state)
when defined(js):
result = (float(x) / float(high(uint32))) * max
else:
let u = (0x3FFu64 shl 52u64) or (x shr 12u64)
result = (cast[float](u) - 1.0) * max
proc random*[T](x: HSlice[T, T]): T {.deprecated:
"Deprecated since v0.18.0; use 'rand' instead".} =
result = T(random(x.b - x.a)) + x.a
proc random*[T](a: openArray[T]): T {.deprecated:
"Deprecated since v0.18.0; use 'sample' instead".} =
result = a[random(a.low..a.len)]
proc rand*(r: var Rand; max: Natural): int {.benign.} =
## Returns a random integer in the range `0..max` using the given state.
##
@ -362,10 +338,6 @@ proc rand*[T: Ordinal or SomeFloat](x: HSlice[T, T]): T =
doAssert rand(1..6) == 6
result = rand(state, x)
proc rand*[T](r: var Rand; a: openArray[T]): T {.deprecated:
"Deprecated since v0.20.0; use 'sample' instead".} =
result = a[rand(r, a.low..a.high)]
proc rand*[T: SomeInteger](t: typedesc[T]): T =
## Returns a random integer in the range `low(T)..high(T)`.
##
@ -395,10 +367,6 @@ proc rand*[T: SomeInteger](t: typedesc[T]): T =
else:
result = cast[T](state.next)
proc rand*[T](a: openArray[T]): T {.deprecated:
"Deprecated since v0.20.0; use 'sample' instead".} =
result = a[rand(a.low..a.high)]
proc sample*[T](r: var Rand; s: set[T]): T =
## Returns a random element from the set ``s`` using the given state.
##
@ -687,6 +655,6 @@ when isMainModule:
# don't use causes integer overflow
doAssert compiles(random[int](low(int) .. high(int)))
doAssert compiles(rand[int](low(int) .. high(int)))
main()

View file

@ -334,22 +334,3 @@ else:
include ioselects/ioselectors_select
else:
include ioselects/ioselectors_poll
proc register*[T](s: Selector[T], fd: int | SocketHandle,
events: set[Event], data: T) {.deprecated: "use registerHandle instead".} =
## **Deprecated since v0.18.0:** Use ``registerHandle`` instead.
s.registerHandle(fd, events, data)
proc setEvent*(ev: SelectEvent) {.deprecated: "use trigger instead".} =
## Trigger event ``ev``.
##
## **Deprecated since v0.18.0:** Use ``trigger`` instead.
ev.trigger()
proc update*[T](s: Selector[T], fd: int | SocketHandle,
events: set[Event]) {.deprecated: "use updateHandle instead".} =
## Update file/socket descriptor ``fd``, registered in selector
## ``s`` with new events set ``event``.
##
## **Deprecated since v0.18.0:** Use ``updateHandle`` instead.
s.updateHandle()

View file

@ -581,8 +581,8 @@ proc initDuration*(nanoseconds, microseconds, milliseconds,
## Create a new `Duration <#Duration>`_.
runnableExamples:
let dur = initDuration(seconds = 1, milliseconds = 1)
doAssert dur.milliseconds == 1
doAssert dur.seconds == 1
doAssert dur.inMilliseconds == 1001
doAssert dur.inSeconds == 1
let seconds = convert(Weeks, Seconds, weeks) +
convert(Days, Seconds, days) +
@ -1464,7 +1464,7 @@ type
s, ss
fff, ffffff, fffffffff
t, tt
y, yy, yyy, yyyy, yyyyy
yy, yyyy
YYYY
uuuu
UUUU
@ -1612,11 +1612,8 @@ proc stringToPattern(str: string): FormatPattern =
of "fffffffff": result = fffffffff
of "t": result = t
of "tt": result = tt
of "y": result = y
of "yy": result = yy
of "yyy": result = yyy
of "yyyy": result = yyyy
of "yyyyy": result = yyyyy
of "YYYY": result = YYYY
of "uuuu": result = uuuu
of "UUUU": result = UUUU
@ -1709,20 +1706,14 @@ proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string,
result.add if dt.hour >= 12: "P" else: "A"
of tt:
result.add if dt.hour >= 12: "PM" else: "AM"
of y: # Deprecated
result.add $(dt.yearOfEra mod 10)
of yy:
result.add (dt.yearOfEra mod 100).intToStr(2)
of yyy: # Deprecated
result.add (dt.yearOfEra mod 1000).intToStr(3)
of yyyy:
let year = dt.yearOfEra
if year < 10000:
result.add year.intToStr(4)
else:
result.add '+' & $year
of yyyyy: # Deprecated
result.add (dt.yearOfEra mod 100_000).intToStr(5)
of YYYY:
if dt.year < 1:
result.add $(abs(dt.year) + 1)
@ -1933,8 +1924,6 @@ proc parsePattern(input: string, pattern: FormatPattern, i: var int,
i.inc 2
else:
result = false
of y, yyy, yyyyy:
raiseAssert "Pattern is invalid for parsing: " & $pattern
of Lit: doAssert false, "Can't happen"
proc toDateTime(p: ParsedTime, zone: Timezone, f: TimeFormat,
@ -2631,167 +2620,11 @@ when not defined(js):
else:
result = toFloat(int(getClock())) / toFloat(clocksPerSec)
#
# Deprecations
#
proc countLeapYears*(yearSpan: int): int
{.deprecated.} =
## Returns the number of leap years spanned by a given number of years.
##
## **Note:** For leap years, start date is assumed to be 1 AD.
## counts the number of leap years up to January 1st of a given year.
## Keep in mind that if specified year is a leap year, the leap day
## has not happened before January 1st of that year.
# Deprecated since v0.20.0
(yearSpan - 1) div 4 - (yearSpan - 1) div 100 + (yearSpan - 1) div 400
proc countDays*(yearSpan: int): int
{.deprecated.} =
## Returns the number of days spanned by a given number of years.
# Deprecated since v0.20.0
(yearSpan - 1) * 365 + countLeapYears(yearSpan)
proc countYears*(daySpan: int): int
{.deprecated.} =
## Returns the number of years spanned by a given number of days.
# Deprecated since v0.20.0
((daySpan - countLeapYears(daySpan div 365)) div 365)
proc countYearsAndDays*(daySpan: int): tuple[years: int, days: int]
{.deprecated.} =
## Returns the number of years spanned by a given number of days and the
## remainder as days.
# Deprecated since v0.20.0
let days = daySpan - countLeapYears(daySpan div 365)
result.years = days div 365
result.days = days mod 365
proc toTimeInterval*(time: Time): TimeInterval
{.deprecated: "Use 'between' instead".} =
## Converts a Time to a TimeInterval. To be used when diffing times.
# Deprecated since version 0.20.0
runnableExamples:
let a = fromUnix(10)
let b = fromUnix(1_500_000_000)
let ti = b.toTimeInterval() - a.toTimeInterval()
doAssert a + ti == b
var dt = time.local
initTimeInterval(dt.nanosecond, 0, 0, dt.second, dt.minute, dt.hour,
dt.monthday, 0, dt.month.ord - 1, dt.year)
proc weeks*(dur: Duration): int64
{.inline, deprecated: "Use 'inWeeks' instead".} =
## Number of whole weeks represented by the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(weeks = 1, days = 2, hours = 3, minutes = 4)
doAssert dur.weeks == 1
dur.inWeeks
proc days*(dur: Duration): int64
{.inline, deprecated: "Use 'inDays' instead".} =
## Number of whole days represented by the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(weeks = 1, days = 2, hours = 3, minutes = 4)
doAssert dur.days == 9
dur.inDays
proc hours*(dur: Duration): int64
{.inline, deprecated: "Use 'inHours' instead".} =
## Number of whole hours represented by the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(days = 1, hours = 2, minutes = 3)
doAssert dur.hours == 26
dur.inHours
proc minutes*(dur: Duration): int64
{.inline, deprecated: "Use 'inMinutes' instead".} =
## Number of whole minutes represented by the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(days = 1, hours = 2, minutes = 3)
doAssert dur.minutes == 1563
dur.inMinutes
proc seconds*(dur: Duration): int64
{.inline, deprecated: "Use 'inSeconds' instead".} =
## Number of whole seconds represented by the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(minutes = 10, seconds = 30)
doAssert dur.seconds == 630
dur.inSeconds
proc milliseconds*(dur: Duration): int {.inline, deprecated.} =
## Number of whole milliseconds represented by the **fractional**
## part of the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7,
microseconds = 8, nanoseconds = 9)
doAssert dur.milliseconds == 7
result = convert(Nanoseconds, Milliseconds, dur.nanosecond)
proc microseconds*(dur: Duration): int {.inline, deprecated.} =
## Number of whole microseconds represented by the **fractional**
## part of the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7,
microseconds = 8, nanoseconds = 9)
doAssert dur.microseconds == 7008
result = convert(Nanoseconds, Microseconds, dur.nanosecond)
proc nanoseconds*(dur: Duration): NanosecondRange {.inline, deprecated.} =
## Number of whole microseconds represented by the **fractional**
## part of the duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7,
microseconds = 8, nanoseconds = 9)
doAssert dur.nanoseconds == 7008009
dur.nanosecond
proc fractional*(dur: Duration): Duration {.inline, deprecated.} =
## The fractional part of `dur`, as a duration.
# Deprecated since version v0.20.0
runnableExamples:
let dur = initDuration(minutes = 5, seconds = 6, milliseconds = 7,
microseconds = 8, nanoseconds = 9)
doAssert dur.fractional == initDuration(milliseconds = 7, microseconds = 8,
nanoseconds = 9)
initDuration(nanoseconds = dur.nanosecond)
proc fromSeconds*(since1970: float): Time
{.tags: [], raises: [], benign, deprecated: "Use `fromUnixFloat or 'fromUnix' instead".} =
## Takes a float which contains the number of seconds since the unix epoch and
## returns a time object.
# Deprecated since v0.18.0
fromUnixFloat(since1970)
proc fromSeconds*(since1970: int64): Time
{.tags: [], raises: [], benign, deprecated: "Use 'fromUnix' instead".} =
## Takes an int which contains the number of seconds since the unix epoch and
## returns a time object.
# Deprecated since v0.18.0
fromUnix(since1970)
proc toSeconds*(time: Time): float
{.tags: [], raises: [], benign, deprecated: "Use 'toUnixFloat' or 'toUnix' instead".} =
## Returns the time in seconds since the unix epoch, with subsecond resolution.
# Deprecated since v0.18.0
toUnixFloat(time)
proc getGMTime*(time: Time): DateTime
{.tags: [], raises: [], benign, deprecated: "Use 'utc' instead".} =
## Converts the calendar time `time` to broken-down time representation,
## expressed in Coordinated Universal Time (UTC).
# Deprecated since v0.18.0
time.utc
proc `nanosecond=`*(dt: var DateTime, value: NanosecondRange) {.deprecated: "Deprecated since v1.3.1".} =
dt.nanosecond = value

View file

@ -1169,88 +1169,6 @@ proc alignLeft*(s: string, count: Natural, padding = ' '.Rune): string {.
else:
result = s
# -----------------------------------------------------------------------------
# deprecated
template runeCaseCheck(s, runeProc, skipNonAlpha) =
## Common code for rune.isLower and rune.isUpper.
if len(s) == 0: return false
var
i = 0
rune: Rune
hasAtleastOneAlphaRune = false
while i < len(s):
fastRuneAt(s, i, rune, doInc = true)
if skipNonAlpha:
var runeIsAlpha = isAlpha(rune)
if not hasAtleastOneAlphaRune:
hasAtleastOneAlphaRune = runeIsAlpha
if runeIsAlpha and (not runeProc(rune)):
return false
else:
if not runeProc(rune):
return false
return if skipNonAlpha: hasAtleastOneAlphaRune else: true
proc isLower*(s: string, skipNonAlpha: bool): bool {.
deprecated: "Deprecated since version 0.20 since its semantics are unclear".} =
## **Deprecated since version 0.20 since its semantics are unclear**
##
## Checks whether ``s`` is lower case.
##
## If ``skipNonAlpha`` is true, returns true if all alphabetical
## runes in ``s`` are lower case. Returns false if none of the
## runes in ``s`` are alphabetical.
##
## If ``skipNonAlpha`` is false, returns true only if all runes in
## ``s`` are alphabetical and lower case.
##
## For either value of ``skipNonAlpha``, returns false if ``s`` is
## an empty string.
runeCaseCheck(s, isLower, skipNonAlpha)
proc isUpper*(s: string, skipNonAlpha: bool): bool {.
deprecated: "Deprecated since version 0.20 since its semantics are unclear".} =
## **Deprecated since version 0.20 since its semantics are unclear**
##
## Checks whether ``s`` is upper case.
##
## If ``skipNonAlpha`` is true, returns true if all alphabetical
## runes in ``s`` are upper case. Returns false if none of the
## runes in ``s`` are alphabetical.
##
## If ``skipNonAlpha`` is false, returns true only if all runes in
## ``s`` are alphabetical and upper case.
##
## For either value of ``skipNonAlpha``, returns false if ``s`` is
## an empty string.
runeCaseCheck(s, isUpper, skipNonAlpha)
proc isTitle*(s: string): bool {.noSideEffect, rtl, extern: "nuc$1Str",
deprecated: "Deprecated since version 0.20 since its semantics are unclear".} =
## **Deprecated since version 0.20 since its semantics are unclear**
##
## Checks whether or not ``s`` is a unicode title.
##
## Returns true if the first character in each word inside ``s``
## are upper case and there is at least one character in ``s``.
if s.len == 0:
return false
result = true
var
i = 0
rune: Rune
var firstRune = true
while i < len(s) and result:
fastRuneAt(s, i, rune, doInc = true)
if not rune.isWhiteSpace() and firstRune:
result = rune.isUpper() and result
firstRune = false
elif rune.isWhiteSpace():
firstRune = true
when isMainModule:

View file

@ -416,8 +416,7 @@ proc ensureInitialized() =
if formatters.len == 0:
formatters = @[OutputFormatter(defaultConsoleFormatter())]
if not disabledParamFiltering and not testsFilters.isValid:
testsFilters.init()
if not disabledParamFiltering:
when declared(paramCount):
# Read tests to run from the command line.
for i in 1 .. paramCount():
@ -712,7 +711,7 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped =
## import math, random
## proc defectiveRobot() =
## randomize()
## case random(1..4)
## case rand(1..4)
## of 1: raise newException(OSError, "CANNOT COMPUTE!")
## of 2: discard parseInt("Hello World!")
## of 3: raise newException(IOError, "I can't do that Dave.")

View file

@ -481,18 +481,10 @@ proc `+=`*[T: SomeInteger](x: var T, y: T) {.
magic: "Inc", noSideEffect.}
## Increments an integer.
proc `+=`*[T: enum|bool](x: var T, y: T) {.
magic: "Inc", noSideEffect, deprecated: "use `inc` instead".}
## **Deprecated since v0.20**: use `inc` instead.
proc `-=`*[T: SomeInteger](x: var T, y: T) {.
magic: "Dec", noSideEffect.}
## Decrements an integer.
proc `-=`*[T: enum|bool](x: var T, y: T) {.
magic: "Dec", noSideEffect, deprecated: "0.20.0, use `dec` instead".}
## **Deprecated since v0.20**: use `dec` instead.
proc `*=`*[T: SomeInteger](x: var T, y: T) {.
inline, noSideEffect.} =
## Binary `*=` operator for integers.