summary refs log tree commit diff stats
path: root/tests/stdlib/tstrutils.nim
Commit message (Collapse)AuthorAgeFilesLines
* make parseEnum skip type aliases for enum type sym (#22727)metagn2023-09-191-4/+15
| | | fixes #22726
* `strutils.split/rsplit` now return src on an empty sep (#22136)Zoom2023-06-211-6/+10
| | | | | | | | | | | | | | | This is a rebase of an earlier rejected PR. Following the discussion around it, this commit provides a valid output for and edge case of an empty separator for `split` and `rsplit` routines. The empty separator is interpreted as "split by no separators" and the initial string is returned. This is consistent with the behaviour of the `set[char]` version of `split`/`rsplit` routines and unifies them all. Compared to a commit merged earlier, this one has a benefit of not using assertions that will be removed in release builds and thus still not preventing possible infinite loops (which was the earlier behaviour for this edge case for separator of type `string`). Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* alternative to #21914; split, rsplit now forbid an empty separator (#21961)ringabout2023-05-301-0/+14
|
* stdlib tests now check refc too (#21664)ringabout2023-04-211-1/+1
| | | | | | | | | | | * stdlib tests now check refc too * typo * fixes line numbers * disable cpp * do not touch
* int64/uint64 as bigint in JS (#21613)metagn2023-04-111-7/+11
| | | | | | | | | | | * int64/uint64 as bigint in JS * fix CI * convert to compile option * fix lie * smaller diff, changelog entry
* strutils, rstgen: avoid deprecated `strutils.delete` (#20488)ee72022-10-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The strutils `delete` func with signature func delete*(s: var string, first, last: int) was deprecated in adba5eb45e0a, in favor of one with signature func delete*(s: var string, slice: Slice[int]) However, a few procedures still used the deprecated form. This commit updates them, resolving these deprecation warnings: rstgen.nim(766, 12) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated] strutils.nim(1651, 19) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated] strutils.nim(1679, 7) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated] strutils.nim(2472, 7) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated] Before this commit: - `trimZeros` called `s.delete(i+1, i)` for an input that lacks a trailing zero (like "1.23"). - `removePrefix*(s: var string, prefix: string)` called `s.delete(0, -1)` when the prefix was the empty string. which did not modify `s`, nor raise an error. But the newer slice `delete` raises an `IndexDefect` when the start of the slice is greater than the end, so we avoid calling the new `delete` for such a case. Recall that exceptions inheriting from `system.Defect` are not tracked with the `.raises: []` exception tracking mechanism [1], so this commit does not break existing code like: proc foo {.raises: [].} = var s = "abc1.20" s.removePrefix("abc") s.trimZeros() doAssert s == "1.2" The `strutils.delete` deprecation was motivated by a problem with `system.delete` [2][3]: `system.delete` had surprising behavior when the index passed to it was out of bounds (it would delete the last entry then). Compile with `-d:nimStrictDelete` so that an index error is produced instead. Be aware however that your code might depend on this quirky behavior so a review process is required on your part before you can use `-d:nimStrictDelete`. To make this review easier, use the `-d:nimAuditDelete` switch, which pretends that `system.delete` is deprecated so that it is easier to see where it was used in your code. `-d:nimStrictDelete` will become the default in upcoming versions. A similar deprecation happened with `sequtils.delete` [4], but that deprecated form is already not used in this repo. [1] https://github.com/nim-lang/Nim/blob/2dec69fe5aa6/doc/manual.md#exception-tracking [2] https://github.com/nim-lang/Nim/blob/2dec69fe5aa6/changelogs/changelog_1_6_0.md#system [3] https://github.com/nim-lang/Nim/commit/92cb76571432 [4] https://github.com/nim-lang/Nim/commit/1d6863a7899f
* fix #19500; remove find optimization [backport: 1.6] (#19714)ringabout2022-09-281-0/+5
| | | | | | | | | | | | | | | | * remove find optimization close #19500 * save find to std * add simple tests * Apply suggestions from code review Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Co-authored-by: sandytypical <43030857+xflywind@users.noreply.github.com> Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
* make more standard libraries work with `nimPreviewSlimSystem` (#20343)ringabout2022-09-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * 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
* fix #18128 rfind on empty needle returns rightmost index (#20430)n5m2022-09-261-13/+17
| | | rfind on empty needle returns haystack len
* Fix `find` routines' api to default to `last=-1` (#19761)Zoom2022-06-071-17/+21
| | | | | | | | | | | | This changes the default for the `last` parameter of various `find` routines from `0` to `-1`. Previous default prevents limiting the search to the first character. This is a logic error, as full text search was performed for 2 *valid* values of `last`: `0` and `last.high()`. Adds an overload for `initSkipTable` which returns a newly initialized table. This encapsulates every single usage of a `var`-acting original func in this module. Co-authored-by: flywind <xzsflywind@gmail.com>
* fix parseEnum cannot parse enum with const fields (#19466)flywind2022-02-041-0/+11
| | | fix #19463
* Fix nimIdentNormalize, fixes #19067 (#19068)Tomasz Kramkowski2021-10-291-0/+7
| | | | | | | * Make nimIdentNormalize return "" when passed ""; fixes #19067 Fixes #19067 * Add tests for nimIdentNormalize
* deprecate strutils.delete and add an overload with saner semantics ↵Timothee Cour2021-07-181-1/+25
| | | | consistent with sequtils.delete; follows #18487 (#18510)
* add string-string tests for find and rfind (#18137)n5m2021-06-021-3/+98
| | | | | | | * add string-string tests for find and rfind * remove duplicate test cases * remove more redundant test cases
* improve fast returns of find and rfind (#18127)n5m2021-05-311-0/+28
|
* std/hashes: hash(ref|ptr|pointer) + other improvements (#17731)Timothee Cour2021-04-161-5/+1
|
* use doAssert in tests (#16486)flywind2020-12-281-132/+132
|
* strip minor improvement (#16444)flywind2020-12-231-0/+13
| | | | | | | * strip minor improvement * add more tests * Update tests/stdlib/tstrutils.nim Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* improve tstrutils: test c, cpp, js, vm; cleanups (#16357)Timothee Cour2020-12-151-0/+689
* renamed: tests/stdlib/tstrutil.nim -> tests/stdlib/tstrutils.nim * improve test * enable tstrutils for js, vm