Commit Graph

25 Commits

Author SHA1 Message Date
Timothee Cour
49033eb531 make tests/stdlib tests joinable (#14626)
* make tests/stdlib tests joinable

* fixup
2020-06-15 13:27:33 +02:00
cooldome
3b5a504692 parseEnum_regression (#14150)
Co-authored-by: cooldome <ariabushenko@bk.ru>
2020-04-28 19:56:50 +02:00
Jacek Sieka
7d6cbf290a Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
2020-04-28 19:56:01 +02:00
Vindaar
d42c5a575d base parseEnum on a case statement, fixes #14030 (#14046)
* base `parseEnum` on a case statement, fixes #14030

* apply simplifactions / clean up, remove `norm` node, use strVal

* export `normalize` in json.nim

* cmp using nimIdentNormalize, error at CT if ambiguous enum found

`nimIdentNormalize` provided by @cooldome.

We track all names of the branches we have created so far and error if
a duplicate is found.

Dummy change to make github react...

* fix docstring of `nimIdentNormalize`

* make `typ` arg `typedesc`, add lineinfo, call norm. only once
2020-04-22 09:41:56 +01:00
b3liever
0c4d81241a Version of trimZeros without temp strings (#12633) 2019-11-11 12:54:17 +01:00
Andreas Rumpf
3ba3307d61 remove deprecated procs (#12535) 2019-11-05 11:05:46 +01:00
Charles Blake
bde899d4f8 Attempt to close https://github.com/nim-lang/Nim/issues/11430 2019-06-12 07:44:56 -04:00
Andreas Rumpf
5eb47f8ed9 fixes #11369 (#11381) 2019-06-02 14:24:38 +02:00
Arne Döring
1105d03644 require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
Andreas Rumpf
0330fb2e13 fixes #8911 2018-09-16 12:28:43 +02:00
Iván Montes
ee29370f60 Fixed 7478: splitLines keepEol option (#8621) 2018-08-13 11:42:50 +02:00
Vindaar
e80be6173d Add parse bin int, fixes #8018 (#8020)
* clarify `parseHexInt`, `parseOctInt` docstring and exception msgs

* add `parseBinInt` based on `parseutil.parseBin` implementation

Adds a `parseBinInt`, which parses a binary integer string and returns
it as an integer. This is based on the implementation of
`parseutil.parseBin`, removing the unnecessary parts.

* add tests for all `parse(Hex|Oct|Bin)Int` procs

* replace `parse*Int` proc impls by call to parseutil procs

Replaces the `parse(Hex|Oct|Bin)Int` procedure implementation by calls
to the `parseutil` procs, which receive a mutable argument.

Has the main advantage that the empty string as well as a "prefix
only" string, e.g. "0x" counts as an invalid integer.

Also moves the `parseOctInt` proc further up in the file so that all
`parse` procs are below one another.

* replace `var L` by `let L` in `parse` procs

There's no reason for the usage of `var` here.

* add `maxLen` optional arg for `parseutil.parse(Oct|Bin)`

Plus small change to test cases.

* update changelog about `parse*Int` procs

* fix `rejectParse` template in `tstrutils`

* make sure only `s.len` chars are parsed, if `maxLen+start` > s.len

Fixes a previous bug in `parseHex` (and now affected `parseOct` and
`parseBin`), which allowed to set `start + maxLen` to be larger than
the strings length. This resulted in an out of bounds access.

* move `parse*Int` proc change to breaking changes, add double `
2018-06-13 13:32:12 -04:00
Federico Ceratto
4100932a4b Add string-to-hex and back conversions
Add parseHexStr and toHex and tests.
2017-11-27 16:43:41 +00:00
Bo Lingen
c182d37f45 Update removeSuffix implementations to match removePrefix (#6636) 2017-10-30 22:45:13 +01:00
Bo Lingen
e135135469 add strutils.removePrefix proc (#6473) 2017-10-28 10:47:23 +02:00
Viktor Marosvary
ce04288d64 isAlphaNumberic and isDigit improvement + tests (#6579)
if we encounter a character that does not satisfy the proc, we return immediately, without continuing to loop over the rest of the chars in the string.
2017-10-24 10:22:18 +02:00
Simon Krauter
94e336fe85 Fix wrong result of countLines() (#6371) 2017-09-15 10:45:22 +02:00
Parashurama
d04ca6ef23 Improve & optimize strutils 'find' procs (#5196)
* add 'last' argument to 'find' procs in strutils
* add 'rfind' proc for looking up set[char] in strutils
* use optimised C function 'memchr' when available
2017-01-11 09:48:31 +01:00
Charles Blake
a1df79d5f2 Add a unit test that covers issue 3477
https://github.com/nim-lang/Nim/issues/3477
2015-11-19 07:03:06 -05:00
Zach Aysan
94149f7a48 Update tests to proposed changes 2015-07-21 15:04:10 -04:00
Zach Aysan
d28862422b Add tests for chomp 2015-07-17 16:26:10 -04:00
Hans Raaf
3546ff8819 Replaced repeatStr() and repeatChar() with more natural versions. 2015-03-03 16:37:54 +01:00
Hans Raaf
a471b3c87f Added test for toHex(). 2015-02-18 19:02:38 +01:00
dyu
12f97a7151 strutils.rfind via char 2014-12-19 20:08:42 +08:00
Araq
20b5f31c03 new tester; all tests categorized 2014-01-13 02:10:03 +01:00