mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
fix linter errors
This commit is contained in:
+106
-105
@@ -9,6 +9,7 @@ type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray
|
||||
| Int8Array | Int16Array | Int32Array
|
||||
| Float32Array | Float64Array;
|
||||
|
||||
// we explicitly test against the looping version in the test cases
|
||||
function loopFill(array: TypedArray, value: number, start: number = 0, end?: number | undefined): TypedArray {
|
||||
if (start >= array.length) {
|
||||
return array;
|
||||
@@ -28,128 +29,128 @@ function loopFill(array: TypedArray, value: number, start: number = 0, end?: num
|
||||
return array;
|
||||
}
|
||||
|
||||
function deepEquals(a: TypedArray, b: TypedArray) {
|
||||
assert.equal(a.length, b.length);
|
||||
for (let i = 0; i < a.length; ++i) {
|
||||
assert.equal(a[i], b[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
describe('polyfill conformance tests', function(): void {
|
||||
|
||||
function deepEquals(a: TypedArray, b: TypedArray): void {
|
||||
assert.equal(a.length, b.length);
|
||||
for (let i = 0; i < a.length; ++i) {
|
||||
assert.equal(a[i], b[i]);
|
||||
}
|
||||
}
|
||||
|
||||
describe('TypedArray.fill', function(): void {
|
||||
it('should work with all typed array types', function(): void {
|
||||
const u8_1 = new Uint8Array(5);
|
||||
const u8_2 = new Uint8Array(5);
|
||||
deepEquals(fill(u8_1, 2), u8_2.fill(2));
|
||||
deepEquals(fill(u8_1, -1), u8_2.fill(-1));
|
||||
const u16_1 = new Uint16Array(5);
|
||||
const u16_2 = new Uint16Array(5);
|
||||
deepEquals(fill(u16_1, 2), u16_2.fill(2));
|
||||
deepEquals(fill(u16_1, 65535), u16_2.fill(65535));
|
||||
deepEquals(fill(u16_1, -1), u16_2.fill(-1));
|
||||
const u32_1 = new Uint32Array(5);
|
||||
const u32_2 = new Uint32Array(5);
|
||||
deepEquals(fill(u32_1, 2), u32_2.fill(2));
|
||||
deepEquals(fill(u32_1, 65537), u32_2.fill(65537));
|
||||
deepEquals(fill(u32_1, -1), u32_2.fill(-1));
|
||||
const i8_1 = new Int8Array(5);
|
||||
const i8_2 = new Int8Array(5);
|
||||
deepEquals(fill(i8_1, 2), i8_2.fill(2));
|
||||
deepEquals(fill(i8_1, -1), i8_2.fill(-1));
|
||||
const i16_1 = new Int16Array(5);
|
||||
const i16_2 = new Int16Array(5);
|
||||
deepEquals(fill(i16_1, 2), i16_2.fill(2));
|
||||
deepEquals(fill(i16_1, 65535), i16_2.fill(65535));
|
||||
deepEquals(fill(i16_1, -1), i16_2.fill(-1));
|
||||
const i32_1 = new Int32Array(5);
|
||||
const i32_2 = new Int32Array(5);
|
||||
deepEquals(fill(i32_1, 2), i32_2.fill(2));
|
||||
deepEquals(fill(i32_1, 65537), i32_2.fill(65537));
|
||||
deepEquals(fill(i32_1, -1), i32_2.fill(-1));
|
||||
const f32_1 = new Float32Array(5);
|
||||
const f32_2 = new Float32Array(5);
|
||||
deepEquals(fill(f32_1, 1.2345), f32_2.fill(1.2345));
|
||||
const f64_1 = new Float64Array(5);
|
||||
const f64_2 = new Float64Array(5);
|
||||
deepEquals(fill(f64_1, 1.2345), f64_2.fill(1.2345));
|
||||
const u8Clamped_1 = new Uint8ClampedArray(5);
|
||||
const u8Clamped_2 = new Uint8ClampedArray(5);
|
||||
deepEquals(fill(u8Clamped_1, 2), u8Clamped_2.fill(2));
|
||||
deepEquals(fill(u8Clamped_1, 257), u8Clamped_2.fill(257));
|
||||
const u81 = new Uint8Array(5);
|
||||
const u82 = new Uint8Array(5);
|
||||
deepEquals(fill(u81, 2), u82.fill(2));
|
||||
deepEquals(fill(u81, -1), u82.fill(-1));
|
||||
const u161 = new Uint16Array(5);
|
||||
const u162 = new Uint16Array(5);
|
||||
deepEquals(fill(u161, 2), u162.fill(2));
|
||||
deepEquals(fill(u161, 65535), u162.fill(65535));
|
||||
deepEquals(fill(u161, -1), u162.fill(-1));
|
||||
const u321 = new Uint32Array(5);
|
||||
const u322 = new Uint32Array(5);
|
||||
deepEquals(fill(u321, 2), u322.fill(2));
|
||||
deepEquals(fill(u321, 65537), u322.fill(65537));
|
||||
deepEquals(fill(u321, -1), u322.fill(-1));
|
||||
const i81 = new Int8Array(5);
|
||||
const i82 = new Int8Array(5);
|
||||
deepEquals(fill(i81, 2), i82.fill(2));
|
||||
deepEquals(fill(i81, -1), i82.fill(-1));
|
||||
const i161 = new Int16Array(5);
|
||||
const i162 = new Int16Array(5);
|
||||
deepEquals(fill(i161, 2), i162.fill(2));
|
||||
deepEquals(fill(i161, 65535), i162.fill(65535));
|
||||
deepEquals(fill(i161, -1), i162.fill(-1));
|
||||
const i321 = new Int32Array(5);
|
||||
const i322 = new Int32Array(5);
|
||||
deepEquals(fill(i321, 2), i322.fill(2));
|
||||
deepEquals(fill(i321, 65537), i322.fill(65537));
|
||||
deepEquals(fill(i321, -1), i322.fill(-1));
|
||||
const f321 = new Float32Array(5);
|
||||
const f322 = new Float32Array(5);
|
||||
deepEquals(fill(f321, 1.2345), f322.fill(1.2345));
|
||||
const f641 = new Float64Array(5);
|
||||
const f642 = new Float64Array(5);
|
||||
deepEquals(fill(f641, 1.2345), f642.fill(1.2345));
|
||||
const u8Clamped1 = new Uint8ClampedArray(5);
|
||||
const u8Clamped2 = new Uint8ClampedArray(5);
|
||||
deepEquals(fill(u8Clamped1, 2), u8Clamped2.fill(2));
|
||||
deepEquals(fill(u8Clamped1, 257), u8Clamped2.fill(257));
|
||||
});
|
||||
it('should work with all typed array types - explicit looping', function(): void {
|
||||
const u8_1 = new Uint8Array(5);
|
||||
const u8_2 = new Uint8Array(5);
|
||||
deepEquals(loopFill(u8_1, 2), u8_2.fill(2));
|
||||
deepEquals(loopFill(u8_1, -1), u8_2.fill(-1));
|
||||
const u16_1 = new Uint16Array(5);
|
||||
const u16_2 = new Uint16Array(5);
|
||||
deepEquals(loopFill(u16_1, 2), u16_2.fill(2));
|
||||
deepEquals(loopFill(u16_1, 65535), u16_2.fill(65535));
|
||||
deepEquals(loopFill(u16_1, -1), u16_2.fill(-1));
|
||||
const u32_1 = new Uint32Array(5);
|
||||
const u32_2 = new Uint32Array(5);
|
||||
deepEquals(loopFill(u32_1, 2), u32_2.fill(2));
|
||||
deepEquals(loopFill(u32_1, 65537), u32_2.fill(65537));
|
||||
deepEquals(loopFill(u32_1, -1), u32_2.fill(-1));
|
||||
const i8_1 = new Int8Array(5);
|
||||
const i8_2 = new Int8Array(5);
|
||||
deepEquals(loopFill(i8_1, 2), i8_2.fill(2));
|
||||
deepEquals(loopFill(i8_1, -1), i8_2.fill(-1));
|
||||
const i16_1 = new Int16Array(5);
|
||||
const i16_2 = new Int16Array(5);
|
||||
deepEquals(loopFill(i16_1, 2), i16_2.fill(2));
|
||||
deepEquals(loopFill(i16_1, 65535), i16_2.fill(65535));
|
||||
deepEquals(loopFill(i16_1, -1), i16_2.fill(-1));
|
||||
const i32_1 = new Int32Array(5);
|
||||
const i32_2 = new Int32Array(5);
|
||||
deepEquals(loopFill(i32_1, 2), i32_2.fill(2));
|
||||
deepEquals(loopFill(i32_1, 65537), i32_2.fill(65537));
|
||||
deepEquals(loopFill(i32_1, -1), i32_2.fill(-1));
|
||||
const f32_1 = new Float32Array(5);
|
||||
const f32_2 = new Float32Array(5);
|
||||
deepEquals(loopFill(f32_1, 1.2345), f32_2.fill(1.2345));
|
||||
const f64_1 = new Float64Array(5);
|
||||
const f64_2 = new Float64Array(5);
|
||||
deepEquals(loopFill(f64_1, 1.2345), f64_2.fill(1.2345));
|
||||
const u8Clamped_1 = new Uint8ClampedArray(5);
|
||||
const u8Clamped_2 = new Uint8ClampedArray(5);
|
||||
deepEquals(loopFill(u8Clamped_1, 2), u8Clamped_2.fill(2));
|
||||
deepEquals(loopFill(u8Clamped_1, 257), u8Clamped_2.fill(257));
|
||||
const u81 = new Uint8Array(5);
|
||||
const u82 = new Uint8Array(5);
|
||||
deepEquals(loopFill(u81, 2), u82.fill(2));
|
||||
deepEquals(loopFill(u81, -1), u82.fill(-1));
|
||||
const u161 = new Uint16Array(5);
|
||||
const u162 = new Uint16Array(5);
|
||||
deepEquals(loopFill(u161, 2), u162.fill(2));
|
||||
deepEquals(loopFill(u161, 65535), u162.fill(65535));
|
||||
deepEquals(loopFill(u161, -1), u162.fill(-1));
|
||||
const u321 = new Uint32Array(5);
|
||||
const u322 = new Uint32Array(5);
|
||||
deepEquals(loopFill(u321, 2), u322.fill(2));
|
||||
deepEquals(loopFill(u321, 65537), u322.fill(65537));
|
||||
deepEquals(loopFill(u321, -1), u322.fill(-1));
|
||||
const i81 = new Int8Array(5);
|
||||
const i82 = new Int8Array(5);
|
||||
deepEquals(loopFill(i81, 2), i82.fill(2));
|
||||
deepEquals(loopFill(i81, -1), i82.fill(-1));
|
||||
const i161 = new Int16Array(5);
|
||||
const i162 = new Int16Array(5);
|
||||
deepEquals(loopFill(i161, 2), i162.fill(2));
|
||||
deepEquals(loopFill(i161, 65535), i162.fill(65535));
|
||||
deepEquals(loopFill(i161, -1), i162.fill(-1));
|
||||
const i321 = new Int32Array(5);
|
||||
const i322 = new Int32Array(5);
|
||||
deepEquals(loopFill(i321, 2), i322.fill(2));
|
||||
deepEquals(loopFill(i321, 65537), i322.fill(65537));
|
||||
deepEquals(loopFill(i321, -1), i322.fill(-1));
|
||||
const f321 = new Float32Array(5);
|
||||
const f322 = new Float32Array(5);
|
||||
deepEquals(loopFill(f321, 1.2345), f322.fill(1.2345));
|
||||
const f641 = new Float64Array(5);
|
||||
const f642 = new Float64Array(5);
|
||||
deepEquals(loopFill(f641, 1.2345), f642.fill(1.2345));
|
||||
const u8Clamped1 = new Uint8ClampedArray(5);
|
||||
const u8Clamped2 = new Uint8ClampedArray(5);
|
||||
deepEquals(loopFill(u8Clamped1, 2), u8Clamped2.fill(2));
|
||||
deepEquals(loopFill(u8Clamped1, 257), u8Clamped2.fill(257));
|
||||
});
|
||||
it('start offset', function(): void {
|
||||
for (let i = -2; i < 10; ++i) {
|
||||
const u8_1 = new Uint8Array(5);
|
||||
const u8_2 = new Uint8Array(5);
|
||||
const u8_3 = new Uint8Array(5);
|
||||
deepEquals(fill(u8_1, 2, i), u8_3.fill(2, i));
|
||||
deepEquals(fill(u8_1, -1, i), u8_3.fill(-1, i));
|
||||
deepEquals(loopFill(u8_2, 2, i), u8_3.fill(2, i));
|
||||
deepEquals(loopFill(u8_2, -1, i), u8_3.fill(-1, i));
|
||||
const u81 = new Uint8Array(5);
|
||||
const u82 = new Uint8Array(5);
|
||||
const u83 = new Uint8Array(5);
|
||||
deepEquals(fill(u81, 2, i), u83.fill(2, i));
|
||||
deepEquals(fill(u81, -1, i), u83.fill(-1, i));
|
||||
deepEquals(loopFill(u82, 2, i), u83.fill(2, i));
|
||||
deepEquals(loopFill(u82, -1, i), u83.fill(-1, i));
|
||||
}
|
||||
});
|
||||
it('end offset', function(): void {
|
||||
for (let i = -2; i < 10; ++i) {
|
||||
const u8_1 = new Uint8Array(5);
|
||||
const u8_2 = new Uint8Array(5);
|
||||
const u8_3 = new Uint8Array(5);
|
||||
deepEquals(fill(u8_1, 2, 0, i), u8_3.fill(2, 0, i));
|
||||
deepEquals(fill(u8_1, -1, 0, i), u8_3.fill(-1, 0, i));
|
||||
deepEquals(loopFill(u8_2, 2, 0, i), u8_3.fill(2, 0, i));
|
||||
deepEquals(loopFill(u8_2, -1, 0, i), u8_3.fill(-1, 0, i));
|
||||
const u81 = new Uint8Array(5);
|
||||
const u82 = new Uint8Array(5);
|
||||
const u83 = new Uint8Array(5);
|
||||
deepEquals(fill(u81, 2, 0, i), u83.fill(2, 0, i));
|
||||
deepEquals(fill(u81, -1, 0, i), u83.fill(-1, 0, i));
|
||||
deepEquals(loopFill(u82, 2, 0, i), u83.fill(2, 0, i));
|
||||
deepEquals(loopFill(u82, -1, 0, i), u83.fill(-1, 0, i));
|
||||
}
|
||||
});
|
||||
it('start/end offset', function(): void {
|
||||
for (let i = -2; i < 10; ++i) {
|
||||
for (let j = -2; j < 10; ++j) {
|
||||
const u8_1 = new Uint8Array(5);
|
||||
const u8_2 = new Uint8Array(5);
|
||||
const u8_3 = new Uint8Array(5);
|
||||
deepEquals(fill(u8_1, 2, i, j), u8_3.fill(2, i, j));
|
||||
deepEquals(fill(u8_1, -1, i, j), u8_3.fill(-1, i, j));
|
||||
deepEquals(loopFill(u8_2, 2, i, j), u8_3.fill(2, i, j));
|
||||
deepEquals(loopFill(u8_2, -1, i, j), u8_3.fill(-1, i, j));
|
||||
const u81 = new Uint8Array(5);
|
||||
const u82 = new Uint8Array(5);
|
||||
const u83 = new Uint8Array(5);
|
||||
deepEquals(fill(u81, 2, i, j), u83.fill(2, i, j));
|
||||
deepEquals(fill(u81, -1, i, j), u83.fill(-1, i, j));
|
||||
deepEquals(loopFill(u82, 2, i, j), u83.fill(2, i, j));
|
||||
deepEquals(loopFill(u82, -1, i, j), u83.fill(-1, i, j));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user