-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize degree + minor refactorings + update as-pect (#12)
* optimize degree + minor refactorings + update as-pect * var -> let * updates deps + refactor tests * simplify * remove unnecessary info
- Loading branch information
Showing
6 changed files
with
4,863 additions
and
4,073 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
import { degree, mod, Rabin } from '../index' | ||
import { degree, mod, Rabin } from '../index'; | ||
|
||
NativeMath.seedRandom(2777792873); | ||
|
||
NativeMath.seedRandom(2777792873) | ||
function getRandomArbitrary(min: f64, max: f64): f64 { | ||
return NativeMath.random() * (max - min) + min; | ||
} | ||
describe("rabin degree", (): void => { | ||
it("degree should be truthy", (): void => { | ||
expect<u64>(degree(0)).toBe(-1, "42 is the meaning of life."); | ||
|
||
describe("rabin degree", () => { | ||
it("degree should be truthy", () => { | ||
expect(degree(0)).toBe(-1); | ||
}); | ||
|
||
it("mod should be truthy", (): void => { | ||
expect<u64>(mod((<u64>0) << 0x3DA3358B4DC173, 0x3DA3358B4DC173)).toBe(0, "42 is the meaning of life."); | ||
it("mod should be truthy", () => { | ||
expect(mod((<u64>0) << 0x3DA3358B4DC173, 0x3DA3358B4DC173)).toBe(0); | ||
}); | ||
|
||
it("fingerprint", (): void => { | ||
let r = new Rabin(124, 1 * 8, 2 * 8, 64) | ||
it("fingerprint", () => { | ||
let r = new Rabin(124, 1 * 8, 2 * 8, 64); | ||
let file = new Uint8Array(1024); | ||
for (let i = 0; i < file.length; i++) { | ||
file[i] = <u32>getRandomArbitrary(128, 8888) | ||
file[i] = <u32>getRandomArbitrary(128, 8888); | ||
} | ||
const out = r.fingerprint(file, new Int32Array(file.length/128)) | ||
const out = r.fingerprint(file, new Int32Array(file.length / 128)); | ||
|
||
log(out) | ||
const expected = new Int32Array(1) | ||
expected[0] = 16 | ||
expect(out[0]).toBe(expected[0]) | ||
log(out); | ||
const expected = new Int32Array(1); | ||
expected[0] = 16; | ||
expect(out[0]).toBe(expected[0]); | ||
}); | ||
|
||
}); |
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
Oops, something went wrong.