-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve Int128
API
#123
improve Int128
API
#123
Conversation
* `shl` now also accepts an integer * `shr` now wraps the shift distance prior to shifting (same as what `shl` already does)
This is in line with the nomenclature used for the built-in integer types, where `div` returns an integer (instead of a floating-point number).
The standard `div` treats the values as signed, and for consistency, `<` and `<=` now do too. All usage sites are updated.
They are based on the tests for the NimSkull compiler's internal `Int128` type.
@saem: I'm not sure what licensing obligations taking and modifying the test file from NimSkull entails. |
They're both MIT licensed, so that's fine, there is no explicitly copyright notice so that doesn't have to replicated (assuming an overlay literal reading). I think as is is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One very minor consideration, but incredibly soft suggestion, feel free to ignore it as I'm not convinced it's better.
@@ -360,7 +360,8 @@ if file.len == 0: | |||
# XXX: parallel execution of tests is still missing | |||
for (dir, runner) in dirs.items: | |||
for it in walkDir(dir, relative=false): | |||
if it.path.endsWith(".test"): | |||
if it.path.endsWith(".test") or | |||
(it.path.endsWith(".nim") and it.path.extractFilename.startsWith("t")): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other option would be to only do it for the unittest
directory, treating it as a specific runner accommodation. This is fine though, just thinking out loud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the longer term, I think every directory should specify (via some sort of configuration file) what files to consider tests itself, though there's also the real risk of turning the tester into some overly general and complex tool.
Summary
Int128
APItester
treatt*.nim
files as testsInt128
Details
API improvements:
<
and<=
now treat the operands as signed integers<=%
and<%
(in line with thestandard library naming scheme)
/
todiv
, to reserve the former for fractionsshl
andshr
now consistently wrap the shift distancetoInt128
, not justint
All usages of
Int128
comparisons are adjusted, except for the onesin
builtin.nim
, which should have been signed comparisons from thestart (this fixes an interpreter bug).
To easily run NimSkull-based tests, the tester now considers
t*.nim
as tests. A set of tests for
Int128
based on NimSkull's tint128.nimis added to the test suite.
Notes For Reviewers