-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add more util tests. Add affine tests
- Loading branch information
Showing
3 changed files
with
196 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Everything except undefined, string, Uint8Array | ||
const TYPE_TEST_BASE = [ | ||
null, | ||
[1, 2, 3], | ||
{ a: 1, b: 2, c: 3 }, | ||
NaN, | ||
Infinity, | ||
-Infinity, | ||
0.1234, | ||
1.0000000000001, | ||
10e9999, | ||
new Uint32Array([1, 2, 3]), | ||
100n, | ||
new Set([1, 2, 3]), | ||
new Map([['aa', 'bb']]), | ||
new Uint8ClampedArray([1, 2, 3]), | ||
new Int16Array([1, 2, 3]), | ||
new Float32Array([1]), | ||
new BigInt64Array([1n, 2n, 3n]), | ||
new ArrayBuffer(100), | ||
new DataView(new ArrayBuffer(100)), | ||
{ constructor: { name: 'Uint8Array' }, length: '1e30' }, | ||
() => {}, | ||
async () => {}, | ||
class Test {}, | ||
Symbol.for('a'), | ||
new Proxy(new Uint8Array(), { | ||
get(t, p, r) { | ||
if (p === 'isProxy') return true; | ||
return Reflect.get(t, p, r); | ||
}, | ||
}), | ||
]; | ||
|
||
const TYPE_TEST_OPT = [ | ||
'', | ||
new Uint8Array(), | ||
new (class Test {})(), | ||
class Test {}, | ||
() => {}, | ||
0, | ||
0.1234, | ||
NaN, | ||
null, | ||
]; | ||
|
||
const TYPE_TEST_NOT_BOOL = [false, true]; | ||
const TYPE_TEST_NOT_BYTES = ['', 'test', '1', new Uint8Array([]), new Uint8Array([1, 2, 3])]; | ||
const TYPE_TEST_NOT_HEX = [ | ||
'0xbe', | ||
' 1 2 3 4 5', | ||
'010203040x', | ||
'abcdefgh', | ||
'1 2 3 4 5 ', | ||
'bee', | ||
new String('1234'), | ||
]; | ||
const TYPE_TEST_NOT_INT = [-0.0, 0, 1]; | ||
|
||
export const TYPE_TEST = { | ||
bytes: TYPE_TEST_BASE.concat(TYPE_TEST_NOT_INT, TYPE_TEST_NOT_BOOL), | ||
hex: TYPE_TEST_BASE.concat(TYPE_TEST_NOT_INT, TYPE_TEST_NOT_BOOL, TYPE_TEST_NOT_HEX), | ||
}; | ||
|
||
export function repr(item) { | ||
if (item && item.isProxy) return '[proxy]'; | ||
if (typeof item === 'symbol') return item.toString(); | ||
return `${item}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters