Fixing LaTeX tests, adding new sexy natural language method spy, started testing Promises.
This commit is contained in:
parent
a85a4721e3
commit
34caf20593
12 changed files with 511 additions and 35 deletions
|
@ -530,14 +530,14 @@ class CanvasAPI extends Module {
|
|||
if(this.#redrawCount === currentRedrawCount)
|
||||
callback(imgData)
|
||||
else
|
||||
console.log("1Discard render of", imgData.source, this.#redrawCount, currentRedrawCount)
|
||||
console.log("1. Discard render of", imgData.source, this.#redrawCount, currentRedrawCount)
|
||||
})
|
||||
} else {
|
||||
// Callback directly
|
||||
if(this.#redrawCount === currentRedrawCount)
|
||||
callback(imgData)
|
||||
else
|
||||
console.log("2Discard render of", imgData.source, this.#redrawCount, currentRedrawCount)
|
||||
console.log("2. Discard render of", imgData.source, this.#redrawCount, currentRedrawCount)
|
||||
}
|
||||
}
|
||||
const prerendered = Latex.findPrerendered(ltxText, this.textsize, color)
|
||||
|
|
|
@ -23,6 +23,10 @@ const PIXEL = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQAAAAA3bvkkAAAACklEQVR4AWNgAAAAA
|
|||
export class MockLatex {
|
||||
constructor() {
|
||||
}
|
||||
|
||||
get supportsAsyncRender() {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple string hash.
|
||||
|
@ -55,13 +59,23 @@ export class MockLatex {
|
|||
return `${TMP}/${name}.png`
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} markup - LaTeX markup to render
|
||||
* @param {number} fontSize - Font size (in pt) to render
|
||||
* @param {string} color - Color of the text to render
|
||||
* @returns {Promise<string>} - Comma separated data of the image (source, width, height)
|
||||
*/
|
||||
async renderAsync(markup, fontSize, color) {
|
||||
return this.renderSync(markup, fontSize, color)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} markup - LaTeX markup to render
|
||||
* @param {number} fontSize - Font size (in pt) to render
|
||||
* @param {string} color - Color of the text to render
|
||||
* @returns {string} - Comma separated data of the image (source, width, height)
|
||||
*/
|
||||
render(markup, fontSize, color) {
|
||||
renderSync(markup, fontSize, color) {
|
||||
const file = this.__getFileName(markup, fontSize, color)
|
||||
writeFileSync(file, PIXEL, "base64")
|
||||
return `${file},1,1`
|
||||
|
@ -87,4 +101,4 @@ export class MockLatex {
|
|||
checkLatexInstallation() {
|
||||
return true // We're not *actually* doing any latex.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue