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