mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-28 10:13:56 +00:00
* fixes #14054
* make tests green again
* more tests are green
* maybe now
(cherry picked from commit cc60caedb3)
This commit is contained in:
45
changelog.md
45
changelog.md
@@ -4,6 +4,51 @@
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
For `net` and `nativesockets`, an `inheritable` flag has been added to all
|
||||
`proc`s that create sockets, allowing the user to control whether the
|
||||
resulting socket is inheritable. This flag is provided to ease the writing of
|
||||
multi-process servers, where sockets inheritance is desired.
|
||||
|
||||
For a transistion period, define `nimInheritHandles` to enable file handle
|
||||
inheritance by default. This flag does **not** affect the `selectors` module
|
||||
due to the differing semantics between operating systems.
|
||||
|
||||
`system.setInheritable` and `nativesockets.setInheritable` is also introduced
|
||||
for setting file handle or socket inheritance. Not all platform have these
|
||||
`proc`s defined.
|
||||
|
||||
- The file descriptors created for internal bookkeeping by `ioselector_kqueue`
|
||||
and `ioselector_epoll` will no longer be leaked to child processes.
|
||||
|
||||
- `strutils.formatFloat` with `precision = 0` has been restored to the version
|
||||
1 behaviour that produces a trailing dot, e.g. `formatFloat(3.14159, precision = 0)`
|
||||
is now `3.`, not `3`.
|
||||
- `critbits` adds `commonPrefixLen`.
|
||||
|
||||
- `relativePath(rel, abs)` and `relativePath(abs, rel)` used to silently give wrong results
|
||||
(see #13222); instead they now use `getCurrentDir` to resolve those cases,
|
||||
and this can now throw in edge cases where `getCurrentDir` throws.
|
||||
`relativePath` also now works for js with `-d:nodejs`.
|
||||
|
||||
- JavaScript and NimScript standard library changes: `streams.StringStream` is
|
||||
now supported in JavaScript, with the limitation that any buffer `pointer`s
|
||||
used must be castable to `ptr string`, any incompatible pointer type will not
|
||||
work. The `lexbase` and `streams` modules used to fail to compile on
|
||||
NimScript due to a bug, but this has been fixed.
|
||||
|
||||
The following modules now compile on both JS and NimScript: `parsecsv`,
|
||||
`parsecfg`, `parsesql`, `xmlparser`, `htmlparser` and `ropes`. Additionally
|
||||
supported for JS is `cstrutils.startsWith` and `cstrutils.endsWith`, for
|
||||
NimScript: `json`, `parsejson`, `strtabs` and `unidecode`.
|
||||
|
||||
- Added `streams.readStr` and `streams.peekStr` overloads to
|
||||
accept an existing string to modify, which avoids memory
|
||||
allocations, similar to `streams.readLine` (#13857).
|
||||
|
||||
- Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom`. UDP functionality.
|
||||
|
||||
- `paramCount` & `paramStr` are now defined in os.nim instead of nimscript.nim for nimscript/nimble.
|
||||
- `dollars.$` now works for unsigned ints with `nim js`
|
||||
|
||||
## Language changes
|
||||
|
||||
|
||||
@@ -692,11 +692,11 @@ when isMainModule:
|
||||
check &"{-123.456:.3f}", "-123.456"
|
||||
check &"{123.456:1g}", "123.456"
|
||||
check &"{123.456:.1f}", "123.5"
|
||||
check &"{123.456:.0f}", "123"
|
||||
check &"{123.456:.0f}", "123."
|
||||
check &"{123.456:>9.3f}", " 123.456"
|
||||
check &"{123.456:9.3f}", " 123.456"
|
||||
check &"{123.456:>9.4f}", " 123.4560"
|
||||
check &"{123.456:>9.0f}", " 123"
|
||||
check &"{123.456:>9.0f}", " 123."
|
||||
check &"{123.456:<9.4f}", "123.4560 "
|
||||
|
||||
# Float (scientific) tests
|
||||
|
||||
@@ -2357,10 +2357,6 @@ proc formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault,
|
||||
# but nothing else is possible:
|
||||
if buf[i] in {'.', ','}: result[i] = decimalSep
|
||||
else: result[i] = buf[i]
|
||||
since (1, 1):
|
||||
# remove trailing dot, compatible with Python's formatter and JS backend
|
||||
if result[^1] == decimalSep:
|
||||
result.setLen(len(result)-1)
|
||||
when defined(windows):
|
||||
# VS pre 2015 violates the C standard: "The exponent always contains at
|
||||
# least two digits, and only as many more digits as necessary to
|
||||
@@ -2863,7 +2859,8 @@ proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl,
|
||||
when isMainModule:
|
||||
proc nonStaticTests =
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235" # bugs 8242, 12586
|
||||
when not defined(js):
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # bugs 8242, 12586
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
|
||||
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
||||
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in
|
||||
|
||||
@@ -37,7 +37,7 @@ bug12899()
|
||||
|
||||
proc nonStaticTests =
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000"
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235" # bugs 8242, 12586
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # bugs 8242, 12586
|
||||
doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6"
|
||||
doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001"
|
||||
doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in
|
||||
|
||||
@@ -173,3 +173,34 @@ block:
|
||||
y = 234
|
||||
z = true
|
||||
"""
|
||||
|
||||
|
||||
# tests from the very own strformat documentation!
|
||||
|
||||
let msg = "hello"
|
||||
doAssert fmt"{msg}\n" == "hello\\n"
|
||||
|
||||
doAssert &"{msg}\n" == "hello\n"
|
||||
|
||||
doAssert fmt"{msg}{'\n'}" == "hello\n"
|
||||
doAssert fmt("{msg}\n") == "hello\n"
|
||||
doAssert "{msg}\n".fmt == "hello\n"
|
||||
|
||||
doAssert &"""{"abc":>4}""" == " abc"
|
||||
doAssert &"""{"abc":<4}""" == "abc "
|
||||
|
||||
doAssert fmt"{-12345:08}" == "-0012345"
|
||||
doAssert fmt"{-1:3}" == " -1"
|
||||
doAssert fmt"{-1:03}" == "-01"
|
||||
doAssert fmt"{16:#X}" == "0x10"
|
||||
|
||||
doAssert fmt"{123.456}" == "123.456"
|
||||
doAssert fmt"{123.456:>9.3f}" == " 123.456"
|
||||
doAssert fmt"{123.456:9.3f}" == " 123.456"
|
||||
doAssert fmt"{123.456:9.4f}" == " 123.4560"
|
||||
doAssert fmt"{123.456:>9.0f}" == " 123."
|
||||
doAssert fmt"{123.456:<9.4f}" == "123.4560 "
|
||||
|
||||
doAssert fmt"{123.456:e}" == "1.234560e+02"
|
||||
doAssert fmt"{123.456:>13e}" == " 1.234560e+02"
|
||||
doAssert fmt"{123.456:13e}" == " 1.234560e+02"
|
||||
|
||||
Reference in New Issue
Block a user