diff --git a/helpers/prng_unsafe.nim b/helpers/prng_unsafe.nim index d977e6d..b408d02 100644 --- a/helpers/prng_unsafe.nim +++ b/helpers/prng_unsafe.nim @@ -118,7 +118,7 @@ func random_unsafe*[T: SomeInteger](rng: var RngState, inclRange: Slice[T]): T = # Containers # ------------------------------------------------------------ -func sample_unsafe*[T](rng: var RngState, src: openarray[T]): T = +func sample_unsafe*[T](rng: var RngState, src: openArray[T]): T = ## Return a random sample from an array result = src[rng.random_unsafe(uint32 src.len)] @@ -206,7 +206,7 @@ type HighHammingWeight Long01Sequence -func random_elem*(rng: var RngState, T: typedesc, gen: RandomGen): T {.inline, noInit.} = +func random_elem*(rng: var RngState, T: typedesc, gen: RandomGen): T {.inline, noinit.} = case gen of Uniform: result = rng.random_unsafe(T) diff --git a/stint.nimble b/stint.nimble index b7fb0a5..ef3f52a 100644 --- a/stint.nimble +++ b/stint.nimble @@ -30,8 +30,9 @@ task test_public_api, "Run all tests - prod implementation (StUint[64] = uint64" task test_uint256_ttmath, "Run random tests Uint256 vs TTMath": requires "https://github.com/alehander42/nim-quicktest >= 0.18.0", "https://github.com/status-im/nim-ttmath" - switch("define", "release") - test "uint256_ttmath", "cpp" + putEnv("TEST_LANG", "cpp") + switch("define", "release") + test "", "tests/test_uint256_ttmath" task test, "Run all tests": exec "nimble test_internal" diff --git a/tests/all_tests.nim b/tests/all_tests.nim index 9bf1c12..5e6d1ea 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -34,4 +34,6 @@ import import test_io, - test_conversion + test_conversion, + t_randomized_divmod + diff --git a/tests/t_randomized_divmod.nim b/tests/t_randomized_divmod.nim index c0e2e71..dfc4b9d 100644 --- a/tests/t_randomized_divmod.nim +++ b/tests/t_randomized_divmod.nim @@ -25,15 +25,15 @@ echo "t_randomized_divmod xoshiro512** seed: ", seed proc test_divmod(bits: static int, iters: int, gen: RandomGen) = for _ in 0 ..< iters: - let a = rng.random_elem(Stuint[bits], gen) - let b = rng.random_elem(Stuint[bits], gen) + let a = rng.random_elem(StUint[bits], gen) + let b = rng.random_elem(StUint[bits], gen) try: let (q, r) = divmod(a, b) doAssert a == q*b + r except DivByZeroDefect: doAssert b.isZero() - + template test(bits: static int) = test "(q, r) = divmod(a, b) <=> a = q*b + r (" & $bits & " bits)": test_divmod(bits, Iters, Uniform) @@ -43,4 +43,4 @@ template test(bits: static int) = suite "Randomized division and modulo checks": test(128) test(256) - test(512) \ No newline at end of file + test(512) diff --git a/tests/ttmath_compat.nim b/tests/ttmath_compat.nim index eda9fbc..da0695f 100644 --- a/tests/ttmath_compat.nim +++ b/tests/ttmath_compat.nim @@ -1,4 +1,4 @@ -import ../stint, ttmath +import ../stint, ttmath/ttmath export ttmath template asSt*(val: UInt): auto =