summary refs log tree commit diff stats
path: root/tests/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* Fix RST/Markdown false heading detection (#21685)Andrey Makarov2023-04-182-1/+40
|
* custom pragmas: correct error condition, remove outdated symkind whitelist ↵metagn2023-04-131-4/+3
| | | | | | | | | | | | | | | (#21653) * test not restricting custom pragma applied symbols fixes #21652 * fix other test * different patch * fix tests * actually test #18212 and other routines
* fixes #21632; enforce deref for `wasMoved` in ORC (#21647)ringabout2023-04-121-1/+10
| | | fixes #21632; enforce deref for `wasMoved`
* int64/uint64 as bigint in JS (#21613)metagn2023-04-116-28/+26
| | | | | | | | | | | * int64/uint64 as bigint in JS * fix CI * convert to compile option * fix lie * smaller diff, changelog entry
* Fix option lists with additional indentation in Markdown (#21633)Andrey Makarov2023-04-111-0/+26
| | | | | | | | This is more Markdown-ish way to fix issue #21055, then PR #21625. It does not enable RST definition lists, instead it makes adding additional indentation (less than 4) right after a paragraph be ignored, as it's done for all block elements in Markdown. (In this case this tenet is applied to option lists that are not part of CommonMark spec by themselves).
* fixes #21638; `fromJson` should support empty objects (#21641)ringabout2023-04-111-0/+5
| | | | | * fixes #21638; `fromJson` should supports empty objects * complete the logic
* fixes #21564; std/bitops: Add explicit type masking for the JS target (#21598)chmod2222023-04-031-0/+28
| | | | | | | | | | | | | | | | | | | * std/bitops: Add explicit type masking for the JS target Typecasts on the JavaScript backend do not function the same way as they do on C and C++ backends, so for bitwise operations we may need to mask them back down into their allowed range when they get shifted outside it. Since they do work as expected on the other backends, a default bitmask of all 1's is casted down into the target type as an easily optimizable "& 0xFF" operation for these backends. * Fixup: this should still be a func * Run test case on js target * Adapt testcase to contributor guide and best practices * Simplify constrain logic and turn into actual no-op for the C side
* disable google request in thttpclient (#21572)metagn2023-03-281-4/+6
| | | was breaking macos CI
* fixes #21538; expand len template parameter once in newSeqWith (#21543)Eric N. Vander Weele2023-03-201-0/+5
| | | | | | | `len` could contain side effects and may result in different values when substituted twice in the template expansion. Instead, capture the result of substituting `len` once. closes: #21538
* Fix: #21541. Add support for xnVerbatimText (#21542)Mark Leyva2023-03-201-0/+15
| | | | to text and text= procs. Remove unnecessary LF for xnVerbatimText in $ proc.
* fixes quoted variables with typedesc types (#21493)ringabout2023-03-091-0/+8
|
* closes #20704; add a test case (#21480)ringabout2023-03-061-1/+12
|
* fixes #21326; fixes #7375; fixes #11986; fixes #9607; rework quote do; ↵ringabout2023-03-021-0/+136
| | | | | | | | | | | | | `getAst` uses type info to annotate the type of quoted variables; no more type erasures for quoted variables (#21433) * fixes #21326; getAst uses type info to annotateType quoted variables * simplify logics; sem types first * fixes important packages * add testcases * tiny
* Make `Time` work with `std/strformat` (#21409)Jake Leahy2023-02-211-0/+5
| | | | | | | * Add test case * Remove formatValue template for `Time` It didn't handle empty specifier correctly which caused it to be blank with strformat
* Fix `closeHandle` bug, add `setFileSize`, make `resize` work on Windows (#21375)c-blake2023-02-151-2/+3
| | | | | | | | | | | | | | * Add general purpose `setFileSize` (unexported for now). Use to simplify `memfiles.open` as well as make robust (via hard allocation, not merely `ftruncate` address space allocation) on systems with `posix_fallocate`. As part of this, fix a bad `closeHandle` return check bug on Windows and add `MemFile.resize` for Windows now that setFileSize makes that easier. * Adapt existing test to exercise newly portable `MemFile.resize`. * Since Apple has never provided `posix_fallocate`, provide a fallback. This is presently written in terms of `ftruncate`, but it can be improved to use `F_PREALLOCATE` instead, as mentioned in a comment.
* This adds `parseutils.parseSize`, an inverse to `strutils.formatSize` (#21349)c-blake2023-02-141-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * This adds `parseutils.parseSize`, an inverse to `strutils.formatSize` which has existed since 2017. It is useful for parsing the compiler's own output logs (like SuccessX) or many other scenarios where "human readable" units have been chosen. The doc comment and tests explain accepted syntax in detail. Big units lead to small numbers, often with a fractional part, but we parse into an `int64` since that is what `formatSize` stringifies and this is an inverse over partial function slots. Although metric prefixes z & y for zettabyte & yottabyte are accepted, these will saturate the result at `int64.high` unless the qualified number is a small fraction. This should not be much of a problem until such sizes are common (at which point another overload with the parse result either `float64` or `int128` could be added). Tests avoids `test()` because of a weakly related static: test() failure as mentioned in https://github.com/nim-lang/Nim/pull/21325. This is a more elemental VM failure. As such, it needs its own failure exhibition issue that is a smaller test case. (I am working on that, but unless there is a burning need to `parseSize` at compile-time before run-time it need not hold up this PR.) * This worked with `int` but fails with `int64`. Try for green tests. * Lift 2-result matching into a `checkParseSize` template and format as a table of input & 2 expected outputs which seems nicer and to address https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294407679 * Fix (probably) the i386 trouble by using `int64` consistently. * Improve documentation by mentioning saturation. * Improve documentation with `runnableExamples` and a little more detail in the main doc comment based on excellent code review by @juancarlospaco: https://github.com/nim-lang/Nim/pull/21349#pullrequestreview-1294564155 * Address some more @juancarlospaco code review concerns. * Remove a stray space. * Mention milli-bytes in docs to maybe help clarify why wild conventions are so prone to going case-insensitive-metric. * Add some parens.
* fixes #18134; registers `formatBiggestFloat` in VM (#21299)ringabout2023-01-261-8/+11
| | | | | fixes #18134; registers formatBiggestFloat in vmops strformat supports float format in VM
* fixes #21273; fixes an io.readLine off by one bug [backport 1.0] (#21276)ringabout2023-01-251-0/+18
| | | fixes #21273; io.readLine off by one
* fixes #21290; deindent if the last same level is a text node (#21293)ringabout2023-01-241-1/+17
| | | | | * fixes #21290; deindent if the last same level is a text node * add one more test
* fixes #21278; `deques.shrink` off by one bug (#21284)ringabout2023-01-201-0/+6
| | | fixes #21278; deques.shrink off ny one bug
* Fix getting custom pragma from generic object (#20481)Jake Leahy2023-01-111-0/+18
| | | | | | | | | | | * Merge devel Add another test case * Fix test Use getCustomPragmaVal instead of hasCustomPragma Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* fixes #21232; highlite.getNextToken() returns gtOperator for '/' in C (#21234)ringabout2023-01-081-0/+10
|
* docgen: implement cross-document links (#20990)Andrey Makarov2023-01-042-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * docgen: implement cross-document links Fully implements https://github.com/nim-lang/RFCs/issues/125 Follow-up of: https://github.com/nim-lang/Nim/pull/18642 (for internal links) and https://github.com/nim-lang/Nim/issues/20127. Overview -------- Explicit import-like directive is required, called `.. importdoc::`. (the syntax is % RST, Markdown will use it for a while). Then one can reference any symbols/headings/anchors, as if they were in the local file (but they will be prefixed with a module name or markup document in link text). It's possible to reference anything from anywhere (any direction in `.nim`/`.md`/`.rst` files). See `doc/docgen.md` for full description. Working is based on `.idx` files, hence one needs to generate all `.idx` beforehand. A dedicated option `--index:only` is introduced (and a separate stage for `--index:only` is added to `kochdocs.nim`). Performance note ---------------- Full run for `./koch docs` now takes 185% of the time before this PR. (After: 315 s, before: 170 s on my PC). All the time seems to be spent on `--index:only` run, which takes almost as much (85%) of normal doc run -- it seems that most time is spent on file parsing, turning off HTML generation phase has not helped much. (One could avoid it by specifying list of files that can be referenced and pre-processing only them. But it can become error-prone and I assume that these linke will be **everywhere** in the repository anyway, especially considering https://github.com/nim-lang/RFCs/issues/478. So every `.nim`/`.md` file is processed for `.idx` first). But that's all without significant part of repository converted to cross-module auto links. To estimate impact I checked the time for `doc`ing a few files (after all indexes have been generated), and everywhere difference was **negligible**. E.g. for `lib/std/private/osfiles.nim` that `importdoc`s large `os.idx` and hence should have been a case with relatively large performance impact, but: * After: 0.59 s. * Before: 0.59 s. So Nim compiler works so slow that doc part basically does not matter :-) Testing ------- 1) added `extlinks` test to `nimdoc/` 2) checked that `theindex.html` is still correct 2) fixed broken auto-links for modules that were derived from `os.nim` by adding appropriate ``importdoc`` Implementation note ------------------- Parsing and formating of `.idx` entries is moved into a dedicated `rstidx.nim` module from `rstgen.nim`. `.idx` file format changed: * fields are not escaped in most cases because we need original strings for referencing, not HTML ones (the exception is linkTitle for titles and headings). Escaping happens later -- on the stage of `rstgen` buildIndex, etc. * all lines have fixed number of columns 6 * added discriminator tag as a first column, it always allows distinguish Nim/markup entries, titles/headings, etc. `rstgen` does not rely any more (in most cases) on ad-hoc logic to determine what type each entry is. * there is now always a title entry added at the first line. * add a line number as 6th column * linkTitle (4th) column has a different format: before it was like `module: funcName()`, now it's `proc funcName()`. (This format is also propagated to `theindex.html` and search results, I kept it that way since I like it more though it's discussible.) This column is what used for Nim symbols resolution. * also changed details on column format for headings and titles: "keyword" is original, "linkTitle" is HTML one * fix paths on Windows + more clear code * Update compiler/docgen.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> * Handle .md and .nim paths uniformly in findRefFile * handle titles better + more comments * don't allow markup overwrite index title for .nim files Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* build the documentation of official packages (#20986)ringabout2022-12-064-315/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * remove db stuffs * remove punycode * remove * fixes script * add cloner * patches * disable * patch * fixes external packages * disable two packages * preview documentation build * try again * fixes URL * fixes a bug * simplify * fixes documentaion * fixes * Apply suggestions from code review
* [unittest] remove unnecessay export for testing (#20868)ringabout2022-12-011-0/+1
|
* Update tssl.nim (#20973)Chavdar Ivanov2022-11-301-0/+1
| | | This test hangs also under NetBSD and prevents the rest of the tests to carry over to the end.
* Allow some tests to run without network (#20955)Anna2022-11-292-3/+8
| | | | | * thttpclient.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING * tnetconnect.nim: respect NIM_TESTAMENT_REMOTE_NETWORKING
* fix #13790; ptr char (+friends) should not implicitly convert to cstring ↵ringabout2022-11-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#20761) * fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* render post expr blocks better (#20871)metagn2022-11-221-0/+51
| | | | | | | * render post expr blocks * remove pointless diff * fix PR split mistake
* fixes #20026; marks system procs which can raise defects (#20864)ringabout2022-11-221-1/+0
| | | | | | | | | * marks system procs which can raise defects * add tests * add more systemRaisesDefect * add comment
* rename `std/threads` to `std/typedthreads` (#20850)ringabout2022-11-164-4/+4
| | | | | | | | | * rename `std/threads` to `std/oldthreads` * fixes tests * rename to `typedthreads` * changelog
* fixes ptr to cstring warnings[backport] (#20848)ringabout2022-11-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix =#13790 ptr char (+friends) should not implicitly convert to cstring * Apply suggestions from code review * first round; compiles on windows * nimPreviewSlimSystem * conversion is unsafe, cast needed * fixes more tests * fixes asyncnet * another try another error * last one * true * one more * why bugs didn't show at once * add `nimPreviewCstringConversion` switch * typo * fixes ptr to cstring warnings[backport] * add fixes Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* fixes tests and add notes (#20830)ringabout2022-11-131-1/+4
|
* fixes tests for quit (#20813)ringabout2022-11-111-1/+1
| | | Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
* [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk (#20680)Vindaar2022-11-101-0/+60
| | | | | | | | | | | | * [sugar] handle HiddenDeref in capture, error at CT if unsupported nnk Instead of running into trouble of the `.strVal` access failing, it's better to error at CT. * [tests] remove unnecessary import in test case * improve ident extraction & extend test cases * [tests] improve tests for `capture` of different types & act. check
* remove compiler/strutils2.nim (#20748)Bung2022-11-051-39/+0
| | | | | | | | | * use std strutils toLowerAscii char * avoid additional call and assign * remove compiler/strutils2.nim * canonical
* fix posix.mq_receive compilation with cpp backend (#20710)n5m2022-11-051-1/+44
| | | | | | | | | | | | | | | | | * fix posix.mq_receive compilation with cpp backend * only enable runnableExample on posix * linux, not posix * simplify example * add test * mqueue.h does not exist on MacOS * place test case in own block * drop runnableExamples
* allow deferred close of nil stream (#20706)n5m2022-10-311-0/+6
| | | | | * allow deferred close of nil stream * improve example
* put std/threads under the umbrella of nimPreviewSlimSystem (#20711)ringabout2022-10-314-4/+11
| | | | | | | | | | | * put `std/threads` under the umbrella of `nimPreviewSlimSystem` * add changelog * fixes tests * fixes tests again * fixes tests
* Fix #20628 for Windows (#20667)Andrey Makarov2022-10-282-11/+11
| | | | | | | * Fix #20628 for Windows * Move isRegular - !isSpecial and onlyRegular - skipSpecial * Forgot to change it in 1 more place
* Implement Unix file regularity check (#20448) (#20628)Andrey Makarov2022-10-252-3/+45
| | | | | * Implement Unix file regularity check * update std/dirs also
* Added 'openArray[char]' overloads to 'std/parseutils' (#20527)Jason Beetham2022-10-241-50/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Added 'openarray[char]' overloads to 'std/parseutils' * Removed redundant `start` and `last` params from slice using procs * Fixed type for parseIdent overload * fixed one by off with 'substr' * removed missed start parameters for procedures * Fixed VM op to work with new 'opcSlice' * Corrected captureBetween's logic to work with openarray * js sys's parsefloat logic now uses openarray Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
* fixes #19278; make `privateAccess` work with generic ref object (#20640)ringabout2022-10-242-1/+16
| | | | | * fixes #19278; make `privateAccess` work with generic ref object * fixes
* Fix tuple size check in `std/jsonutils` (#20637)Jake Leahy2022-10-241-1/+7
| | | | | | | | | | | * Add test for tuple being invalid size * Test tuple size before accessing fields * Fix formatting for import * Fix not being able to build from csources_v1 Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Pass json options to hooks (#20638)Jake Leahy2022-10-241-0/+22
| | | | | | | | | | | * Added tests * Fix expected string * Allow hooks to take an optional parameter that is the current options * Add options to hooks for other generic types * Fix doc links
* add `std/appdirs` (#20618)ringabout2022-10-221-1/+14
|
* add typesafe `std/paths`, `std/files`, `std/dirs`, `std/symlinks` (#20582)ringabout2022-10-212-0/+253
| | | | | | | | | | | | * split std/os; add typesafe std/paths * add more files, dirs, paths * add documentation * add testcase * remove tryRemoveFile * clean up * Delete test.nim * apply changes * add `add` and fixes
* refactor envvars, oserrors; register vmops (#20592)ringabout2022-10-181-1/+2
| | | | | * refactor envvars, oserrors; register vmops * remove type definitions
* fixes #19162; enable `strictEffects` for v2 (#19380)ringabout2022-10-151-3/+3
| | | | | | | | | | | | | | | | | | | * enable stricteffects * add gcsafe * fix tests * use func * fixes pegs tests * explicitly mark repr related procs with noSideEffect * add nimLegacyEffects * change URL * fixes docopt * add `raises: []` to repr * fixes weave * fixes nimyaml * fixes glob * fixes parsetoml * Apply suggestions from code review * Update testament/important_packages.nim * add legacy:laxEffects
* oids sticks to 24 length strings; fixes breaking changes (#20546)ringabout2022-10-121-1/+1
| | | oids sticks 24 length strings