diff --git a/packages/mini/mini.mjs b/packages/mini/mini.mjs index 8e5f2f33..648499e6 100644 --- a/packages/mini/mini.mjs +++ b/packages/mini/mini.mjs @@ -7,7 +7,7 @@ This program is free software: you can redistribute it and/or modify it under th import * as krill from './krill-parser.js'; import * as strudel from '@strudel.cycles/core'; -const randOffset = 0.0002; +const randOffset = 0.0003; const applyOptions = (parent, code) => (pat, i) => { const ast = parent.source_[i]; diff --git a/packages/mini/test/mini.test.mjs b/packages/mini/test/mini.test.mjs index 71b88855..70577ab0 100644 --- a/packages/mini/test/mini.test.mjs +++ b/packages/mini/test/mini.test.mjs @@ -140,8 +140,20 @@ describe('mini', () => { expect(haps.length < 230).toBe(true); // 'Had too many cycles remaining after degradeBy 0.8'); }); - it('supports lists', () => { - expect(minV('a:b c:d:[e:f] g')).toEqual([['a', 'b'], ['c', 'd', ['e', 'f']], 'g']); + it('supports multiple independent uses of the random choice operator ("|")', () => { + const numCycles = 1000; + const values = mini('[a|b] [a|b]') + .queryArc(0, numCycles) + .map((e) => e.value); + const observed = { aa: 0, ab: 0, ba: 0, bb: 0 }; + for (let i = 0; i < values.length; i += 2) { + const chunk = values.slice(i, i + 2); + observed[chunk.join('')]++; + } + for (const count of Object.values(observed)) { + // Should fall within 99% confidence interval for binomial with p=0.25. + expect(215 <= count && count <= 286).toBe(true); + } }); it('supports the random choice operator ("|") with nesting', () => { const numCycles = 900; @@ -169,4 +181,7 @@ describe('mini', () => { // PRNG, this test should succeed expect(chisq <= 15.086).toBe(true); }); + it('supports lists', () => { + expect(minV('a:b c:d:[e:f] g')).toEqual([['a', 'b'], ['c', 'd', ['e', 'f']], 'g']); + }); });