Remove some linter-skipping

This commit is contained in:
David Evans 2018-05-04 22:51:01 +01:00
parent e32a54e03a
commit 73cc61d430
6 changed files with 66 additions and 54 deletions

View File

@ -1463,19 +1463,19 @@
class AgentState {
constructor({
visible = false,
locked = false,
blocked = false,
highlighted = false,
group = null,
covered = false,
group = null,
highlighted = false,
locked = false,
visible = false,
} = {}) {
this.visible = visible;
this.locked = locked;
this.blocked = blocked;
this.highlighted = highlighted;
this.group = group;
this.covered = covered;
this.group = group;
this.highlighted = highlighted;
this.locked = locked;
this.visible = visible;
}
}
AgentState.LOCKED = new AgentState({locked: true});
@ -2494,8 +2494,8 @@
agent: agents[0],
ln: 0,
options,
tag,
parallel,
tag,
});
this.handleConnectDelayEnd({
agent: agents[1],

File diff suppressed because one or more lines are too long

View File

@ -1463,19 +1463,19 @@
class AgentState {
constructor({
visible = false,
locked = false,
blocked = false,
highlighted = false,
group = null,
covered = false,
group = null,
highlighted = false,
locked = false,
visible = false,
} = {}) {
this.visible = visible;
this.locked = locked;
this.blocked = blocked;
this.highlighted = highlighted;
this.group = group;
this.covered = covered;
this.group = group;
this.highlighted = highlighted;
this.locked = locked;
this.visible = visible;
}
}
AgentState.LOCKED = new AgentState({locked: true});
@ -2494,8 +2494,8 @@
agent: agents[0],
ln: 0,
options,
tag,
parallel,
tag,
});
this.handleConnectDelayEnd({
agent: agents[1],

View File

@ -1,5 +1,4 @@
/* eslint-disable max-lines */
/* eslint-disable sort-keys */ // Maybe later
import {
flatMap,
@ -13,19 +12,19 @@ import {
class AgentState {
constructor({
visible = false,
locked = false,
blocked = false,
highlighted = false,
group = null,
covered = false,
group = null,
highlighted = false,
locked = false,
visible = false,
} = {}) {
this.visible = visible;
this.locked = locked;
this.blocked = blocked;
this.highlighted = highlighted;
this.group = group;
this.covered = covered;
this.group = group;
this.highlighted = highlighted;
this.locked = locked;
this.visible = visible;
}
}
AgentState.LOCKED = new AgentState({locked: true});
@ -1044,8 +1043,8 @@ export default class Generator {
agent: agents[0],
ln: 0,
options,
tag,
parallel,
tag,
});
this.handleConnectDelayEnd({
agent: agents[1],

View File

@ -1,22 +1,42 @@
function checkNear(actual, expected, range) {
if(
typeof expected !== 'number' ||
typeof range !== 'number' ||
range < 0
) {
throw new Error(
'Invalid toBeNear(' + expected + ',' + range + ')'
);
}
if(typeof actual !== 'number') {
throw new Error('Expected a number, got ' + actual);
}
return Math.abs(actual - expected) <= range;
}
beforeAll(() => {
jasmine.addMatchers({
toBeNear: () => ({
compare: (actual, expected, range) => {
if(
typeof expected !== 'number' ||
typeof range !== 'number' ||
range < 0
) {
throw new Error(
'Invalid toBeNear(' + expected + ',' + range + ')'
);
if(Array.isArray(expected)) {
if(typeof actual !== 'object') {
throw new Error('Expected an array, got ' + actual);
}
if(actual.length !== expected.length) {
throw new Error(
'Expected an array of size ' + expected.length +
', got ' + actual
);
}
for(let i = 0; i < expected.length; ++ i) {
if(!checkNear(actual[i], expected[i], range)) {
return {pass: false};
}
}
return {pass: true};
}
if(typeof actual !== 'number') {
throw new Error('Expected a number, got ' + actual);
}
return {
pass: Math.abs(actual - expected) <= range,
};
return {pass: checkNear(actual, expected, range)};
},
}),
});

View File

@ -1,5 +1,3 @@
/* eslint-disable max-statements */
import ImageRegion from './ImageRegion.mjs';
import {nodejs} from '../../scripts/core/browser.mjs';
@ -99,15 +97,10 @@ describe('ImageRegion', () => {
expect(r.stepX).toEqual(1);
expect(r.stepY).toEqual(3);
expect(r.dim).toEqual(1);
expect(r.values[0]).toBeNear(0, PRECISION);
expect(r.values[1]).toBeNear(0, PRECISION);
expect(r.values[2]).toBeNear(0, PRECISION);
expect(r.values[3]).toBeNear(-1, PRECISION);
expect(r.values[4]).toBeNear(-1 / 3, PRECISION);
expect(r.values[5]).toBeNear(1, PRECISION);
expect(r.values[6]).toBeNear(-1 / 2, PRECISION);
expect(r.values[7]).toBeNear(-1 / 6, PRECISION);
expect(r.values[8]).toBeNear(1 / 2, PRECISION);
expect(r.values).toBeNear(
[0, 0, 0, -1, -1 / 3, 1, -1 / 2, -1 / 6, 1 / 2],
PRECISION
);
});
});