attaswift / BigInt

Arbitrary-precision arithmetic in pure Swift
MIT License
764 stars 106 forks source link

Using tests from “Violet - Python VM written in Swift” #98

Open LiarPrincess opened 2 years ago

LiarPrincess commented 2 years ago

Hi,

As I mentioned in #97 Using ManagedBufferPointer instead of Array as a storage I also implemented my own version of BigInt for Violet - Python VM written in Swift.

The question is: can I merge some of our tests to this repo?

The main idea behind this would be to test our tests. If attaswift/BigInt fails some case then it may mean that the test is wrong, in which case we have to fix our code in Violet.

Violet test suite is quite big (but by no means it is exhausting the test-space). We went with property based testing with means that we test millions of inputs to check if the general rule holds (for example: a+b=c -> c-a=b etc.). This takes time, but pays for itself by finding weird overflows in bit operations (we store “sign + magnitude”, so bit operations are a bit difficult to implement).

You can preview our tests at Violet -> BigIntTests. Though I would advise reading our documentation before, because our design is quite different than yours.

tgymnich commented 2 years ago

Yes, please! Violets test suite looks way more sophisticated than ours.

LiarPrincess commented 2 years ago

Ok. I will work on it next week. Obviously it will be multiple smaller PRs rather than a single big one. All of them will be linked to this issue.

Btw. can I create a new target for it? Something like "VioletBigIntTests". This will simplify the code ownership: everything connected to this target will be owned by me (for example new issue/PR -> I am responsible).