encoder_test.dart
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import 'package:flutter_math_fork/ast.dart';
import 'package:flutter_math_fork/src/encoder/encoder.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_math_fork/src/encoder/tex/encoder.dart';
import 'recode.dart';
void main() {
group('EquationRowEncoderResult', () {
test('empty row', () {
final result = EquationRowTexEncodeResult(<dynamic>[]);
expect(result.stringify(TexEncodeConf.mathConf), '{}');
expect(result.stringify(TexEncodeConf.mathParamConf), '');
});
test('normal row', () {
final result = EquationRowTexEncodeResult(<dynamic>[
'a',
StaticEncodeResult('b'),
SymbolNode(symbol: 'c'),
EquationRowNode.empty(),
]);
expect(result.stringify(TexEncodeConf.mathConf), '{abc{}}');
expect(result.stringify(TexEncodeConf.mathParamConf), 'abc{}');
});
test('symbol contanetation', () {
const testStrings = [
'i\\pi x',
'i\\pi\\xi',
];
for (final testString in testStrings) {
expect(recodeTex(testString), testString);
}
});
});
group('TexCommandEncoderResult', () {
test('basic spec lookup', () {
final result =
TexCommandEncodeResult(command: '\\frac', args: <dynamic>[]);
expect(result.numArgs, 2);
expect(result.numOptionalArgs, 0);
expect(result.argModes, [null, null]);
});
test('empty math param', () {
final result = TexCommandEncodeResult(
command: '\\frac',
args: <dynamic>[EquationRowNode.empty(), EquationRowNode.empty()]);
expect(result.stringify(TexEncodeConf.mathConf), '\\frac{}{}');
});
test('single char math param', () {
final result =
TexCommandEncodeResult(command: '\\frac', args: <dynamic>['1', '2']);
expect(result.stringify(TexEncodeConf.mathConf), '\\frac{1}{2}');
});
});
}