Improve Disk II test reliability (#195)

Before, the garbage test had only about a 92% chance of success
because it relied on random numbers not being equal.  This change just
repeats the test 5 times and allows up to 1 failure.  This increases
the chance of the test passing to a hair less that 99.8%.
This commit is contained in:
Ian Flanigan 2023-08-13 00:50:48 +02:00 committed by GitHub
parent 0047b9dbb3
commit 486f554d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 19 deletions

View File

@ -677,6 +677,9 @@ describe('DiskII', () => {
diskII.ioSwitch(0x82); // coil 1 off
diskII.ioSwitch(0x8e); // read mode
// Try this test 5 times because we could get unlucky.
let failures = 0;
for (let i = 0; i < 5; i++) {
// Read 5 nibbles
const nibbles: byte[] = [];
let read = false;
@ -698,7 +701,11 @@ describe('DiskII', () => {
for (let i = 1; i < 5; i++) {
equal ||= nibbles[0] === nibbles[i];
}
expect(equal).not.toBeTruthy();
if (equal) {
failures++;
}
}
expect(failures).toBeLessThan(2);
});
it('disk spins at a consistent speed', () => {