Skip to content

Commit

Permalink
Clean unused variables in units
Browse files Browse the repository at this point in the history
Related #448
  • Loading branch information
dubzzz committed Nov 6, 2019
1 parent e739bd6 commit 7959330
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 100 deletions.
6 changes: 3 additions & 3 deletions test/e2e/SkipAllAfterTime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => {
it('should interrupt as soon as delay expires and mark run as success (no failure before)', () => {
let numRuns = 0;
const out = fc.check(
fc.property(fc.integer(), x => {
fc.property(fc.integer(), _n => {
++numRuns;
return true;
}),
Expand All @@ -37,7 +37,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => {
it('should interrupt as soon as delay expires and mark run as failure if asked to', () => {
let numRuns = 0;
const out = fc.check(
fc.property(fc.integer(), x => {
fc.property(fc.integer(), _n => {
++numRuns;
return true;
}),
Expand All @@ -53,7 +53,7 @@ describe(`SkipAllAfterTime (seed: ${seed})`, () => {
it('should consider interrupt with higer priority than skip', () => {
let numRuns = 0;
const out = fc.check(
fc.property(fc.integer(), x => {
fc.property(fc.integer(), _n => {
++numRuns;
return true;
}),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/check/arbitrary/ArrayArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DummyArbitrary extends Arbitrary<{ key: number }> {
constructor(public value: () => number) {
super();
}
generate(mrng: Random): Shrinkable<{ key: number }> {
generate(_mrng: Random): Shrinkable<{ key: number }> {
return new Shrinkable({ key: this.value() });
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/check/arbitrary/DateArbitrary.utest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('DateArbitrary', () => {
it('Should be able to build the minimal valid date', () => {
// Arrange
const { integer } = mocked(IntegerArbitraryMock);
integer.mockImplementationOnce((a, b) => arbitraryFor([{ value: a }]));
integer.mockImplementationOnce((a, _b) => arbitraryFor([{ value: a }]));

// Act
const arb = date();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/check/arbitrary/LetRecArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('LetRecArbitrary', () => {
const expectedArb1 = buildArbitrary(jest.fn());
const expectedArb2 = buildArbitrary(jest.fn());

const { arb1, arb2 } = letrec(tie => ({
const { arb1, arb2 } = letrec(_tie => ({
arb1: expectedArb1,
arb2: expectedArb2
}));
Expand All @@ -20,7 +20,7 @@ describe('LetRecArbitrary', () => {
expect(arb2).toBe(expectedArb2);
});
it('Should not produce LazyArbitrary for no-tie constructs', () => {
const { arb } = letrec(tie => ({
const { arb } = letrec(_tie => ({
arb: buildArbitrary(jest.fn())
}));
expect(arb).not.toBeInstanceOf(LazyArbitrary);
Expand Down
10 changes: 5 additions & 5 deletions test/unit/check/arbitrary/MixedCaseArbitrary.utest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('MixedCaseArbitrary', () => {
it('should not toggle any character if flags are null', () => {
// Arrange
const { bigUintN } = mocked(BigIntArbitraryMock);
bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(0) }]));
bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(0) }]));
const stringArb = arbitraryFor([{ value: 'azerty' }]);

// Act
Expand All @@ -40,7 +40,7 @@ describe('MixedCaseArbitrary', () => {
it('should toggle characters according to flags', () => {
// Arrange
const { bigUintN } = mocked(BigIntArbitraryMock);
bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }]));
bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }]));
const stringArb = arbitraryFor([{ value: 'azerty' }]);

// Act
Expand All @@ -54,7 +54,7 @@ describe('MixedCaseArbitrary', () => {
it('should toggle both lower and upper characters', () => {
// Arrange
const { bigUintN } = mocked(BigIntArbitraryMock);
bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }]));
bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(9) /* 001001 */ }]));
const stringArb = arbitraryFor([{ value: 'azERty' }]);

// Act
Expand All @@ -68,7 +68,7 @@ describe('MixedCaseArbitrary', () => {
it('should not try to toggle characters that do not have lower/upper versions', () => {
// Arrange
const { bigUintN } = mocked(BigIntArbitraryMock);
bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(0) }]));
bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(0) }]));
const stringArb = arbitraryFor([{ value: 'az01ty' }]); // 01 upper version is the same

// Act
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('MixedCaseArbitrary', () => {
it('should use toggle function when provided to check what can be toggled or not', () => {
// Arrange
const { bigUintN } = mocked(BigIntArbitraryMock);
bigUintN.mockImplementationOnce(n => arbitraryFor([{ value: BigInt(63) /* 111111 */ }]));
bigUintN.mockImplementationOnce(_n => arbitraryFor([{ value: BigInt(63) /* 111111 */ }]));
const stringArb = arbitraryFor([{ value: 'azerty' }]);
const customToggle = jest.fn();
customToggle.mockImplementation((c: string) => {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/check/arbitrary/ObjectArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('ObjectArbitrary', () => {
const mrng = new Random(prand.xorshift128plus(seed));
let shrinkable = anything().generate(mrng);
const originalValue = shrinkable.value;
while (shrinkable.shrink().has(v => true)[0]) {
while (shrinkable.shrink().has(_ => true)[0]) {
shrinkable = shrinkable.shrink().next().value;
} // only check one shrink path
assertShrinkedValue(originalValue, shrinkable.value);
Expand Down Expand Up @@ -282,7 +282,7 @@ describe('ObjectArbitrary', () => {
const mrng = new Random(prand.xorshift128plus(seed));
let shrinkable = json().generate(mrng);
const originalValue = shrinkable.value;
while (shrinkable.shrink().has(v => true)[0]) {
while (shrinkable.shrink().has(_ => true)[0]) {
shrinkable = shrinkable.shrink().next().value;
} // only check one shrink path
expect(typeof shrinkable.value).toEqual('string');
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('ObjectArbitrary', () => {
const mrng = new Random(prand.xorshift128plus(seed));
let shrinkable = unicodeJson().generate(mrng);
const originalValue = shrinkable.value;
while (shrinkable.shrink().has(v => true)[0]) {
while (shrinkable.shrink().has(_ => true)[0]) {
shrinkable = shrinkable.shrink().next().value;
} // only check one shrink path
expect(typeof shrinkable.value).toEqual('string');
Expand Down Expand Up @@ -398,7 +398,7 @@ describe('ObjectArbitrary', () => {
fc.property(fc.integer(), seed => {
const mrng = new Random(prand.xorshift128plus(seed));
let shrinkable = object().generate(mrng);
while (shrinkable.shrink().has(v => true)[0]) {
while (shrinkable.shrink().has(_ => true)[0]) {
shrinkable = shrinkable.shrink().next().value;
} // only check one shrink path
return typeof shrinkable.value === 'object' && Object.keys(shrinkable.value).length === 0;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/check/arbitrary/OneOfArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CustomArbitrary extends Arbitrary<number> {
constructor(readonly value: number) {
super();
}
generate(mrng: Random): Shrinkable<number> {
generate(_mrng: Random): Shrinkable<number> {
function* g(v: number) {
yield new Shrinkable(v - 42);
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/check/arbitrary/OptionArbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('OptionArbitrary', () => {
fc.property(fc.integer(), fc.integer(), (seed, start) => {
const mrng = stubRng.mutable.fastincrease(seed);
let shrinkable = option(stubArb.withShrink(start)).generate(mrng);
while (shrinkable.shrink().has(v => true)[0]) {
while (shrinkable.shrink().has(_ => true)[0]) {
shrinkable = shrinkable.shrink().next().value;
} // only check one shrink path
return shrinkable.value === null;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/check/arbitrary/UuidArbitrary.utest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('UuidArbitrary', () => {
const { nat, integer } = mocked(IntegerArbitraryMock);
const { tuple } = mocked(TupleArbitraryMock);
nat.mockImplementation(() => arbitraryFor([{ value: 0 }, { value: 0 }, { value: 0 }]));
integer.mockImplementation((a, b) => arbitraryFor([{ value: a }]));
integer.mockImplementation((a, _b) => arbitraryFor([{ value: a }]));
tuple.mockImplementation((...arbs) => arbitraryFor([{ value: arbs.map(a => a.generate(mrng()).value_) as any }]));

// Act
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('UuidArbitrary', () => {
const { nat, integer } = mocked(IntegerArbitraryMock);
const { tuple } = mocked(TupleArbitraryMock);
nat.mockImplementation(() => arbitraryFor([{ value: 0 }, { value: 0 }]));
integer.mockImplementation((a, b) => arbitraryFor([{ value: a }]));
integer.mockImplementation((a, _b) => arbitraryFor([{ value: a }]));
tuple.mockImplementation((...arbs) => arbitraryFor([{ value: arbs.map(a => a.generate(mrng()).value_) as any }]));

// Act
Expand Down
8 changes: 4 additions & 4 deletions test/unit/check/arbitrary/definition/Arbitrary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ class FakeNoBiasArbitrary extends Arbitrary<number> {
generate(mrng: Random): Shrinkable<number> {
return new ForwardArbitrary().generate(mrng);
}
withBias(freq: number) {
withBias(_freq: number) {
return new ForwardArbitrary();
}
}

class FakeTwoValuesBiasArbitrary extends Arbitrary<number> {
generate(mrng: Random): Shrinkable<number> {
generate(_mrng: Random): Shrinkable<number> {
return new Shrinkable(44);
}
withBias(freq: number) {
withBias(_freq: number) {
return new (class extends Arbitrary<number> {
generate(mrng: Random): Shrinkable<number> {
return mrng.nextInt(1, 2) === 1 ? new Shrinkable(42) : new Shrinkable(43);
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Arbitrary', () => {
fc.assert(
fc.property(fc.integer(), (seed: number) => {
const mrng = stubRng.mutable.fastincrease(seed);
const fmapper = (v: number) => new ForwardArbitrary();
const fmapper = (_v: number) => new ForwardArbitrary();
const arb = constant(0).chain(fmapper);
const biasedArb = arb.withBias(1); // 100% of bias - not recommended outside of tests
const g = biasedArb.generate(mrng).value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Stream, stream } from '../../../../../src/stream/Stream';

describe('ArbitraryWithShrink', () => {
const arbWithShrink = new (class extends ArbitraryWithShrink<number> {
generate(mrng: Random): Shrinkable<number> {
generate(_mrng: Random): Shrinkable<number> {
throw new Error('Method not implemented.');
}
shrink(value: number, shrunkOnce?: boolean): Stream<number> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const isValidArbitrary = function<U, T>(
const biasedArbitraryBuilder = ([biasedFactor, u]: [(number | null), U]) => {
return biasedFactor != null ? arbitraryBuilder(u).withBias(biasedFactor) : arbitraryBuilder(u);
};
const biasedIsValidValue = (g: T, [biasedFactor, u]: [(number | null), U]) => {
const biasedIsValidValue = (g: T, [_biasedFactor, u]: [(number | null), U]) => {
return settings.isValidValue(g, u);
};

Expand Down
2 changes: 1 addition & 1 deletion test/unit/check/model/ModelRunner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('ModelRunner', () => {
calledBeforeDataReady = calledBeforeDataReady || !setupDataReady;
return true;
};
run = async (m: {}, r: {}) => {
run = async (_m: {}, _r: {}) => {
calledBeforeDataReady = calledBeforeDataReady || !setupDataReady;
};
})();
Expand Down
28 changes: 14 additions & 14 deletions test/unit/check/model/commands/CommandWrapper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ type Real = {};
describe('CommandWrapper', () => {
it('Should show name of the command if it has not run', () => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {};
toString = () => 'sync command';
})();
const wrapper = new CommandWrapper(cmd);
expect(wrapper.toString()).toEqual('sync command');
});
it('Should show name of the command if it has run', () => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {};
toString = () => 'sync command';
})();
const wrapper = new CommandWrapper(cmd);
Expand All @@ -28,8 +28,8 @@ describe('CommandWrapper', () => {
});
it('Should reset run flag of clone', () => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {};
toString = () => 'sync command';
})();
const wrapper = new CommandWrapper(cmd);
Expand All @@ -40,8 +40,8 @@ describe('CommandWrapper', () => {
});
it('Should consider a run on success', () => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {};
toString = () => 'sync command';
})();
const wrapper = new CommandWrapper(cmd);
Expand All @@ -51,8 +51,8 @@ describe('CommandWrapper', () => {
});
it('Should consider a run on failure', () => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {
throw 'failure message';
};
toString = () => 'sync command';
Expand All @@ -64,8 +64,8 @@ describe('CommandWrapper', () => {
});
it('Should consider a run on asynchronous success', async () => {
const cmd = new (class implements AsyncCommand<Model, Real> {
check = (m: Readonly<Model>) => true;
run = async (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = async (_m: Model, _r: Real) => {};
toString = () => 'async command';
})();
const wrapper = new CommandWrapper(cmd);
Expand All @@ -75,8 +75,8 @@ describe('CommandWrapper', () => {
});
it('Should consider a run on asynchronous failure', async () => {
const cmd = new (class implements AsyncCommand<Model, Real> {
check = (m: Readonly<Model>) => true;
run = async (m: Model, r: Real) => {
check = (_m: Readonly<Model>) => true;
run = async (_m: Model, _r: Real) => {
throw 'failure message';
};
toString = () => 'async command';
Expand Down
4 changes: 2 additions & 2 deletions test/unit/check/model/commands/CommandsIterable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type Real = {};
const buildAlreadyRanCommands = (runFlags: boolean[]) => {
return runFlags.map((hasRun, idx) => {
const cmd = new (class implements Command<Model, Real> {
check = (m: Readonly<Model>) => true;
run = (m: Model, r: Real) => {};
check = (_m: Readonly<Model>) => true;
run = (_m: Model, _r: Real) => {};
toString = () => String(idx);
})();
const wrapper = new CommandWrapper(cmd);
Expand Down
Loading

0 comments on commit 7959330

Please sign in to comment.