Skip to content

Commit

Permalink
chore(test): cleanup usages of randomSeed (#3260)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Nov 19, 2024
1 parent eae226e commit b85d0fd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
3 changes: 0 additions & 3 deletions test/modules/color.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ describe('color', () => {
);
});

// Create and log-back the seed for debug purposes
faker.seed(Math.ceil(Math.random() * 1_000_000_000));

describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))(
'random seeded tests for seed %i',
() => {
Expand Down
3 changes: 0 additions & 3 deletions test/modules/science.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ describe('science', () => {
t.itEach('chemicalElement', 'unit');
});

// Create and log-back the seed for debug purposes
faker.seed(Math.ceil(Math.random() * 1_000_000_000));

describe.each(times(NON_SEEDED_BASED_RUN).map(() => faker.seed()))(
'random seeded tests for seed %i',
() => {
Expand Down
10 changes: 2 additions & 8 deletions test/utils/mersenne.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { MersenneTwister19937 } from '../../src/internal/mersenne';
import { randomSeed } from '../../src/internal/seed';
import type { Randomizer } from '../../src/randomizer';
import {
generateMersenne32Randomizer,
Expand All @@ -15,18 +16,12 @@ import {

const NON_SEEDED_BASED_RUN = 25;

function newTwister(
seed: number = Math.random() * Number.MAX_SAFE_INTEGER
): MersenneTwister19937 {
function newTwister(seed: number = randomSeed()): MersenneTwister19937 {
const twister = new MersenneTwister19937();
twister.initGenrand(seed);
return twister;
}

function randomSeed(): number {
return Math.ceil(Math.random() * 1_000_000_000);
}

describe('MersenneTwister19937', () => {
describe('genrandInt32()', () => {
it('should be able to return 0', () => {
Expand Down Expand Up @@ -116,7 +111,6 @@ describe.each([
});
});

// Create and log-back the seed for debug purposes
describe.each(
times(NON_SEEDED_BASED_RUN).flatMap(() => [
[randomSeed()],
Expand Down

0 comments on commit b85d0fd

Please sign in to comment.