-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathtest_format.py
946 lines (905 loc) · 55.7 KB
/
test_format.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
import os
from test.helper import check_evaluation
from mathics.core.symbols import Symbol
from mathics.session import MathicsSession
session = MathicsSession()
# from mathics.builtin.base import BoxConstruct, Predefined
import pytest
#
# Aim of the tests:
#
# In these tests, we check that the current behavior of makeboxes does not change
# without noticing that it could affect compatibility with WL and with
# mathics-django. Also looking at some issues in the current behavior regarding
# the WL standard (for instance, how to represent $a^(b/c)$) and the Mathics
# own implementation (BoxError raising in some simple conditions).
# These test should be updated as we fix pending issues.
# Set this to 0 in case mathml tests must be considered xfail. With True, ensures the
# compatibility with the current mathics-django branch.
MATHML_STRICT = (
int(os.environ.get("MATHML_STRICT", "1")) == 1
) # To set to False, set ENV var to "0"
# This dict contains all the tests. The main key is an expression to be evaluated and
# formatted. For each expression, we have a base message, and tests for each output box
# mode ("text", "mathml" and "tex"). On each mode, we have a dict for the different formats.
# If the value associated with a format is a string and the message does not
# finish with "- Fragile!", the test is considered mandatory,
# (not xfail), and the assert message is the base message.
# If there is a tuple instead, the test is against the first element of the tuple,
# and allowed to fail. In this case, the assert message is the
# concatenation of the base message and the second element of the tuple.
all_test = {
# Checking basic formats for atoms
"-4": {
"msg": "An Integer",
"text": {
"System`StandardForm": "-4",
"System`TraditionalForm": "-4",
"System`InputForm": "-4",
"System`OutputForm": "-4",
},
"mathml": {
"System`StandardForm": "<mn>-4</mn>",
"System`TraditionalForm": "<mn>-4</mn>",
"System`InputForm": "<mtext>-4</mtext>",
"System`OutputForm": "<mn>-4</mn>",
},
"latex": {
"System`StandardForm": "-4",
"System`TraditionalForm": "-4",
"System`InputForm": "-4",
"System`OutputForm": "-4",
},
},
"-4.32": {
"msg": "A MachineReal number",
"text": {
"System`StandardForm": "-4.32",
"System`TraditionalForm": "-4.32",
"System`InputForm": "-4.32",
"System`OutputForm": "-4.32",
},
# In WMA, depending on the requested form, numbers in MathMLForm is
# tagged with <mn> or <mtext>. In particular, for InputForm and FullForm
# the choice is <mtext>
"mathml": {
"System`StandardForm": "<mn>-4.32</mn>",
"System`TraditionalForm": "<mn>-4.32</mn>",
"System`InputForm": "<mtext>-4.32</mtext>",
"System`OutputForm": "<mn>-4.32</mn>",
},
"latex": {
"System`StandardForm": "-4.32",
"System`TraditionalForm": "-4.32",
"System`InputForm": "-4.32",
"System`OutputForm": "-4.32",
},
},
"-4.32`4": {
"msg": "A PrecisionReal number",
"text": {
"System`StandardForm": "-4.320",
"System`TraditionalForm": "-4.320",
"System`InputForm": "-4.320",
"System`OutputForm": "-4.320",
},
"mathml": {
"System`StandardForm": "<mn>-4.320</mn>",
"System`TraditionalForm": "<mn>-4.320</mn>",
"System`InputForm": "<mtext>-4.320</mtext>",
"System`OutputForm": "<mn>-4.320</mn>",
},
"latex": {
"System`StandardForm": "-4.320",
"System`TraditionalForm": "-4.320",
"System`InputForm": "-4.320",
"System`OutputForm": "-4.320",
},
},
"-4.326563712`2": {
"msg": "A Real number",
"text": {
"System`StandardForm": "-4.3",
"System`TraditionalForm": "-4.3",
"System`InputForm": "-4.3",
"System`OutputForm": "-4.3",
},
"mathml": {
"System`StandardForm": "<mn>-4.3</mn>",
"System`TraditionalForm": "<mn>-4.3</mn>",
"System`InputForm": "<mtext>-4.3</mtext>",
"System`OutputForm": "<mn>-4.3</mn>",
},
"latex": {
"System`StandardForm": "-4.3",
"System`TraditionalForm": "-4.3",
"System`InputForm": "-4.3",
"System`OutputForm": "-4.3",
},
},
"1. 10^6": {
"msg": "very large real number (>10^6)",
"text": {
"System`InputForm": r"1.000000*^6",
"System`OutputForm": "1.×10^6",
},
"latex": {
"System`InputForm": r"1.000000\text{*${}^{\wedge}$}6",
"System`OutputForm": r"1.\times 10^6",
},
"mathml": {},
},
"1. 10^5": {
"msg": "large real number (<10^6)",
"text": {
"System`InputForm": r"100000.",
"System`OutputForm": "100000.",
},
"latex": {
"System`InputForm": r"100000.",
"System`OutputForm": "100000.",
},
"mathml": {},
},
"-1. 10^6": {
"msg": "large negative real number (>10^6)",
"text": {
"System`InputForm": r"-1.000000*^6",
"System`OutputForm": "-1.×10^6",
},
"latex": {
"System`InputForm": r"-1.000000\text{*${}^{\wedge}$}6",
"System`OutputForm": r"-1.\times 10^6",
},
"mathml": {},
},
"-1. 10^5": {
"msg": "large negative real number (<10^6)",
"text": {
"System`InputForm": r"-100000.",
"System`OutputForm": "-100000.",
},
"latex": {
"System`InputForm": r"-100000.",
"System`OutputForm": "-100000.",
},
"mathml": {},
},
"1. 10^-6": {
"msg": "very small real number (<10^-6)",
"text": {
"System`InputForm": r"1.*^-6",
"System`OutputForm": "1.×10^-6",
},
"latex": {
"System`InputForm": r"1.\text{*${}^{\wedge}$}-6",
"System`OutputForm": r"1.\times 10^{-6}",
},
"mathml": {},
},
"1. 10^-5": {
"msg": "small real number (<10^-5)",
"text": {
"System`InputForm": r"0.00001",
"System`OutputForm": "0.00001",
},
"latex": {
"System`InputForm": r"0.00001",
"System`OutputForm": "0.00001",
},
"mathml": {},
},
"-1. 10^-6": {
"msg": "very small negative real number (<10^-6)",
"text": {
"System`InputForm": r"-1.*^-6",
"System`OutputForm": "-1.×10^-6",
},
"latex": {
"System`InputForm": r"-1.\text{*${}^{\wedge}$}-6",
"System`OutputForm": r"-1.\times 10^{-6}",
},
"mathml": {},
},
"-1. 10^-5": {
"msg": "small negative real number (>10^-5)",
"text": {
"System`InputForm": r"-0.00001",
"System`OutputForm": "-0.00001",
},
"latex": {
"System`InputForm": r"-0.00001",
"System`OutputForm": "-0.00001",
},
"mathml": {},
},
"Complex[1.09*^12,3.]": {
"msg": "Complex number",
"text": {
"System`StandardForm": "1.09*^12+3. I",
"System`TraditionalForm": "1.09×10^12+3.I",
"System`InputForm": "1.090000000000*^12 + 3.*I",
"System`OutputForm": "1.09×10^12 + 3. I",
},
"mathml": {
"System`StandardForm": r"<mrow><mrow><mn>1.09</mn> <mtext>*^</mtext> <mn>12</mn></mrow> <mo>+</mo> <mrow><mn>3.</mn> <mo> </mo> <mi>I</mi></mrow></mrow>",
"System`TraditionalForm": r'<mrow><mrow><mn>1.09</mn> <mo>×</mo> <msup><mn>10</mn> <mn>12</mn></msup></mrow> <mo>+</mo> <mrow><mn>3.</mn> <mo form="prefix" lspace="0" rspace="0.2em"></mo> <mi>I</mi></mrow></mrow>',
"System`InputForm": r"<mrow><mrow><mtext>1.090000000000</mtext> <mtext>*^</mtext> <mtext>12</mtext></mrow> <mtext> + </mtext> <mrow><mtext>3.</mtext> <mtext>*</mtext> <mi>I</mi></mrow></mrow>",
"System`OutputForm": r"<mrow><mrow><mn>1.09</mn> <mo>×</mo> <msup><mn>10</mn> <mn>12</mn></msup></mrow> <mtext> + </mtext> <mrow><mn>3.</mn> <mo> </mo> <mi>I</mi></mrow></mrow>",
},
"latex": {
"System`StandardForm": r"1.09\text{*${}^{\wedge}$}12+3. I",
"System`TraditionalForm": r"1.09\times 10^{12}+3. I",
"System`InputForm": r"1.090000000000\text{*${}^{\wedge}$}12\text{ + }3.*I",
"System`OutputForm": r"1.09\times 10^{12}\text{ + }3. I",
},
},
'"Hola!"': {
"msg": "A String",
"text": {
"System`StandardForm": "Hola!",
"System`TraditionalForm": "Hola!",
"System`InputForm": '"Hola!"',
"System`OutputForm": "Hola!",
},
"mathml": {
"System`StandardForm": "<mtext>Hola!</mtext>",
"System`TraditionalForm": "<mtext>Hola!</mtext>",
"System`InputForm": "<ms>Hola!</ms>",
"System`OutputForm": "<mtext>Hola!</mtext>",
},
# Notice that differetly from "text", where InputForm
# preserves the quotes in strings, MathTeXForm just
# sorrounds the string in a ``\text{...}`` command,
# in the same way that all the other forms. This choice
# follows the behavior in WMA.
"latex": {
"System`StandardForm": "\\text{Hola!}",
"System`TraditionalForm": "\\text{Hola!}",
"System`InputForm": "\\text{``Hola!''}",
"System`OutputForm": "\\text{Hola!}",
},
},
# String with special characters
# In WMA, TeXForm[Pi] returns ``"\pi"`` instead the unicode character.
# In a next round, the idea would be to use mathics-scanner to recover the
# right representation of the characters.
'"\\[Pi] is a trascendental number"': {
"msg": "A String",
"text": {
"System`StandardForm": "π is a trascendental number",
"System`TraditionalForm": "π is a trascendental number",
"System`InputForm": '"π is a trascendental number"',
"System`OutputForm": "π is a trascendental number",
},
"mathml": {
"System`StandardForm": "<mtext>π is a trascendental number</mtext>",
"System`TraditionalForm": "<mtext>π is a trascendental number</mtext>",
"System`InputForm": "<ms>π is a trascendental number</ms>",
"System`OutputForm": "<mtext>π is a trascendental number</mtext>",
},
"latex": {
"System`StandardForm": "\\text{π is a trascendental number}",
"System`TraditionalForm": "\\text{π is a trascendental number}",
"System`InputForm": "\\text{``π is a trascendental number''}",
"System`OutputForm": "\\text{π is a trascendental number}",
},
},
'"-4.32"': {
"msg": "A String with a number",
"text": {
"System`StandardForm": "-4.32",
"System`TraditionalForm": "-4.32",
"System`InputForm": '"-4.32"',
"System`OutputForm": "-4.32",
},
"mathml": {
"System`StandardForm": "<mtext>-4.32</mtext>",
"System`TraditionalForm": "<mtext>-4.32</mtext>",
"System`InputForm": "<ms>-4.32</ms>",
"System`OutputForm": "<mtext>-4.32</mtext>",
},
"latex": {
"System`StandardForm": "\\text{-4.32}",
"System`TraditionalForm": "\\text{-4.32}",
"System`InputForm": "\\text{``-4.32''}",
"System`OutputForm": "\\text{-4.32}",
},
},
# Symbols
"a": {
"msg": "A Symbol",
"text": {
"System`StandardForm": "a",
"System`TraditionalForm": "a",
"System`InputForm": "a",
"System`OutputForm": "a",
},
"mathml": {
"System`StandardForm": "<mi>a</mi>",
"System`TraditionalForm": "<mi>a</mi>",
"System`InputForm": "<mi>a</mi>",
"System`OutputForm": "<mi>a</mi>",
},
"latex": {
"System`StandardForm": "a",
"System`TraditionalForm": "a",
"System`InputForm": "a",
"System`OutputForm": "a",
},
},
"\\[Pi]": {
"msg": "A greek letter Symbol",
"text": {
"System`StandardForm": "π",
"System`TraditionalForm": "π",
"System`InputForm": "Pi",
"System`OutputForm": "Pi",
},
"mathml": {
"System`StandardForm": "<mi>π</mi>",
"System`TraditionalForm": "<mi>π</mi>",
"System`InputForm": "<mi>Pi</mi>",
"System`OutputForm": "<mi>Pi</mi>",
},
"latex": {
"System`StandardForm": "π",
"System`TraditionalForm": "π",
"System`InputForm": "\\text{Pi}",
"System`OutputForm": "\\text{Pi}",
},
},
# Boxed expressions.
"a^4": {
"msg": "SuperscriptBox",
"text": {
"System`StandardForm": "a^4",
"System`TraditionalForm": "a^4",
"System`InputForm": "a^4",
"System`OutputForm": "a ^ 4",
},
"mathml": {
"System`StandardForm": "<msup><mi>a</mi> <mn>4</mn></msup>",
"System`TraditionalForm": "<msup><mi>a</mi> <mn>4</mn></msup>",
"System`InputForm": "<mrow><mi>a</mi> <mo>^</mo> <mtext>4</mtext></mrow>",
"System`OutputForm": "<mrow><mi>a</mi> <mtext> ^ </mtext> <mn>4</mn></mrow>",
},
"latex": {
"System`StandardForm": "a^4",
"System`TraditionalForm": "a^4",
"System`InputForm": "a{}^{\\wedge}4",
"System`OutputForm": "a\\text{ ${}^{\\wedge}$ }4",
},
},
"Subscript[a, 4]": {
"msg": "SubscriptBox",
"text": {
"System`StandardForm": ("Subscript[a, 4]", "BoxError"),
"System`TraditionalForm": ("Subscript[a, 4]", "BoxError"),
"System`InputForm": "Subscript[a, 4]",
"System`OutputForm": "Subscript[a, 4]",
},
"mathml": {
"System`StandardForm": "<msub><mi>a</mi> <mn>4</mn></msub>",
"System`TraditionalForm": "<msub><mi>a</mi> <mn>4</mn></msub>",
"System`InputForm": (
"<mrow><mi>Subscript</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mtext>4</mtext></mrow> <mo>]</mo></mrow>",
"Fragile!",
),
"System`OutputForm": (
"<mrow><mi>Subscript</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mn>4</mn></mrow> <mo>]</mo></mrow>",
"Fragile!",
),
},
"latex": {
"System`StandardForm": "a_4",
"System`TraditionalForm": "a_4",
"System`InputForm": "\\text{Subscript}\\left[a, 4\\right]",
"System`OutputForm": "\\text{Subscript}\\left[a, 4\\right]",
},
},
(
"Grid[{"
'{"Spanish", "Hola!"},'
'{"Portuguese", "Olà!"},'
'{"English", "Hi!"}'
"}]"
): {
"msg": "Strings in a GridBox",
"text": {
"System`StandardForm": (
"Spanish Hola!\n\n" "Portuguese Olà!\n\n" "English Hi!\n"
),
"System`TraditionalForm": (
"Spanish Hola!\n\n" "Portuguese Olà!\n\n" "English Hi!\n"
),
"System`InputForm": (
"Grid[{"
'{"Spanish", "Hola!"}, '
'{"Portuguese", "Olà!"}, '
'{"English", "Hi!"}'
"}]"
),
"System`OutputForm": (
"Spanish Hola!\n\n" "Portuguese Olà!\n\n" "English Hi!\n"
),
},
"latex": {
"System`StandardForm": "\\begin{array}{cc} \\text{Spanish} & \\text{Hola!}\\\\ \\text{Portuguese} & \\text{Olà!}\\\\ \\text{English} & \\text{Hi!}\\end{array}",
"System`TraditionalForm": "\\begin{array}{cc} \\text{Spanish} & \\text{Hola!}\\\\ \\text{Portuguese} & \\text{Olà!}\\\\ \\text{English} & \\text{Hi!}\\end{array}",
"System`InputForm": r"\text{Grid}\left[\left\{\left\{\text{``Spanish''}, \text{``Hola!''}\right\}, \left\{\text{``Portuguese''}, \text{``Olà!''}\right\}, \left\{\text{``English''}, \text{``Hi!''}\right\}\right\}\right]",
"System`OutputForm": "\\begin{array}{cc} \\text{Spanish} & \\text{Hola!}\\\\ \\text{Portuguese} & \\text{Olà!}\\\\ \\text{English} & \\text{Hi!}\\end{array}",
},
"mathml": {
"System`StandardForm": (
'<mtable columnalign="center">\n'
'<mtr><mtd columnalign="center"><mtext>Spanish</mtext></mtd><mtd columnalign="center"><mtext>Hola!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>Portuguese</mtext></mtd><mtd columnalign="center"><mtext>Olà!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>English</mtext></mtd><mtd columnalign="center"><mtext>Hi!</mtext></mtd></mtr>\n'
"</mtable>"
),
"System`TraditionalForm": (
'<mtable columnalign="center">\n'
'<mtr><mtd columnalign="center"><mtext>Spanish</mtext></mtd><mtd columnalign="center"><mtext>Hola!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>Portuguese</mtext></mtd><mtd columnalign="center"><mtext>Olà!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>English</mtext></mtd><mtd columnalign="center"><mtext>Hi!</mtext></mtd></mtr>\n'
"</mtable>"
),
"System`InputForm": r"""<mrow><mi>Grid</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mrow><mo>{</mo> <mrow><ms>Spanish</ms> <mtext>, </mtext> <ms>Hola!</ms></mrow> <mo>}</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><ms>Portuguese</ms> <mtext>, </mtext> <ms>Olà!</ms></mrow> <mo>}</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><ms>English</ms> <mtext>, </mtext> <ms>Hi!</ms></mrow> <mo>}</mo></mrow></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>""",
"System`OutputForm": (
'<mtable columnalign="center">\n'
'<mtr><mtd columnalign="center"><mtext>Spanish</mtext></mtd><mtd columnalign="center"><mtext>Hola!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>Portuguese</mtext></mtd><mtd columnalign="center"><mtext>Olà!</mtext></mtd></mtr>\n'
'<mtr><mtd columnalign="center"><mtext>English</mtext></mtd><mtd columnalign="center"><mtext>Hi!</mtext></mtd></mtr>\n'
"</mtable>"
),
},
},
"Subsuperscript[a, p, q]": {
"msg": "SubsuperscriptBox",
"text": {
"System`StandardForm": "Subsuperscript[a, p, q]",
"System`TraditionalForm": "Subsuperscript[a, p, q]",
"System`InputForm": "Subsuperscript[a, p, q]",
"System`OutputForm": "Subsuperscript[a, p, q]",
},
"mathml": {
"System`StandardForm": "<msubsup><mi>a</mi> <mi>p</mi> <mi>q</mi></msubsup>",
"System`TraditionalForm": "<msubsup><mi>a</mi> <mi>p</mi> <mi>q</mi></msubsup>",
"System`InputForm": "<mrow><mi>Subsuperscript</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>p</mi> <mtext>, </mtext> <mi>q</mi></mrow> <mo>]</mo></mrow>",
"System`OutputForm": "<mrow><mi>Subsuperscript</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>p</mi> <mtext>, </mtext> <mi>q</mi></mrow> <mo>]</mo></mrow>",
},
"latex": {
"System`StandardForm": "a_p^q",
"System`TraditionalForm": "a_p^q",
"System`InputForm": "\\text{Subsuperscript}\\left[a, p, q\\right]",
"System`OutputForm": "\\text{Subsuperscript}\\left[a, p, q\\right]",
},
},
# Here I use Integrate to simplify the input.
"Integrate[F[x], {x, a, g[b]}]": {
"msg": "Nontrivial SubsuperscriptBox",
"text": {
# FIXME: The next to are use the wrong DifferentialD due to hard-coding
# in Integrate[] MakeBox rules.
# "System`StandardForm": "Subsuperscript[∫, a, g[b]]\u2062F[x]\u2062\uf74cx",
# "System`TraditionalForm": "Subsuperscript[∫, a, g(b)]\u2062F(x)\u2062\uf74cx",
# "System`InputForm": "Integrate[F[x], {x, a, g[b]}]",
"System`OutputForm": "Integrate[F[x], {x, a, g[b]}]",
},
"mathml": {
# FIXME: The next to are use the wrong DifferentialD due to hard-coding
# in Integrate[] MakeBox rules.
# "System`StandardForm": '<mrow><msubsup><mo>∫</mo> <mi>a</mi> <mrow><mi>g</mi> <mo>[</mo> <mi>b</mi> <mo>]</mo></mrow></msubsup> <mo form="prefix" lspace="0" rspace="0.2em">\u2062</mo> <mrow><mi>F</mi> <mo>[</mo> <mi>x</mi> <mo>]</mo></mrow> <mo form="prefix" lspace="0" rspace="0.2em">\u2062</mo> <mrow><mtext>\uf74c</mtext> <mi>x</mi></mrow></mrow>',
# "System`TraditionalForm": '<mrow><msubsup><mo>∫</mo> <mi>a</mi> <mrow><mi>g</mi> <mo>(</mo> <mi>b</mi> <mo>)</mo></mrow></msubsup> <mo form="prefix" lspace="0" rspace="0.2em">\u2062</mo> <mrow><mi>F</mi> <mo>(</mo> <mi>x</mi> <mo>)</mo></mrow> <mo form="prefix" lspace="0" rspace="0.2em">\u2062</mo> <mrow><mtext>\uf74c</mtext> <mi>x</mi></mrow></mrow>',
"System`InputForm": "<mrow><mi>Integrate</mi> <mo>[</mo> <mrow><mrow><mi>F</mi> <mo>[</mo> <mi>x</mi> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mi>x</mi> <mtext>, </mtext> <mi>a</mi> <mtext>, </mtext> <mrow><mi>g</mi> <mo>[</mo> <mi>b</mi> <mo>]</mo></mrow></mrow> <mo>}</mo></mrow></mrow> <mo>]</mo></mrow>",
"System`OutputForm": "<mrow><mi>Integrate</mi> <mo>[</mo> <mrow><mrow><mi>F</mi> <mo>[</mo> <mi>x</mi> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mi>x</mi> <mtext>, </mtext> <mi>a</mi> <mtext>, </mtext> <mrow><mi>g</mi> <mo>[</mo> <mi>b</mi> <mo>]</mo></mrow></mrow> <mo>}</mo></mrow></mrow> <mo>]</mo></mrow>",
},
"latex": {
"System`StandardForm": "\\int_a^{g\\left[b\\right]} F\\left[x\\right] \, dx",
"System`TraditionalForm": "\\int_a^{g\\left(b\\right)} F\\left(x\\right) \, dx",
"System`InputForm": "\\text{Integrate}\\left[F\\left[x\\right], \\left\\{x, a, g\\left[b\\right]\\right\\}\\right]",
"System`OutputForm": "\\text{Integrate}\\left[F\\left[x\\right], \\left\\{x, a, g\\left[b\\right]\\right\\}\\right]",
},
},
# Nested compound expressions:
"a^(b/c)": {
"msg": "SuperscriptBox with a nested expression.",
"text": {
"System`StandardForm": "a^(b / c)",
"System`TraditionalForm": "a^(b / c)",
"System`InputForm": "a^(b / c)",
"System`OutputForm": "a ^ (b / c)",
},
"mathml": {
"System`StandardForm": "<msup><mi>a</mi> <mfrac><mi>b</mi> <mi>c</mi></mfrac></msup>",
"System`TraditionalForm": "<msup><mi>a</mi> <mfrac><mi>b</mi> <mi>c</mi></mfrac></msup>",
"System`InputForm": "<mrow><mi>a</mi> <mo>^</mo> <mrow><mo>(</mo> <mrow><mi>b</mi> <mtext> / </mtext> <mi>c</mi></mrow> <mo>)</mo></mrow></mrow>",
"System`OutputForm": r"<mrow><mi>a</mi> <mtext> ^ </mtext> <mrow><mo>(</mo> <mfrac><mi>b</mi> <mi>c</mi></mfrac> <mo>)</mo></mrow></mrow>",
},
"latex": {
"System`StandardForm": "a^{\\frac{b}{c}}",
"System`TraditionalForm": "a^{\\frac{b}{c}}",
"System`InputForm": "a{}^{\\wedge}\\left(b\\text{ / }c\\right)",
"System`OutputForm": "a\\text{ ${}^{\\wedge}$ }\\left(\\frac{b}{c}\\right)",
},
},
"1/(1+1/(1+1/a))": {
"msg": "FractionBox",
"text": {
"System`StandardForm": "1 / (1+1 / (1+1 / a))",
"System`TraditionalForm": "1 / (1+1 / (1+1 / a))",
"System`InputForm": "1 / (1 + 1 / (1 + 1 / a))",
"System`OutputForm": "1 / (1 + 1 / (1 + 1 / a))",
},
"mathml": {
"System`StandardForm": (
"<mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mi>a</mi></mfrac></mrow></mfrac></mrow></mfrac>",
"Fragile!",
),
"System`TraditionalForm": (
"<mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mi>a</mi></mfrac></mrow></mfrac></mrow></mfrac>",
"Fragile!",
),
"System`InputForm": (
"<mrow><mtext>1</mtext> <mtext> / </mtext> <mrow><mo>(</mo> <mrow><mtext>1</mtext> <mtext> + </mtext> <mrow><mtext>1</mtext> <mtext> / </mtext> <mrow><mo>(</mo> <mrow><mtext>1</mtext> <mtext> + </mtext> <mrow><mtext>1</mtext> <mtext> / </mtext> <mi>a</mi></mrow></mrow> <mo>)</mo></mrow></mrow></mrow> <mo>)</mo></mrow></mrow>",
"Fragile!",
),
"System`OutputForm": (
(
r"<mfrac><mn>1</mn> <mrow><mn>1</mn> <mtext> + </mtext> "
r"<mfrac><mn>1</mn> <mrow><mn>1</mn> <mtext> + </mtext> "
r"<mfrac><mn>1</mn> <mi>a</mi></mfrac></mrow></mfrac></mrow>"
r"</mfrac>"
),
"Fragile!",
),
},
"latex": {
"System`StandardForm": "\\frac{1}{1+\\frac{1}{1+\\frac{1}{a}}}",
"System`TraditionalForm": "\\frac{1}{1+\\frac{1}{1+\\frac{1}{a}}}",
"System`InputForm": "1\\text{ / }\\left(1\\text{ + }1\\text{ / }\\left(1\\text{ + }1\\text{ / }a\\right)\\right)",
"System`OutputForm": r"\frac{1}{1\text{ + }\frac{1}{1\text{ + }\frac{1}{a}}}",
},
},
"Sqrt[1/(1+1/(1+1/a))]": {
"msg": "SqrtBox",
"text": {
"System`StandardForm": "Sqrt[1 / (1+1 / (1+1 / a))]",
"System`TraditionalForm": "Sqrt[1 / (1+1 / (1+1 / a))]",
"System`InputForm": "Sqrt[1 / (1 + 1 / (1 + 1 / a))]",
"System`OutputForm": "Sqrt[1 / (1 + 1 / (1 + 1 / a))]",
},
"mathml": {
"System`StandardForm": (
"<msqrt> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mi>a</mi></mfrac></mrow></mfrac></mrow></mfrac> </msqrt>",
"Fragile!",
),
"System`TraditionalForm": (
"<msqrt> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mo>+</mo> <mfrac><mn>1</mn> <mi>a</mi></mfrac></mrow></mfrac></mrow></mfrac> </msqrt>",
"Fragile!",
),
"System`InputForm": (
"<mrow><mi>Sqrt</mi> <mo>[</mo> <mrow><mtext>1</mtext> <mtext> / </mtext> <mrow><mo>(</mo> <mrow><mtext>1</mtext> <mtext> + </mtext> <mrow><mtext>1</mtext> <mtext> / </mtext> <mrow><mo>(</mo> <mrow><mtext>1</mtext> <mtext> + </mtext> <mrow><mtext>1</mtext> <mtext> / </mtext> <mi>a</mi></mrow></mrow> <mo>)</mo></mrow></mrow></mrow> <mo>)</mo></mrow></mrow> <mo>]</mo></mrow>",
"Fragile!",
),
"System`OutputForm": (
(
r"<mrow><mi>Sqrt</mi> <mo>[</mo> <mfrac><mn>1</mn> <mrow><mn>1</mn> <mtext> + </mtext> "
r"<mfrac><mn>1</mn> <mrow><mn>1</mn> <mtext> + </mtext> <mfrac><mn>1</mn> <mi>a</mi>"
r"</mfrac></mrow></mfrac></mrow></mfrac> <mo>]</mo></mrow>"
),
"Fragile!",
),
},
"latex": {
"System`StandardForm": "\\sqrt{\\frac{1}{1+\\frac{1}{1+\\frac{1}{a}}}}",
"System`TraditionalForm": "\\sqrt{\\frac{1}{1+\\frac{1}{1+\\frac{1}{a}}}}",
"System`InputForm": "\\text{Sqrt}\\left[1\\text{ / }\\left(1\\text{ + }1\\text{ / }\\left(1\\text{ + }1\\text{ / }a\\right)\\right)\\right]",
"System`OutputForm": r"\text{Sqrt}\left[\frac{1}{1\text{ + }\frac{1}{1\text{ + }\frac{1}{a}}}\right]",
},
},
# Grids, arrays and matrices
"Grid[{{a,b},{c,d}}]": {
"msg": "GridBox",
"text": {
"System`StandardForm": "a b\n\nc d\n",
"System`TraditionalForm": "a b\n\nc d\n",
"System`InputForm": "Grid[{{a, b}, {c, d}}]",
"System`OutputForm": "a b\n\nc d\n",
},
"mathml": {
"System`StandardForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
"System`TraditionalForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
"System`InputForm": "<mrow><mi>Grid</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mrow><mo>{</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>}</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mi>c</mi> <mtext>, </mtext> <mi>d</mi></mrow> <mo>}</mo></mrow></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>",
"System`OutputForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
},
"latex": {
"System`StandardForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
"System`TraditionalForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
"System`InputForm": "\\text{Grid}\\left[\\left\\{\\left\\{a, b\\right\\}, \\left\\{c, d\\right\\}\\right\\}\\right]",
"System`OutputForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
},
},
"TableForm[{{a,b},{c,d}}]": {
"msg": "GridBox in a table",
"text": {
"System`StandardForm": "a b\n\nc d\n",
"System`TraditionalForm": "a b\n\nc d\n",
"System`InputForm": "TableForm[{{a, b}, {c, d}}]",
"System`OutputForm": "a b\n\nc d\n",
},
"mathml": {
"System`StandardForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
"System`TraditionalForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
"System`InputForm": "<mrow><mi>TableForm</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mrow><mo>{</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>}</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mi>c</mi> <mtext>, </mtext> <mi>d</mi></mrow> <mo>}</mo></mrow></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>",
"System`OutputForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
},
"latex": {
"System`StandardForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
"System`TraditionalForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
"System`InputForm": "\\text{TableForm}\\left[\\left\\{\\left\\{a, b\\right\\}, \\left\\{c, d\\right\\}\\right\\}\\right]",
"System`OutputForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
},
},
"MatrixForm[{{a,b},{c,d}}]": {
"msg": "GridBox in a matrix",
"text": {
"System`StandardForm": "(a b\n\nc d\n)",
"System`TraditionalForm": "(a b\n\nc d\n)",
"System`InputForm": "MatrixForm[{{a, b}, {c, d}}]",
"System`OutputForm": "a b\n\nc d\n",
},
"mathml": {
"System`StandardForm": '<mrow><mo>(</mo> <mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable> <mo>)</mo></mrow>',
"System`TraditionalForm": '<mrow><mo>(</mo> <mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable> <mo>)</mo></mrow>',
"System`InputForm": "<mrow><mi>MatrixForm</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mrow><mo>{</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>}</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mi>c</mi> <mtext>, </mtext> <mi>d</mi></mrow> <mo>}</mo></mrow></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>",
"System`OutputForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mi>a</mi></mtd><mtd columnalign="center"><mi>b</mi></mtd></mtr>\n<mtr><mtd columnalign="center"><mi>c</mi></mtd><mtd columnalign="center"><mi>d</mi></mtd></mtr>\n</mtable>',
},
"latex": {
"System`StandardForm": "\\left(\\begin{array}{cc} a & b\\\\ c & d\\end{array}\\right)",
"System`TraditionalForm": "\\left(\\begin{array}{cc} a & b\\\\ c & d\\end{array}\\right)",
"System`InputForm": "\\text{MatrixForm}\\left[\\left\\{\\left\\{a, b\\right\\}, \\left\\{c, d\\right\\}\\right\\}\\right]",
"System`OutputForm": "\\begin{array}{cc} a & b\\\\ c & d\\end{array}",
},
},
# Boxes including Graphics.
# These tests could require to be re-generated
"Graphics[{}]": {
"msg": "GraphicsBox - Fragile!",
"text": {
"System`StandardForm": "-Graphics-",
"System`TraditionalForm": "-Graphics-",
"System`InputForm": "Graphics[{}]",
"System`OutputForm": "-Graphics-",
},
# "mathml": {
# "System`StandardForm": '<mglyph width="350px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMnB4IiBoZWlnaHQ9IjJweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9Ii0xLjAwMDAwMCAtMS4wMDAwMDAgMi4wMDAwMDAgMi4wMDAwMDAiPgogICAgICAgICAgICAgICAgPCEtLUdyYXBoaWNzRWxlbWVudHMtLT4KPC9zdmc+Cg=="/>',
# "System`TraditionalForm": '<mglyph width="350px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMnB4IiBoZWlnaHQ9IjJweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9Ii0xLjAwMDAwMCAtMS4wMDAwMDAgMi4wMDAwMDAgMi4wMDAwMDAiPgogICAgICAgICAgICAgICAgPCEtLUdyYXBoaWNzRWxlbWVudHMtLT4KPC9zdmc+Cg=="/>',
# "System`InputForm": "<mrow><mi>Graphics</mi> <mo>[</mo> <mrow><mo>{</mo> <mo>}</mo></mrow> <mo>]</mo></mrow>",
# "System`OutputForm": '<mglyph width="350px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMnB4IiBoZWlnaHQ9IjJweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9Ii0xLjAwMDAwMCAtMS4wMDAwMDAgMi4wMDAwMDAgMi4wMDAwMDAiPgogICAgICAgICAgICAgICAgPCEtLUdyYXBoaWNzRWxlbWVudHMtLT4KPC9zdmc+Cg=="/>',
# },
"latex": {
"System`StandardForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n',
"System`TraditionalForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n',
"System`InputForm": "\\text{Graphics}\\left[\\left\\{\\right\\}\\right]",
"System`OutputForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(5.8333cm, 5.8333cm);\n\n\nclip(box((-1,-1), (1,1)));\n\n\\end{asy}\n',
},
},
"Graphics[{Text[a^b,{0,0}]}]": {
"msg": "Nontrivial Graphics - Fragile!",
"text": {
"System`StandardForm": "-Graphics-",
"System`TraditionalForm": "-Graphics-",
"System`InputForm": "Graphics[{Text[Power[a, b], {0, 0}]}]",
"System`OutputForm": "-Graphics-",
},
# "mathml": {
# "System`StandardForm": '<mglyph width="294px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjEzNi41MDAwMDAgMTYyLjUwMDAwMCAyMS4wMDAwMDAgMjUuMDAwMDAwIj4KICAgICAgICAgICAgICAgIDwhLS1HcmFwaGljc0VsZW1lbnRzLS0+Cjx0ZXh0IHg9IjE0Ny4wIiB5PSIxNzUuMCIgb3g9IjAiIG95PSIwIiBmb250LXNpemU9IjEwcHgiIHN0eWxlPSJ0ZXh0LWFuY2hvcjplbmQ7IGRvbWluYW50LWJhc2VsaW5lOmhhbmdpbmc7IHN0cm9rZTogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBzdHJva2Utb3BhY2l0eTogMTsgZmlsbDogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBmaWxsLW9wYWNpdHk6IDE7IGNvbG9yOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IG9wYWNpdHk6IDEuMCI+YV5iPC90ZXh0Pgo8L3N2Zz4K"/>',
# "System`TraditionalForm": '<mglyph width="294px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjEzNi41MDAwMDAgMTYyLjUwMDAwMCAyMS4wMDAwMDAgMjUuMDAwMDAwIj4KICAgICAgICAgICAgICAgIDwhLS1HcmFwaGljc0VsZW1lbnRzLS0+Cjx0ZXh0IHg9IjE0Ny4wIiB5PSIxNzUuMCIgb3g9IjAiIG95PSIwIiBmb250LXNpemU9IjEwcHgiIHN0eWxlPSJ0ZXh0LWFuY2hvcjplbmQ7IGRvbWluYW50LWJhc2VsaW5lOmhhbmdpbmc7IHN0cm9rZTogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBzdHJva2Utb3BhY2l0eTogMTsgZmlsbDogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBmaWxsLW9wYWNpdHk6IDE7IGNvbG9yOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IG9wYWNpdHk6IDEuMCI+YV5iPC90ZXh0Pgo8L3N2Zz4K"/>',
# "System`InputForm": "<mrow><mi>Graphics</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mi>Text</mi> <mo>[</mo> <mrow><mrow><mi>Power</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mtext>0</mtext> <mtext>, </mtext> <mtext>0</mtext></mrow> <mo>}</mo></mrow></mrow> <mo>]</mo></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>",
# "System`OutputForm": '<mglyph width="294px" height="350px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjEzNi41MDAwMDAgMTYyLjUwMDAwMCAyMS4wMDAwMDAgMjUuMDAwMDAwIj4KICAgICAgICAgICAgICAgIDwhLS1HcmFwaGljc0VsZW1lbnRzLS0+Cjx0ZXh0IHg9IjE0Ny4wIiB5PSIxNzUuMCIgb3g9IjAiIG95PSIwIiBmb250LXNpemU9IjEwcHgiIHN0eWxlPSJ0ZXh0LWFuY2hvcjplbmQ7IGRvbWluYW50LWJhc2VsaW5lOmhhbmdpbmc7IHN0cm9rZTogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBzdHJva2Utb3BhY2l0eTogMTsgZmlsbDogcmdiKDAuMDAwMDAwJSwgMC4wMDAwMDAlLCAwLjAwMDAwMCUpOyBmaWxsLW9wYWNpdHk6IDE7IGNvbG9yOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IG9wYWNpdHk6IDEuMCI+YV5iPC90ZXh0Pgo8L3N2Zz4K"/>',
# },
"latex": {
"System`StandardForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n',
"System`TraditionalForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n',
"System`InputForm": "\\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right]",
"System`OutputForm": '\n\\begin{asy}\nusepackage("amsmath");\nsize(4.9cm, 5.8333cm);\n\n// InsetBox\nlabel("$a^b$", (147.0,175.0), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((136.5,162.5), (157.5,187.5)));\n\n\\end{asy}\n',
},
},
"TableForm[{Graphics[{Text[a^b,{0,0}]}], Graphics[{Text[a^b,{0,0}]}]}]": {
"msg": "A table of graphics - Fragile!",
"text": {
"System`StandardForm": "-Graphics-\n\n-Graphics-\n",
"System`TraditionalForm": "-Graphics-\n\n-Graphics-\n",
"System`InputForm": "TableForm[{Graphics[{Text[Power[a, b], {0, 0}]}], Graphics[{Text[Power[a, b], {0, 0}]}]}]",
"System`OutputForm": "-Graphics-\n\n-Graphics-\n",
},
# "mathml": {
# "System`StandardForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n</mtable>',
# "System`TraditionalForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n</mtable>',
# "System`InputForm": "<mrow><mi>TableForm</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mrow><mi>Graphics</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mi>Text</mi> <mo>[</mo> <mrow><mrow><mi>Power</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mtext>0</mtext> <mtext>, </mtext> <mtext>0</mtext></mrow> <mo>}</mo></mrow></mrow> <mo>]</mo></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mi>Graphics</mi> <mo>[</mo> <mrow><mo>{</mo> <mrow><mi>Text</mi> <mo>[</mo> <mrow><mrow><mi>Power</mi> <mo>[</mo> <mrow><mi>a</mi> <mtext>, </mtext> <mi>b</mi></mrow> <mo>]</mo></mrow> <mtext>, </mtext> <mrow><mo>{</mo> <mrow><mtext>0</mtext> <mtext>, </mtext> <mtext>0</mtext></mrow> <mo>}</mo></mrow></mrow> <mo>]</mo></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow></mrow> <mo>}</mo></mrow> <mo>]</mo></mrow>",
# "System`OutputForm": '<mtable columnalign="center">\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n<mtr><mtd columnalign="center"><mglyph width="147px" height="175px" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEuMHB4IiBoZWlnaHQ9IjI1LjBweCIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgICAgICAgICAgICAgIHZlcnNpb249IjEuMSIKICAgICAgICAgICAgICAgIHZpZXdCb3g9IjYzLjAwMDAwMCA3NS4wMDAwMDAgMjEuMDAwMDAwIDI1LjAwMDAwMCI+CiAgICAgICAgICAgICAgICA8IS0tR3JhcGhpY3NFbGVtZW50cy0tPgo8dGV4dCB4PSI3My41IiB5PSI4Ny41IiBveD0iMCIgb3k9IjAiIGZvbnQtc2l6ZT0iMTBweCIgc3R5bGU9InRleHQtYW5jaG9yOmVuZDsgZG9taW5hbnQtYmFzZWxpbmU6aGFuZ2luZzsgc3Ryb2tlOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IHN0cm9rZS1vcGFjaXR5OiAxOyBmaWxsOiByZ2IoMC4wMDAwMDAlLCAwLjAwMDAwMCUsIDAuMDAwMDAwJSk7IGZpbGwtb3BhY2l0eTogMTsgY29sb3I6IHJnYigwLjAwMDAwMCUsIDAuMDAwMDAwJSwgMC4wMDAwMDAlKTsgb3BhY2l0eTogMS4wIj5hXmI8L3RleHQ+Cjwvc3ZnPgo="/></mtd></mtr>\n</mtable>',
# },
"latex": {
"System`StandardForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}',
"System`TraditionalForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}',
"System`InputForm": "\\text{TableForm}\\left[\\left\\{\\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right], \\text{Graphics}\\left[\\left\\{\\text{Text}\\left[\\text{Power}\\left[a, b\\right], \\left\\{0, 0\\right\\}\\right]\\right\\}\\right]\\right\\}\\right]",
"System`OutputForm": '\\begin{array}{c} \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\\\ \n\\begin{asy}\nusepackage("amsmath");\nsize(2.45cm, 2.9167cm);\n\n// InsetBox\nlabel("$a^b$", (73.5,87.5), (0,0), rgb(0, 0, 0)+fontsize(3));\n\nclip(box((63,75), (84,100)));\n\n\\end{asy}\n\\end{array}',
},
},
}
def load_tests(key):
"""
This function takes the full set of tests, pick the ones corresponding to one
of the final formats ("text", "latex", "mathml") and produce two list:
the first with the mandatory tests, and the other with "fragile" tests
"""
global all_tests
global MATHML_STRICT
def is_fragile(assert_msg: str) -> bool:
"""
Return True if assert_msg indicates we have a fragile test, and False otherwise
"""
return assert_msg.endswith("Fragile!")
mandatory_tests = []
fragile_tests = []
for expr in all_test:
base_msg = all_test[expr]["msg"]
expected_fmt = all_test[expr].get(key, None)
test_is_fragile = is_fragile(base_msg)
# Some fragile tests have been commented out.
# If we have a fragile test where the output has not
# been adjusted, then skip it.
#
if expected_fmt is None:
assert is_fragile(base_msg)
continue
for form in expected_fmt:
tst = expected_fmt[form]
form_is_fragile = test_is_fragile
must_be = False
if not isinstance(tst, str):
tst, extra_msg = tst
if len(extra_msg) > 7 and extra_msg[:7] == "must be":
must_be = True
elif is_fragile(extra_msg):
form_is_fragile = True
msg = base_msg + " - " + extra_msg
else:
msg = base_msg
# discard Fragile for "text", "latex" or if
# MATHML_STRICT is True
if key != "mathml" or MATHML_STRICT:
form_is_fragile = False
full_test = (expr, tst, Symbol(form), msg)
if form_is_fragile or must_be:
fragile_tests.append(full_test)
else:
mandatory_tests.append(full_test)
return mandatory_tests, fragile_tests
mandatory_tests, fragile_tests = load_tests("text")
if fragile_tests:
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
fragile_tests,
)
@pytest.mark.xfail
def test_makeboxes_text_fragile(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_text(evaluation=session.evaluation)
== str_expected
), msg
else:
strresult = format_result.boxes_to_text(evaluation=session.evaluation)
assert strresult == str_expected
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
mandatory_tests,
)
def test_makeboxes_text(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_text(evaluation=session.evaluation) == str_expected
), msg
else:
strresult = format_result.boxes_to_text(evaluation=session.evaluation)
assert strresult == str_expected
mandatory_tests, fragile_tests = load_tests("latex")
if fragile_tests:
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
fragile_tests,
)
@pytest.mark.xfail
def test_makeboxes_tex_fragile(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_tex(
show_string_characters=False, evaluation=session.evaluation
)
== str_expected
), msg
else:
strresult = format_result.boxes_to_text(evaluation=session.evaluation)
assert strresult == str_expected
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
mandatory_tests,
)
def test_makeboxes_tex(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_tex(
show_string_characters=False, evaluation=session.evaluation
)
== str_expected
), msg
else:
strresult = format_result.boxes_to_text(evaluation=session.evaluation)
assert strresult == str_expected
mandatory_tests, fragile_tests = load_tests("mathml")
if fragile_tests:
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
fragile_tests,
)
@pytest.mark.xfail
def test_makeboxes_mathml_fragile(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_tex(evaluation=session.evaluation)
== str_expected
), msg
else:
strresult = format_result.boxes_to_text(evaluation=session.evaluation)
assert strresult == str_expected
@pytest.mark.parametrize(
("str_expr", "str_expected", "form", "msg"),
mandatory_tests,
)
def test_makeboxes_mathml(str_expr, str_expected, form, msg):
result = session.evaluate(str_expr)
format_result = result.format(session.evaluation, form)
if msg:
assert (
format_result.boxes_to_mathml(evaluation=session.evaluation) == str_expected
), msg
else:
strresult = format_result.boxes_to_mathml(evaluation=session.evaluation)
assert strresult == str_expected
@pytest.mark.parametrize(
("str_expr", "str_expected", "msg"),
[
(
"OutputForm[Complex[2.0 ^ 40, 3]]",
"1.09951×10^12 + 3. I",
"OutputForm Complex",
),
(
"InputForm[Complex[2.0 ^ 40, 3]]",
"1.099511627776*^12 + 3.*I",
"InputForm Complex",
),
],
)
def test_format_private_doctests(str_expr, str_expected, msg):
check_evaluation(
str_expr,
str_expected,
to_string_expr=True,
to_string_expected=True,
hold_expected=True,
failure_message=msg,
)