Skip to content

Commit 6dfec09

Browse files
authored
Merge pull request #1148 from mathjax/tests/complete_base
Complete base tests as much as possible
2 parents dfc65e2 + a431b7b commit 6dfec09

5 files changed

Lines changed: 9330 additions & 3395 deletions

File tree

testsuite/src/setupTex.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import {MmlNode} from '#js/core/MmlTree/MmlNode';
1111
import {tmpJsonFile} from './constants';
1212
import * as fs from 'fs';
1313

14-
let convert: (tex: string) => string;
14+
let convert: (tex: string, display: boolean) => string;
1515

1616
export function setupTex(packages: string[] = ['base'], options = {}) {
1717
const parserOptions = Object.assign({}, {packages: packages}, options);
1818
const tex = new TeX(parserOptions);
1919
const html = new HTMLDocument('', liteAdaptor(), {InputJax: tex});
2020
const visitor = new SerializedMmlVisitor();
2121
const toMathML = ((node: MmlNode) => visitor.visitTree(node));
22-
convert = (expr: string) =>
23-
toMathML(html.convert(expr, {display: true, end: STATE.CONVERT}));
22+
convert = (expr: string, display: boolean) =>
23+
toMathML(html.convert(expr, {display: display, end: STATE.CONVERT}));
2424
}
2525

2626
import {SVG} from '#js/output/svg';
@@ -31,12 +31,12 @@ export function setupTexWithOutput(packages: string[] = ['base'], options = {})
3131
const html = new HTMLDocument('', liteAdaptor(), {InputJax: tex, OutputJax: new SVG()});
3232
const visitor = new SerializedMmlVisitor();
3333
const toMathML = ((node: MmlNode) => visitor.visitTree(node));
34-
convert = (expr: string) =>
35-
toMathML(html.convert(expr, {display: true, end: STATE.CONVERT}));
34+
convert = (expr: string, display: boolean) =>
35+
toMathML(html.convert(expr, {display: display, end: STATE.CONVERT}));
3636
}
3737

38-
export function tex2mml(tex: string) {
39-
return convert(tex);
38+
export function tex2mml(tex: string, display: boolean = true) {
39+
return convert(tex, display);
4040
};
4141

4242
// Machinery for measuring the completeness of our macro tests.
@@ -133,7 +133,7 @@ export function getTokens(configuration: string) {
133133
// A prototype extension for the macro table lookups.
134134
AbstractParseMap.prototype.lookup = function(token: string) {
135135
const result = this.map.get(token);
136-
if (result && !token.match(/^\s$/)) {
136+
if (result) {
137137
addToken(this.name, token);
138138
}
139139
return result;

testsuite/tests/input/tex/Ams.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,16 @@ describe('Ams', () => {
576576
<mi data-mjx-texclass="OP" mathvariant="normal" data-latex="\\operatorname{R}">R</mi>
577577
<mo data-mjx-texclass="NONE">&#x2061;</mo>
578578
<mi data-latex="b">b</mi>
579+
</math>`
580+
));
581+
it('Operatorname', () =>
582+
toXmlMatch(
583+
tex2mml('a\\operatorname{xyz}b'),
584+
`<math xmlns=\"http://www.w3.org/1998/Math/MathML\" data-latex=\"a\\operatorname{xyz}b\" display=\"block\">
585+
<mi data-latex=\"a\">a</mi>
586+
<mi data-latex=\"\\operatorname{xyz}\">xyz</mi>
587+
<mo data-mjx-texclass=\"NONE\">&#x2061;</mo>
588+
<mi data-latex=\"b\">b</mi>
579589
</math>`
580590
));
581591
});

0 commit comments

Comments
 (0)