Commit Graph

220 Commits

Author SHA1 Message Date
Jordan Hrycaj c020fd80f1
Fix ge() fringe case (#135)
why:
  The point `high(P)` is treated separately and added to the top adjacent
  interval or is treated as a sigle point interval.
2022-07-25 15:05:27 +01:00
Jordan Hrycaj 598246620d
Fix fringe case (#130)
why:
 Merging [a,a] in to {[a+1,b]} caused assertion violation, doAssert
 condition was too strict.
2022-07-19 09:19:41 +01:00
Jordan Hrycaj 8a9816ac02
Fix iterator edge cases for [high(P),high(P)] (#129)
also:
  cascaded `if` in rbtree (for unrelated troubleshooting)
2022-07-18 18:56:31 +01:00
tersec f173efc500
stylecheck: nnkArglist -> nnkArgList (#127)
* stylecheck: nnkArglist -> nnkArgList

* --stylecheck:error iff >= 1.6.0
2022-07-18 11:02:40 +00:00
Jacek Sieka 9a3130eb5b
leb128: avoid shifts larger than type (#123) 2022-07-16 19:16:11 +02:00
Zahary Karadjov b55c5a6d74
Reorder the definitions to avoid a refernce to setBit before it's being defined 2022-07-14 15:11:34 +03:00
Jordan Hrycaj 9c3596d9de
Migrate to `unittest2` (#125)
* Migrate to `unittest2`

why:
  Global symbol overflow when running NIM 1.2 on Github ci suggests that
  unit tests run sort of separately. The replacement library `unittest2`
  provides that.

* Build ci dependencies
2022-07-08 10:34:21 +01:00
Jordan Hrycaj 4cab7b0879
Added `IntervalSet`, sets of non-adjacent intervals (#121)
* Added `IntervalSet`, sets of non-adjacent intervals

Relocated from nimbus-eth1 snap sync development

* Fix local import directive

* Fix --styleCheck complaints

* Attempt to get around CI problem by varying items

details:
  Vary all_tests exec list
  Hide useless globalness of `noisy` constant in non-debugging mode
2022-06-20 15:04:47 +01:00
Jacek Sieka dad28a269f
result: add `Opt.some` / `Opt.none` (#117) 2022-06-17 13:45:22 +03:00
zah 981551ae5d
Nimble Setup (#110) 2022-06-17 11:43:10 +03:00
Zahary Karadjov f75c0a273a
[skip ci] consistent formatting 2022-06-17 11:39:35 +03:00
zah 9fe9cb7002
Add byteutils.hexToByteArrayStrict (#120) 2022-06-17 11:37:06 +03:00
Jordan Hrycaj b3ea2c6b46
Normalise `KeyError` exception message (#119) 2022-06-16 16:19:53 +01:00
lchenut c2f0cbf0d9
Add enum utilities and add enum with holes support (#115) 2022-06-10 02:29:07 +03:00
zah 412a691f5d
Remote a test that doesn't work with Nim 1.2 (#114) 2022-05-23 15:27:04 +03:00
Jordan Hrycaj 779ba052c8
Refactor lruFetch() item rotation (#112)
* Re-route KeyError exceptions as Defect for all except the `[]` function

why:
  Access via key is verified, error is returned via Result[]

* Refactor lruFetch() item rotation

why:
  Previously, the item was deleted and re-inserted in the table although
  for rotation, only the queue links need to be updated.

* Delete some KeyError annotations

why:
  Was overlooked earlier

* More KeyError fixes
2022-05-19 18:51:47 +01:00
Dustin Brody cdb1f213d0
rm obsolete/unused/unmaintained CI AppVeyor and Travis scripts 2022-03-31 12:04:30 +00:00
tersec 419903c9a3
Merge pull request #108 from status-im/sqz
don't disable checks in ptrops
2022-03-16 20:24:54 +00:00
Dustin Brody 057cceeb40
offset() wraparound 2022-03-16 19:40:25 +00:00
Dustin Brody bb73567168
don't disable checks in ptrops 2022-03-16 17:02:32 +00:00
tersec 67b43e2dba
Merge pull request #106 from status-im/Sce
prevent leakage of ptrops checks pragma disabling
2022-03-12 14:46:52 +00:00
Dustin Brody fecc3cc5cb
prevent leakage of ptrops checks pragma disabling 2022-03-10 09:19:14 +00:00
Zahary Karadjov b87fd80b0f
Add tests for recordFields being used with empty objects 2022-03-03 17:36:28 +02:00
Zahary Karadjov bb705bf17b
Stop mixing Result and Exceptions in some of the KeyedQueue APIs 2022-01-23 21:18:03 +02:00
Jacek Sieka b464505b4d
oops 2022-01-13 22:21:46 +01:00
Jacek Sieka 9d0f1167ca
results: `[]` for void (#103)
mostly for consistency.. but it's used in nim-eth tests
2022-01-13 22:02:44 +01:00
Jacek Sieka 6ad35b876f result: expose value/error in errorOr/valueOr
* fix error type as well
2022-01-11 16:39:12 +02:00
Jacek Sieka d2ae2889e8
`Result` refresh (#96)
* `Result` refresh

* add full support for `Result[T, void]` (aka `Opt[T]` aka `Option[T]`)
* expand tests
* add `flatten`, `filter` of `Option` fame
* add `tryError` that raises a regular exception when result holds a
value
* fix `$` to print `ok`/`err` in lower-case, like the functions that
created the result
* add `orErr` that collapses all errors to a single value of a
potentially different type - useful when translating errors between
layers
* `capture` should work with `CatchableError`
* remove `Defect`-dependent tests

* Update stew/results.nim

* avoid redundant error message when converting error to string
* avoid multiple evaluation in `valueOr`
* add `unsafeError` to match `unsafeGet`
* let `valueOr` evaluate a block
* add `errorOr` to mirror `valueOr`
2022-01-10 00:22:09 +02:00
Jacek Sieka 17cd8c846f
add `to0xHex` which returns a `0x`-prefixed hex string 2022-01-06 17:05:47 +01:00
Michael Bradley 4750020a44
byteutils: drop import of assign2 since arrayops imports/exports it (#100)
Closes #99
2022-01-06 08:32:29 +01:00
Jacek Sieka 4e223b95a7
endians2: use copyMem instead of loop outside of vm (#95)
Looking at generated assembly, it turns out the optimizer is not smart
enough to get rid of the loop - use `copyMem` instead.

At least the compiler is smart enough to constant-propagate runtime
endian direction, resolving the review comment.

Also clarify why a minimum length is enfored - it could perhaps be
revisited, but that would leave a slightly odd API.

the `array` overloads are actually unnecessary with an optimizing
compiler - as long as it can prove the length, any extra checks will go
away on their own

also add `initCopyFrom`

* document optimizations
2022-01-03 14:53:01 +01:00
Ștefan Talpalaru 48666d9c65
CI: all Nim versions are supported (#98) 2022-01-02 06:49:51 +01:00
Zahary Karadjov 2f9c61f485
Add hashes.hashAllFields 2021-12-03 13:30:06 +02:00
Zahary Karadjov a98ec09b0b
Add sets.keepItIf 2021-12-03 13:28:59 +02:00
Zahary Karadjov 7ab114e159
Add templateutils.evalTemplateParamOnce 2021-12-03 13:28:54 +02:00
Jacek Sieka 8a405309c6
enable styleCheck:usages (#93) 2021-12-02 16:24:02 +01:00
Jordan Hrycaj 3b9e906a18
Merge pull request #92 from status-im/jordan/fix-SortedSet-naming
Fix canonical name
2021-11-29 09:58:55 +00:00
Jordan Hrycaj f97e953c26
Fix canonical name
why:
  The name clear() is commonly used as reset function.
2021-11-25 17:40:29 +00:00
Ștefan Talpalaru a61869c256
Merge pull request #87 from status-im/ci_multi_nim
CI: test with multiple Nim branches
2021-11-16 15:57:17 +01:00
Ștefan Talpalaru fdd06d8a3e
CI: test with multiple Nim branches
daily CI job
2021-11-16 12:24:13 +01:00
cheatfate a587b7a8eb Fix generic sandwich problem. 2021-11-09 20:15:15 +02:00
Jordan Hrycaj b002c1fad0
New data structures - SortedSet and KeyedQueue
See the modules' documentation for more details
2021-11-04 13:17:50 +02:00
Zahary Karadjov 478cc6efde Add object.isZeroMemory 2021-09-13 19:02:32 +03:00
Jacek Sieka 3c91b8694e
add void tests (#84) 2021-07-07 10:12:20 +02:00
jangko e10da4a90e
fixes bug in base64 decoder when decoding byte sequence
the decoder accepts string or byte sequence but assume
the inner type is a char, now fixed
2021-06-17 08:16:56 +07:00
Ștefan Talpalaru 70680e2af2
CI: refactor Nim compiler caching (#82) 2021-06-01 08:27:27 +02:00
Jacek Sieka 7fb220d1e8
assign2: string support (#81) 2021-04-16 15:23:36 +02:00
Jacek Sieka 7d2790fdf4
fix `countZeros` (#80)
should return zeros based on bits, not bytes!
2021-04-12 22:55:09 +02:00
Eugene Kabanov ede0651741
Fix issue with `uint` type. (#79)
* Fix issue with `uint` type.
Add tests for `uint` type.

* Add decode tests for `uint` type.
2021-04-09 19:01:50 +03:00
Zahary Karadjov ee78822e05
Alternative definition of string.hexToByteArray(N)
This definition is more robust. The previously existing version was
producing compilation errors in certain generic contexts. static
"regular" params are recommended in general as they are more flexible
than the explicit generic parameters.
2021-03-19 03:56:01 +02:00