mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 15:48:06 +02:00
Move additional worker-thread only functions from src/shared/util.js
and into a src/core/core_utils.js
instead
This moves the `log2`, `readInt8`, `readUint16`, `readUint32`, and `isSpace` functions since they are only used in the worker-thread.
This commit is contained in:
parent
794744c3fa
commit
3f031f69c2
12 changed files with 82 additions and 99 deletions
|
@ -16,6 +16,8 @@
|
|||
import { Dict, Ref } from "../../src/core/primitives.js";
|
||||
import {
|
||||
getInheritableProperty,
|
||||
isSpace,
|
||||
log2,
|
||||
toRomanNumerals,
|
||||
} from "../../src/core/core_utils.js";
|
||||
import { XRefMock } from "./test_utils.js";
|
||||
|
@ -180,4 +182,33 @@ describe("core_utils", function() {
|
|||
expect(toRomanNumerals(2019, /* lowercase = */ true)).toEqual("mmxix");
|
||||
});
|
||||
});
|
||||
|
||||
describe("log2", function() {
|
||||
it("handles values smaller than/equal to zero", function() {
|
||||
expect(log2(0)).toEqual(0);
|
||||
expect(log2(-1)).toEqual(0);
|
||||
});
|
||||
|
||||
it("handles values larger than zero", function() {
|
||||
expect(log2(1)).toEqual(0);
|
||||
expect(log2(2)).toEqual(1);
|
||||
expect(log2(3)).toEqual(2);
|
||||
expect(log2(3.14)).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isSpace", function() {
|
||||
it("handles space characters", function() {
|
||||
expect(isSpace(0x20)).toEqual(true);
|
||||
expect(isSpace(0x09)).toEqual(true);
|
||||
expect(isSpace(0x0d)).toEqual(true);
|
||||
expect(isSpace(0x0a)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-space characters", function() {
|
||||
expect(isSpace(0x0b)).toEqual(false);
|
||||
expect(isSpace(null)).toEqual(false);
|
||||
expect(isSpace(undefined)).toEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,9 +22,7 @@ import {
|
|||
isEmptyObj,
|
||||
isNum,
|
||||
isSameOrigin,
|
||||
isSpace,
|
||||
isString,
|
||||
log2,
|
||||
removeNullCharacters,
|
||||
string32,
|
||||
stringToBytes,
|
||||
|
@ -118,21 +116,6 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("isSpace", function() {
|
||||
it("handles space characters", function() {
|
||||
expect(isSpace(0x20)).toEqual(true);
|
||||
expect(isSpace(0x09)).toEqual(true);
|
||||
expect(isSpace(0x0d)).toEqual(true);
|
||||
expect(isSpace(0x0a)).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles non-space characters", function() {
|
||||
expect(isSpace(0x0b)).toEqual(false);
|
||||
expect(isSpace(null)).toEqual(false);
|
||||
expect(isSpace(undefined)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isString", function() {
|
||||
it("handles string values", function() {
|
||||
expect(isString("foo")).toEqual(true);
|
||||
|
@ -147,20 +130,6 @@ describe("util", function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe("log2", function() {
|
||||
it("handles values smaller than/equal to zero", function() {
|
||||
expect(log2(0)).toEqual(0);
|
||||
expect(log2(-1)).toEqual(0);
|
||||
});
|
||||
|
||||
it("handles values larger than zero", function() {
|
||||
expect(log2(1)).toEqual(0);
|
||||
expect(log2(2)).toEqual(1);
|
||||
expect(log2(3)).toEqual(2);
|
||||
expect(log2(3.14)).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("string32", function() {
|
||||
it("converts unsigned 32-bit integers to strings", function() {
|
||||
expect(string32(0x74727565)).toEqual("true");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue