summaryrefslogtreecommitdiff
path: root/pbt/ts/src/gen.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'pbt/ts/src/gen.test.ts')
-rw-r--r--pbt/ts/src/gen.test.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/pbt/ts/src/gen.test.ts b/pbt/ts/src/gen.test.ts
new file mode 100644
index 0000000..eaba36f
--- /dev/null
+++ b/pbt/ts/src/gen.test.ts
@@ -0,0 +1,19 @@
+import Prando from 'prando';
+import {none} from 'fp-ts/lib/Option.js';
+import * as G from './gen.js';
+import {test, expect} from 'vitest';
+
+test('can generate and shrink bytes', async () => {
+ const prng = new Prando(Math.random() * 1000);
+ const gen = new G.BytesGen(prng);
+ const bytes: number[][] = [];
+ for (let i = 1; i < 10; i++) {
+ bytes.push(gen.generate(i));
+ }
+ console.log('Generated bytes:', bytes);
+ const replay = gen.replay();
+ for (let i = 1; i < 10; i++) {
+ const replayed = replay.generate(i);
+ expect(replayed, `Replaying at ${i}`).toEqual(bytes[i - 1]);
+ }
+});