Skip to content

Commit 50a0d26

Browse files
🧪 test: Make a test with large shuffled input deterministic.
1 parent d27eb94 commit 50a0d26

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"devDependencies": {
6262
"@aureooms/js-compare": "2.0.0",
6363
"@aureooms/js-itertools": "5.1.0",
64+
"@aureooms/js-pseudo-random": "^2.0.0",
6465
"@aureooms/js-random": "2.0.0",
6566
"@babel/core": "7.13.14",
6667
"@babel/preset-env": "7.13.12",

test/src/RedBlackTree/remove.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@ import {increasing} from '../../fixtures.js';
44

55
import {list, range, sorted, head, iter, exhaust} from '@aureooms/js-itertools';
66

7-
import {shuffle} from '@aureooms/js-random';
7+
import {_fisheryates, _shuffle} from '@aureooms/js-random';
8+
import {splitmix64, nextFloat64} from '@aureooms/js-pseudo-random';
9+
10+
const seed = [0, 17];
11+
const prng = splitmix64(seed);
12+
const random = () => nextFloat64(prng);
13+
const _randint = (random) => (i, j) => i + Math.floor(random() * (j - i));
14+
const randint = _randint(random);
15+
const sample = _fisheryates(randint);
16+
const shuffle = _shuffle(sample);
817

918
import {RedBlackTree, _debug} from '../../../src/index.js';
1019

yarn.lock

+12
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,23 @@
2727
"@aureooms/js-collections-deque" "^6.0.1"
2828
"@aureooms/js-error" "^5.0.2"
2929

30+
"@aureooms/js-pseudo-random@^2.0.0":
31+
version "2.0.0"
32+
resolved "https://registry.yarnpkg.com/@aureooms/js-pseudo-random/-/js-pseudo-random-2.0.0.tgz#84e396cdf7d2c5d05c54c2e05f0aa4f69e107d4c"
33+
integrity sha512-PdTQCoeo9npuLONdZme469xEbLyjWU5YjCl6DVa0NkiFDglx5Jka+Ojv6oNXkfdgjo/P/soqTDDK7ZKJDuo7dA==
34+
dependencies:
35+
"@aureooms/js-uint64" "^3.0.1"
36+
3037
"@aureooms/js-random@2.0.0":
3138
version "2.0.0"
3239
resolved "https://registry.yarnpkg.com/@aureooms/js-random/-/js-random-2.0.0.tgz#f62c6954ed79bd9a520197125ee3cfbe14b00d72"
3340
integrity sha1-9ixpVO15vZpSAZcSXuPPvhSwDXI=
3441

42+
"@aureooms/js-uint64@^3.0.1":
43+
version "3.1.0"
44+
resolved "https://registry.yarnpkg.com/@aureooms/js-uint64/-/js-uint64-3.1.0.tgz#abd5eba5392dc0503415c383b1deb3d09b5711b6"
45+
integrity sha512-q38EIajp2Iiv+lLJjgFH9LVe5GnWnmhQPUOScPN4fmWywRJJ11qb5i5j1NbtmgRcs6EpymOk6bSRc3Jbh0OENw==
46+
3547
"@babel/code-frame@7.12.11":
3648
version "7.12.11"
3749
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"

0 commit comments

Comments
 (0)