Merge pull request #14432 from Snuffleupagus/update-packages
Update packages and translations
This commit is contained in:
commit
236c8d4786
@ -129,7 +129,7 @@ print_progress_close=Hætta við
|
||||
# Tooltips and alt text for side panel toolbar buttons
|
||||
# (the _label strings are alt text for the buttons, the .title strings are
|
||||
# tooltips)
|
||||
toggle_sidebar.title=Víxla hliðslá
|
||||
toggle_sidebar.title=Víxla hliðarslá af/á
|
||||
toggle_sidebar_label=Víxla hliðslá
|
||||
document_outline.title=Sýna yfirlit skjals (tvísmelltu til að opna/loka öllum hlutum)
|
||||
document_outline_label=Efnisskipan skjals
|
||||
@ -140,6 +140,7 @@ thumbs_label=Smámyndir
|
||||
findbar.title=Leita í skjali
|
||||
findbar_label=Leita
|
||||
|
||||
# LOCALIZATION NOTE (page_landmark): "{{page}}" will be replaced by the page number.
|
||||
# Thumbnails panel item (tooltip and alt text for images)
|
||||
# LOCALIZATION NOTE (thumb_page_title): "{{page}}" will be replaced by the page
|
||||
# number.
|
||||
@ -211,11 +212,15 @@ page_scale_actual=Raunstærð
|
||||
# numerical scale value.
|
||||
page_scale_percent={{scale}}%
|
||||
|
||||
# Loading indicator messages
|
||||
loading_error=Villa kom upp við að hlaða inn PDF.
|
||||
invalid_file_error=Ógild eða skemmd PDF skrá.
|
||||
missing_file_error=Vantar PDF skrá.
|
||||
unexpected_response_error=Óvænt svar frá netþjóni.
|
||||
|
||||
# LOCALIZATION NOTE (annotation_date_string): "{{date}}" and "{{time}}" will be
|
||||
# replaced by the modification date, and time, of the annotation.
|
||||
|
||||
# LOCALIZATION NOTE (text_annotation_type.alt): This is used as a tooltip.
|
||||
# "{{type}}" will be replaced with an annotation type from a list defined in
|
||||
# the PDF spec (32000-1:2008 Table 169 – Annotation types).
|
||||
|
@ -189,7 +189,7 @@ find_match_count_limit[two]=Wiyncyj jak {{limit}}, co pasujōm
|
||||
find_match_count_limit[few]=Wiyncyj jak {{limit}}, co pasujōm
|
||||
find_match_count_limit[many]=Wiyncyj jak {{limit}}, co pasujōm
|
||||
find_match_count_limit[other]=Wiyncyj jak {{limit}}, co pasujōm
|
||||
find_not_found=Fraza niy ma znodniynto
|
||||
find_not_found=Fraza niy znaleziōno
|
||||
|
||||
# Error panel labels
|
||||
error_more_info=Wiyncyj informacyji
|
||||
@ -242,5 +242,3 @@ password_cancel=Pociep
|
||||
printing_not_supported=Pozōr: Ta przeglōndarka niy cołkiym ôbsuguje durk.
|
||||
printing_not_ready=Pozōr: Tyn PDF niy ma za tela zaladowany do durku.
|
||||
web_fonts_disabled=Necowe fōnty sōm zastawiōne: niy idzie użyć wkludzōnych fōntōw PDF.
|
||||
# LOCALIZATION NOTE (unsupported_feature_signatures): Should contain the same
|
||||
# exact string as in the `chrome.properties` file.
|
||||
|
2550
package-lock.json
generated
2550
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,45 +1,45 @@
|
||||
{
|
||||
"name": "pdf.js",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.16.5",
|
||||
"@babel/plugin-transform-runtime": "^7.16.5",
|
||||
"@babel/preset-env": "^7.16.5",
|
||||
"@babel/runtime": "^7.16.5",
|
||||
"@babel/core": "^7.16.7",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.16.7",
|
||||
"@babel/plugin-transform-runtime": "^7.16.7",
|
||||
"@babel/preset-env": "^7.16.7",
|
||||
"@babel/runtime": "^7.16.7",
|
||||
"@javascript-obfuscator/escodegen": "2.2.2",
|
||||
"acorn": "^8.6.0",
|
||||
"autoprefixer": "^10.4.0",
|
||||
"acorn": "^8.7.0",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"babel-loader": "^8.2.3",
|
||||
"canvas": "^2.8.0",
|
||||
"core-js": "^3.20.1",
|
||||
"core-js": "^3.20.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"dommatrix": "^0.0.24",
|
||||
"es-module-shims": "^1.4.1",
|
||||
"eslint": "^8.5.0",
|
||||
"eslint": "^8.6.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-fetch-options": "^0.0.5",
|
||||
"eslint-plugin-html": "^6.2.0",
|
||||
"eslint-plugin-import": "^2.25.3",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-json": "^3.1.0",
|
||||
"eslint-plugin-mozilla": "^2.11.1",
|
||||
"eslint-plugin-no-unsanitized": "^4.0.1",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-sort-exports": "^0.6.0",
|
||||
"eslint-plugin-unicorn": "^39.0.0",
|
||||
"eslint-plugin-unicorn": "^40.0.0",
|
||||
"globals": "^13.12.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-zip": "^5.1.0",
|
||||
"jasmine": "^3.10.0",
|
||||
"jasmine": "^4.0.1",
|
||||
"jsdoc": "^3.6.7",
|
||||
"jstransformer-markdown-it": "^2.1.0",
|
||||
"merge-stream": "^2.0.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"needle": "^3.0.0",
|
||||
"postcss": "^8.4.5",
|
||||
"postcss-calc": "^8.0.0",
|
||||
"postcss-calc": "^8.2.0",
|
||||
"prettier": "^2.5.1",
|
||||
"puppeteer": "^13.0.1",
|
||||
"rimraf": "^3.0.2",
|
||||
|
@ -19,6 +19,7 @@ const Jasmine = require("jasmine");
|
||||
|
||||
async function runTests(results) {
|
||||
const jasmine = new Jasmine();
|
||||
jasmine.exitOnCompletion = false;
|
||||
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
|
||||
jasmine.loadConfig({
|
||||
@ -49,10 +50,7 @@ async function runTests(results) {
|
||||
suiteStarted(result) {},
|
||||
});
|
||||
|
||||
return new Promise(resolve => {
|
||||
jasmine.onComplete(resolve);
|
||||
jasmine.execute();
|
||||
});
|
||||
return jasmine.execute();
|
||||
}
|
||||
|
||||
exports.runTests = runTests;
|
||||
|
@ -21,52 +21,6 @@ import { PostScriptLexer, PostScriptParser } from "../../src/core/ps_parser.js";
|
||||
import { StringStream } from "../../src/core/stream.js";
|
||||
|
||||
describe("function", function () {
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toMatchArray(util, customEqualityTesters) {
|
||||
return {
|
||||
compare(actual, expected) {
|
||||
const result = {};
|
||||
if (actual.length !== expected.length) {
|
||||
result.pass = false;
|
||||
result.message =
|
||||
"Array length: " +
|
||||
actual.length +
|
||||
", expected: " +
|
||||
expected.length;
|
||||
return result;
|
||||
}
|
||||
result.pass = true;
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
const a = actual[i],
|
||||
b = expected[i];
|
||||
if (Array.isArray(b)) {
|
||||
if (a.length !== b.length) {
|
||||
result.pass = false;
|
||||
break;
|
||||
}
|
||||
for (let j = 0; j < a.length; j++) {
|
||||
const suba = a[j],
|
||||
subb = b[j];
|
||||
if (suba !== subb) {
|
||||
result.pass = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (a !== b) {
|
||||
result.pass = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
describe("PostScriptParser", function () {
|
||||
function parse(program) {
|
||||
const stream = new StringStream(program);
|
||||
@ -81,34 +35,34 @@ describe("function", function () {
|
||||
const number = 999;
|
||||
const program = parse("{ " + number + " }");
|
||||
const expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("parses negative numbers", function () {
|
||||
const number = -999;
|
||||
const program = parse("{ " + number + " }");
|
||||
const expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("parses negative floats", function () {
|
||||
const number = 3.3;
|
||||
const program = parse("{ " + number + " }");
|
||||
const expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("parses operators", function () {
|
||||
const program = parse("{ sub }");
|
||||
const expectedProgram = ["sub"];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("parses if statements", function () {
|
||||
const program = parse("{ { 99 } if }");
|
||||
const expectedProgram = [3, "jz", 99];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("parses ifelse statements", function () {
|
||||
const program = parse("{ { 99 } { 44 } ifelse }");
|
||||
const expectedProgram = [5, "jz", 99, 6, "j", 44];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
it("handles missing brackets", function () {
|
||||
expect(function () {
|
||||
@ -119,7 +73,7 @@ describe("function", function () {
|
||||
const number = 3.3;
|
||||
const program = parse("{ " + number + " }#");
|
||||
const expectedProgram = [number];
|
||||
expect(program).toMatchArray(expectedProgram);
|
||||
expect(program).toEqual(expectedProgram);
|
||||
});
|
||||
});
|
||||
|
||||
@ -136,313 +90,313 @@ describe("function", function () {
|
||||
it("pushes stack", function () {
|
||||
const stack = evaluate("{ 99 }");
|
||||
const expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles if with true", function () {
|
||||
const stack = evaluate("{ 1 {99} if }");
|
||||
const expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles if with false", function () {
|
||||
const stack = evaluate("{ 0 {99} if }");
|
||||
const expectedStack = [];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles ifelse with true", function () {
|
||||
const stack = evaluate("{ 1 {99} {77} ifelse }");
|
||||
const expectedStack = [99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles ifelse with false", function () {
|
||||
const stack = evaluate("{ 0 {99} {77} ifelse }");
|
||||
const expectedStack = [77];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles nested if", function () {
|
||||
const stack = evaluate("{ 1 {1 {77} if} if }");
|
||||
const expectedStack = [77];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
|
||||
it("abs", function () {
|
||||
const stack = evaluate("{ -2 abs }");
|
||||
const expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("adds", function () {
|
||||
const stack = evaluate("{ 1 2 add }");
|
||||
const expectedStack = [3];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("boolean and", function () {
|
||||
const stack = evaluate("{ true false and }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("bitwise and", function () {
|
||||
const stack = evaluate("{ 254 1 and }");
|
||||
const expectedStack = [254 & 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the inverse tangent of a number", function () {
|
||||
const stack = evaluate("{ 90 atan }");
|
||||
const expectedStack = [Math.atan(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles bitshifting ", function () {
|
||||
const stack = evaluate("{ 50 2 bitshift }");
|
||||
const expectedStack = [200];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the ceiling value", function () {
|
||||
const stack = evaluate("{ 9.9 ceiling }");
|
||||
const expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("copies", function () {
|
||||
const stack = evaluate("{ 99 98 2 copy }");
|
||||
const expectedStack = [99, 98, 99, 98];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the cosine of a number", function () {
|
||||
const stack = evaluate("{ 90 cos }");
|
||||
const expectedStack = [Math.cos(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("converts to int", function () {
|
||||
const stack = evaluate("{ 9.9 cvi }");
|
||||
const expectedStack = [9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("converts negatives to int", function () {
|
||||
const stack = evaluate("{ -9.9 cvi }");
|
||||
const expectedStack = [-9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("converts to real", function () {
|
||||
const stack = evaluate("{ 55.34 cvr }");
|
||||
const expectedStack = [55.34];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("divides", function () {
|
||||
const stack = evaluate("{ 6 5 div }");
|
||||
const expectedStack = [1.2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("maps division by zero to infinity", function () {
|
||||
const stack = evaluate("{ 6 0 div }");
|
||||
const expectedStack = [Infinity];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("duplicates", function () {
|
||||
const stack = evaluate("{ 99 dup }");
|
||||
const expectedStack = [99, 99];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("accepts an equality", function () {
|
||||
const stack = evaluate("{ 9 9 eq }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects an inequality", function () {
|
||||
const stack = evaluate("{ 9 8 eq }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("exchanges", function () {
|
||||
const stack = evaluate("{ 44 99 exch }");
|
||||
const expectedStack = [99, 44];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles exponentiation", function () {
|
||||
const stack = evaluate("{ 10 2 exp }");
|
||||
const expectedStack = [100];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("pushes false onto the stack", function () {
|
||||
const stack = evaluate("{ false }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the floor value", function () {
|
||||
const stack = evaluate("{ 9.9 floor }");
|
||||
const expectedStack = [9];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles greater than or equal to", function () {
|
||||
const stack = evaluate("{ 10 9 ge }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects less than for greater than or equal to", function () {
|
||||
const stack = evaluate("{ 8 9 ge }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles greater than", function () {
|
||||
const stack = evaluate("{ 10 9 gt }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects less than or equal for greater than", function () {
|
||||
const stack = evaluate("{ 9 9 gt }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("divides to integer", function () {
|
||||
const stack = evaluate("{ 2 3 idiv }");
|
||||
const expectedStack = [0];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("divides to negative integer", function () {
|
||||
const stack = evaluate("{ -2 3 idiv }");
|
||||
const expectedStack = [0];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("duplicates index", function () {
|
||||
const stack = evaluate("{ 4 3 2 1 2 index }");
|
||||
const expectedStack = [4, 3, 2, 1, 3];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles less than or equal to", function () {
|
||||
const stack = evaluate("{ 9 10 le }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects greater than for less than or equal to", function () {
|
||||
const stack = evaluate("{ 10 9 le }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the natural logarithm", function () {
|
||||
const stack = evaluate("{ 10 ln }");
|
||||
const expectedStack = [Math.log(10)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the base 10 logarithm", function () {
|
||||
const stack = evaluate("{ 100 log }");
|
||||
const expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("handles less than", function () {
|
||||
const stack = evaluate("{ 9 10 lt }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects greater than or equal to for less than", function () {
|
||||
const stack = evaluate("{ 10 9 lt }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("performs the modulo operation", function () {
|
||||
const stack = evaluate("{ 4 3 mod }");
|
||||
const expectedStack = [1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("multiplies two numbers (positive result)", function () {
|
||||
const stack = evaluate("{ 9 8 mul }");
|
||||
const expectedStack = [72];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("multiplies two numbers (negative result)", function () {
|
||||
const stack = evaluate("{ 9 -8 mul }");
|
||||
const expectedStack = [-72];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("accepts an inequality", function () {
|
||||
const stack = evaluate("{ 9 8 ne }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rejects an equality", function () {
|
||||
const stack = evaluate("{ 9 9 ne }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("negates", function () {
|
||||
const stack = evaluate("{ 4.5 neg }");
|
||||
const expectedStack = [-4.5];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("boolean not", function () {
|
||||
const stack = evaluate("{ true not }");
|
||||
const expectedStack = [false];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("bitwise not", function () {
|
||||
const stack = evaluate("{ 12 not }");
|
||||
const expectedStack = [-13];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("boolean or", function () {
|
||||
const stack = evaluate("{ true false or }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("bitwise or", function () {
|
||||
const stack = evaluate("{ 254 1 or }");
|
||||
const expectedStack = [254 | 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("pops stack", function () {
|
||||
const stack = evaluate("{ 1 2 pop }");
|
||||
const expectedStack = [1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rolls stack right", function () {
|
||||
const stack = evaluate("{ 1 3 2 2 4 1 roll }");
|
||||
const expectedStack = [2, 1, 3, 2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rolls stack left", function () {
|
||||
const stack = evaluate("{ 1 3 2 2 4 -1 roll }");
|
||||
const expectedStack = [3, 2, 2, 1];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("rounds a number", function () {
|
||||
const stack = evaluate("{ 9.52 round }");
|
||||
const expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates the sine of a number", function () {
|
||||
const stack = evaluate("{ 90 sin }");
|
||||
const expectedStack = [Math.sin(90)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates a square root (integer)", function () {
|
||||
const stack = evaluate("{ 100 sqrt }");
|
||||
const expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates a square root (float)", function () {
|
||||
const stack = evaluate("{ 99 sqrt }");
|
||||
const expectedStack = [Math.sqrt(99)];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("subtracts (positive result)", function () {
|
||||
const stack = evaluate("{ 6 4 sub }");
|
||||
const expectedStack = [2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("subtracts (negative result)", function () {
|
||||
const stack = evaluate("{ 4 6 sub }");
|
||||
const expectedStack = [-2];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("pushes true onto the stack", function () {
|
||||
const stack = evaluate("{ true }");
|
||||
const expectedStack = [true];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("truncates a number", function () {
|
||||
const stack = evaluate("{ 35.004 truncate }");
|
||||
const expectedStack = [35];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
it("calculates an exclusive or value", function () {
|
||||
const stack = evaluate("{ 3 9 xor }");
|
||||
const expectedStack = [10];
|
||||
expect(stack).toMatchArray(expectedStack);
|
||||
expect(stack).toEqual(expectedStack);
|
||||
});
|
||||
});
|
||||
|
||||
@ -465,9 +419,7 @@ describe("function", function () {
|
||||
for (let i = 0; i < samples.length; i++) {
|
||||
const out = new Float32Array(samples[i].output.length);
|
||||
fn(samples[i].input, 0, out, 0);
|
||||
expect(Array.prototype.slice.call(out, 0)).toMatchArray(
|
||||
samples[i].output
|
||||
);
|
||||
expect(Array.prototype.slice.call(out, 0)).toEqual(samples[i].output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,36 +18,6 @@ import { PredictorStream } from "../../src/core/predictor_stream.js";
|
||||
import { Stream } from "../../src/core/stream.js";
|
||||
|
||||
describe("stream", function () {
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toMatchTypedArray(util, customEqualityTesters) {
|
||||
return {
|
||||
compare(actual, expected) {
|
||||
const result = {};
|
||||
if (actual.length !== expected.length) {
|
||||
result.pass = false;
|
||||
result.message =
|
||||
"Array length: " +
|
||||
actual.length +
|
||||
", expected: " +
|
||||
expected.length;
|
||||
return result;
|
||||
}
|
||||
result.pass = true;
|
||||
for (let i = 0, ii = expected.length; i < ii; i++) {
|
||||
const a = actual[i],
|
||||
b = expected[i];
|
||||
if (a !== b) {
|
||||
result.pass = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
});
|
||||
describe("PredictorStream", function () {
|
||||
it("should decode simple predictor data", function () {
|
||||
const dict = new Dict();
|
||||
@ -65,9 +35,7 @@ describe("stream", function () {
|
||||
const predictor = new PredictorStream(input, /* length = */ 9, dict);
|
||||
const result = predictor.getBytes(6);
|
||||
|
||||
expect(result).toMatchTypedArray(
|
||||
new Uint8Array([100, 3, 101, 2, 102, 1])
|
||||
);
|
||||
expect(result).toEqual(new Uint8Array([100, 3, 101, 2, 102, 1]));
|
||||
|
||||
predictor.reset();
|
||||
const clampedResult = predictor.getBytes(6, /* forceClamped = */ true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user