DefinitelyTyped/types/seed-random/seed-random-tests.ts
Ben Lichtman 91f680205a
Revert "[assert] Add support for TypeScript's Assertion Functions" (#41916)
* Revert "[assert] Add support for TypeScript's Assertion Functions (#41616)"

This reverts commit 1eb97992fe.

* Update oracledb tests
2020-01-28 11:09:29 -08:00

27 lines
673 B
TypeScript

/// <reference types="node" />
import * as assert from 'assert';
import * as seed from 'seed-random';
const trueRandomA = seed();
const trueRandomB = seed();
assert(trueRandomA() !== trueRandomB());
const fakeRandomA = seed('foo');
const fakeRandomB = seed('foo');
assert(fakeRandomA() === fakeRandomB());
const fakeRandomC = seed('foo', {entropy: true});
const fakeRandomD = seed('foo', {entropy: true});
assert(fakeRandomC() !== fakeRandomD());
// override global Math.random
seed('foo', {global: true});
const numA = Math.random();
seed('foo', {global: true});
const numB = Math.random();
assert(numA === numB);
// reset to default Math.random
seed.resetGlobal();