* Bugs 16071+16072+16075 fixed: prettyprint() debugged & a bit improved
[scilab.git] / scilab / modules / string / tests / unit_tests / prettyprint.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2009 - DIGITEO - Sylvestre Ledru
4 // Copyright (C) 2019 - Samuel GOUGEON
5 //
6 //  This file is distributed under the same license as the Scilab package.
7 // =============================================================================
8
9 // <-- CLI SHELL MODE -->
10 // <-- NO CHECK REF -->
11
12 // syslin objects: tests in prettyprint_syslin.tst
13
14
15 // TEXTS
16 // =====
17 text = ["André''s got 50% of 1430 $, & the ""remainder"" 1 month later."
18         "x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#"];
19 // LaTeX
20 ref = "${\begin{pmatrix}\mathsf{\text{André''s got 50\% of 1430 \$, \& the ""remainder"" 1 month later.}}\cr \mathsf{\text{x=A\backslash\!B is such that A*x=B, with A in \{a\!<\!b, 1-a, \sim\!a, \^\;\,a\}. _#}}\cr \end{pmatrix}}$";
21 assert_checkequal(prettyprint(text), ref);
22
23 // TeX
24 ref = "${\pmatrix{\mathsf{\text{André''s got 50\% of 1430 \$, \& the ""remainder"" 1 month later.}}\cr \mathsf{\text{x=A\backslash\!B is such that A*x=B, with A in \{a\!<\!b, 1-a, \sim\!a, \^\;\,a\}. _#}}\cr }}$";
25 assert_checkequal(prettyprint(text, "tex"), ref);
26
27 // MathML
28 ref = [""
29 "<mfenced open=""("" close="")"">"
30 "<mtable>"
31 "<mtr>"
32 "<mtd><mi>André''s got 50% of 1430 $, & the ""remainder"" 1 month later.</mi></mtd>"
33 "</mtr>"
34 "<mtr>"
35 "<mtd><mi>x=A\B is such that A*x=B, with A in {a&lt;b, 1-a, ~a, ^a}. _#</mi></mtd>"
36 "</mtr>"
37 "</mtable>"
38 "</mfenced>"
39 "" ];
40 ref = strcat(ref, ascii(10));
41 assert_checkequal(prettyprint(text, "mathml"), ref);
42
43
44 // DECIMAL NUMBERS
45 // ===============
46 assert_checkequal(prettyprint(%inf), "${\infty}$");
47 assert_checkequal(prettyprint(%inf,"mathml"), "<mi>∞</mi>");
48
49 ref = "${\begin{pmatrix}{\infty}&0&1&{-\infty}\cr \end{pmatrix}}$";
50 assert_checkequal(prettyprint([%inf 0  1 -%inf]), ref);
51 ref = "${\begin{pmatrix}{\infty}&0\cr 1&{-\infty}\cr \end{pmatrix}}$"
52 assert_checkequal(prettyprint([%inf 0; 1 -%inf]), ref);
53
54 B = [ ..
55     50.153416    28.06498     40.948255 ; ..
56     43.685876    12.800585    87.841258 ; ..
57     26.931248    77.831286    11.383597 ; ..
58     63.257449    21.190304    19.983377 ; ..
59     40.51954     11.213547    56.186607 ; ..
60     91.847078    68.56896     58.961773 ; ..
61     4.3733433    15.312167    68.539797 ; ..
62     48.185089    69.708506    89.062247 ; ..
63     26.39556     84.155184    50.422128 ; ..
64     41.481037    40.620248    34.936154 ];
65
66 // LaTeX
67 BResultLatex = "${\begin{pmatrix}50.153416&28.06498&40.948255\cr 43.685876&12.800585&87.841258\cr 26.931248&77.831286&11.383597\cr 63.257449&21.190304&19.983377\cr 40.51954&11.213547&56.186607\cr 91.847078&68.56896&58.961773\cr 4.3733433&15.312167&68.539797\cr 48.185089&69.708506&89.062247\cr 26.39556&84.155184&50.422128\cr 41.481037&40.620248&34.936154\cr \end{pmatrix}}$";
68 assert_checkequal(prettyprint(B), BResultLatex);
69
70 // TeX
71 BResultTex = "${\pmatrix{50.153416&28.06498&40.948255\cr 43.685876&12.800585&87.841258\cr 26.931248&77.831286&11.383597\cr 63.257449&21.190304&19.983377\cr 40.51954&11.213547&56.186607\cr 91.847078&68.56896&58.961773\cr 4.3733433&15.312167&68.539797\cr 48.185089&69.708506&89.062247\cr 26.39556&84.155184&50.422128\cr 41.481037&40.620248&34.936154\cr }}$";
72 assert_checkequal(prettyprint(B,"tex"), BResultTex);
73
74 // MathML
75 ref = [""
76 "<mfenced open=""("" close="")"">"
77 "<mtable>"
78 "<mtr>"
79 "<mtd><mn>50.153416</mn></mtd>"
80 "<mtd><mn>28.06498</mn></mtd>"
81 "<mtd><mn>40.948255</mn></mtd>"
82 "</mtr>"
83 "<mtr>"
84 "<mtd><mn>43.685876</mn></mtd>"
85 "<mtd><mn>12.800585</mn></mtd>"
86 "<mtd><mn>87.841258</mn></mtd>"
87 "</mtr>"
88 "<mtr>"
89 "<mtd><mn>26.931248</mn></mtd>"
90 "<mtd><mn>77.831286</mn></mtd>"
91 "<mtd><mn>11.383597</mn></mtd>"
92 "</mtr>"
93 "<mtr>"
94 "<mtd><mn>63.257449</mn></mtd>"
95 "<mtd><mn>21.190304</mn></mtd>"
96 "<mtd><mn>19.983377</mn></mtd>"
97 "</mtr>"
98 "<mtr>"
99 "<mtd><mn>40.51954</mn></mtd>"
100 "<mtd><mn>11.213547</mn></mtd>"
101 "<mtd><mn>56.186607</mn></mtd>"
102 "</mtr>"
103 "<mtr>"
104 "<mtd><mn>91.847078</mn></mtd>"
105 "<mtd><mn>68.56896</mn></mtd>"
106 "<mtd><mn>58.961773</mn></mtd>"
107 "</mtr>"
108 "<mtr>"
109 "<mtd><mn>4.3733433</mn></mtd>"
110 "<mtd><mn>15.312167</mn></mtd>"
111 "<mtd><mn>68.539797</mn></mtd>"
112 "</mtr>"
113 "<mtr>"
114 "<mtd><mn>48.185089</mn></mtd>"
115 "<mtd><mn>69.708506</mn></mtd>"
116 "<mtd><mn>89.062247</mn></mtd>"
117 "</mtr>"
118 "<mtr>"
119 "<mtd><mn>26.39556</mn></mtd>"
120 "<mtd><mn>84.155184</mn></mtd>"
121 "<mtd><mn>50.422128</mn></mtd>"
122 "</mtr>"
123 "<mtr>"
124 "<mtd><mn>41.481037</mn></mtd>"
125 "<mtd><mn>40.620248</mn></mtd>"
126 "<mtd><mn>34.936154</mn></mtd>"
127 "</mtr>"
128 "</mtable>"
129 "</mfenced>"
130 "" ];
131 ref = strcat(ref, ascii(10));
132 assert_checkequal(prettyprint(B,"mathml"), ref);
133
134
135 // COMPLEX NUMBERS
136 // ===============
137 c = complex(0,%nan);
138 assert_checkequal(prettyprint(c), "${\mathrm{NaN}}i$");
139 assert_checkequal(prettyprint(c,"mathml"), "<mi>NaN</mi><mi>i</mi>");
140
141 //
142 c = [complex(1,%nan), complex(-1.25d-12, 2)
143      complex(%inf,6.1e167), complex(1,-%inf)];
144 ref = "${\begin{pmatrix}1+{\mathrm{NaN}}i&-1.250\!\times\!10^{-12}+2i\cr {\infty}+6.10\!\times\!10^{167}i&1{-\infty}i\cr \end{pmatrix}}$";
145 assert_checkequal(prettyprint(c), ref);
146 ref = "${\pmatrix{1+{\mathrm{NaN}}i&-1.250\!\times\!10^{-12}+2i\cr {\infty}+6.10\!\times\!10^{167}i&1{-\infty}i\cr }}$";
147 assert_checkequal(prettyprint(c,"tex"), ref);
148
149
150 // INTEGERS
151 // ========
152 i = int16([
153   26595  1212  4257 -4466  9784
154   -4226  3404  5743    3  10032
155   30471     6 14918  267     30 ]);
156
157 // LaTeX
158 ref = "${\begin{pmatrix}26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr \end{pmatrix}}$";
159 assert_checkequal(prettyprint(i), ref);
160
161 // TeX
162 ref = "${\pmatrix{26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr }}$";
163 assert_checkequal(prettyprint(i, "tex"), ref);
164
165 // MathML
166 ref  = [""
167 "<mfenced open=""("" close="")"">"
168 "<mtable>"
169 "<mtr>"
170 "<mtd><mn>26595</mn></mtd>"
171 "<mtd><mn>1212</mn></mtd>"
172 "<mtd><mn>4257</mn></mtd>"
173 "<mtd><mo>-</mo><mn>4466</mn></mtd>"
174 "<mtd><mn>9784</mn></mtd>"
175 "</mtr>"
176 "<mtr>"
177 "<mtd><mo>-</mo><mn>4226</mn></mtd>"
178 "<mtd><mn>3404</mn></mtd>"
179 "<mtd><mn>5743</mn></mtd>"
180 "<mtd><mn>3</mn></mtd>"
181 "<mtd><mn>10032</mn></mtd>"
182 "</mtr>"
183 "<mtr>"
184 "<mtd><mn>30471</mn></mtd>"
185 "<mtd><mn>6</mn></mtd>"
186 "<mtd><mn>14918</mn></mtd>"
187 "<mtd><mn>267</mn></mtd>"
188 "<mtd><mn>30</mn></mtd>"
189 "</mtr>"
190 "</mtable>"
191 "</mfenced>"
192 ""];
193 ref = strcat(ref, ascii(10));
194 assert_checkequal(prettyprint(i, "mathml"), ref);
195
196
197 // BOOLEANS
198 // ========
199 C = [ %t %t; %f %t ];
200 // LaTeX
201 CResultLatex="${\begin{pmatrix}T&T\cr F&T\cr \end{pmatrix}}$";
202 assert_checkequal(prettyprint(C), CResultLatex);
203 // TeX
204 CResultTex="${\pmatrix{T&T\cr F&T\cr }}$";
205 assert_checkequal(prettyprint(C,"tex"), CResultTex);
206 // MathML
207 ref = [""
208 "<mfenced open=""("" close="")"">"
209 "<mtable>"
210 "<mtr>"
211 "<mtd><mi>T</mi></mtd>"
212 "<mtd><mi>T</mi></mtd>"
213 "</mtr>"
214 "<mtr>"
215 "<mtd><mi>F</mi></mtd>"
216 "<mtd><mi>T</mi></mtd>"
217 "</mtr>"
218 "</mtable>"
219 "</mfenced>"
220 ""];
221 ref = strcat(ref, ascii(10));
222 assert_checkequal(prettyprint(C,"mathml"), ref);
223
224
225 // POLYNOMIALS
226 // ===========
227 assert_checkequal(prettyprint(0*%z), "$0z$");
228 assert_checkequal(prettyprint(0*%z, "tex"), "$0z$");
229 assert_checkequal(prettyprint(0*%z, "mathml"), "<mn>0</mn><mi>z</mi>");
230
231 p = 1+%s+2*%s^2;
232 assert_checkequal(prettyprint(p), "$1+s +2s^{2} $");
233
234 D = poly(B,"s");
235 DResultLatex="$1.553\!\times\!10^{47}-1.738\!\times\!10^{47}s +8.994\!\times\!10^{46}s^{2} -2.885\!\times\!10^{46}s^{3} +6.474\!\times\!10^{45}s^{4} -1.086\!\times\!10^{45}s^{5} +1.422\!\times\!10^{44}s^{6} -1.493\!\times\!10^{43}s^{7} +1.284\!\times\!10^{42}s^{8} -9.182\!\times\!10^{40}s^{9} +5.527\!\times\!10^{39}s^{10} -2.824\!\times\!10^{38}s^{11} +1.233\!\times\!10^{37}s^{12} -4.626\!\times\!10^{35}s^{13} +1.496\!\times\!10^{34}s^{14} -4.182\!\times\!10^{32}s^{15} +1.011\!\times\!10^{31}s^{16} -2.116\!\times\!10^{29}s^{17} +3.826\!\times\!10^{27}s^{18} -5.965\!\times\!10^{25}s^{19} +7.990\!\times\!10^{23}s^{20} -9.144\!\times\!10^{21}s^{21} +8.876\!\times\!10^{19}s^{22} -7.234\!\times\!10^{17}s^{23} +4.885\!\times\!10^{15}s^{24} -2.683\!\times\!10^{13}s^{25} +1.167\!\times\!10^{11}s^{26} -3.868\!\times\!10^{08}s^{27} +916980.98s^{28} -1384.5606s^{29} +s^{30} $";
236 assert_checkequal(prettyprint(D,"latex","["), DResultLatex);
237
238 DResultTex="$1.553\!\times\!10^{47}-1.738\!\times\!10^{47}s +8.994\!\times\!10^{46}s^{2} -2.885\!\times\!10^{46}s^{3} +6.474\!\times\!10^{45}s^{4} -1.086\!\times\!10^{45}s^{5} +1.422\!\times\!10^{44}s^{6} -1.493\!\times\!10^{43}s^{7} +1.284\!\times\!10^{42}s^{8} -9.182\!\times\!10^{40}s^{9} +5.527\!\times\!10^{39}s^{10} -2.824\!\times\!10^{38}s^{11} +1.233\!\times\!10^{37}s^{12} -4.626\!\times\!10^{35}s^{13} +1.496\!\times\!10^{34}s^{14} -4.182\!\times\!10^{32}s^{15} +1.011\!\times\!10^{31}s^{16} -2.116\!\times\!10^{29}s^{17} +3.826\!\times\!10^{27}s^{18} -5.965\!\times\!10^{25}s^{19} +7.990\!\times\!10^{23}s^{20} -9.144\!\times\!10^{21}s^{21} +8.876\!\times\!10^{19}s^{22} -7.234\!\times\!10^{17}s^{23} +4.885\!\times\!10^{15}s^{24} -2.683\!\times\!10^{13}s^{25} +1.167\!\times\!10^{11}s^{26} -3.868\!\times\!10^{08}s^{27} +916980.98s^{28} -1384.5606s^{29} +s^{30} $";
239 assert_checkequal(prettyprint(D,"tex","["), DResultLatex)
240
241 DResultMathML="<mn>1.553</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>47</mn></mrow></msup><mo>-</mo><mn>1.738</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>47</mn></mrow></msup><mi>s</mi><mo>+</mo><mn>8.994</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>46</mn></mrow></msup><msup><mi>s</mi><mn>2</mn></msup> <mo>-</mo><mn>2.885</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>46</mn></mrow></msup><msup><mi>s</mi><mn>3</mn></msup> <mo>+</mo><mn>6.474</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>45</mn></mrow></msup><msup><mi>s</mi><mn>4</mn></msup> <mo>-</mo><mn>1.086</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>45</mn></mrow></msup><msup><mi>s</mi><mn>5</mn></msup> <mo>+</mo><mn>1.422</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>44</mn></mrow></msup><msup><mi>s</mi><mn>6</mn></msup> <mo>-</mo><mn>1.493</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>43</mn></mrow></msup><msup><mi>s</mi><mn>7</mn></msup> <mo>+</mo><mn>1.284</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>42</mn></mrow></msup><msup><mi>s</mi><mn>8</mn></msup> <mo>-</mo><mn>9.182</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>40</mn></mrow></msup><msup><mi>s</mi><mn>9</mn></msup> <mo>+</mo><mn>5.527</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>39</mn></mrow></msup><msup><mi>s</mi><mn>10</mn></msup> <mo>-</mo><mn>2.824</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>38</mn></mrow></msup><msup><mi>s</mi><mn>11</mn></msup> <mo>+</mo><mn>1.233</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>37</mn></mrow></msup><msup><mi>s</mi><mn>12</mn></msup> <mo>-</mo><mn>4.626</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>35</mn></mrow></msup><msup><mi>s</mi><mn>13</mn></msup> <mo>+</mo><mn>1.496</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>34</mn></mrow></msup><msup><mi>s</mi><mn>14</mn></msup> <mo>-</mo><mn>4.182</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>32</mn></mrow></msup><msup><mi>s</mi><mn>15</mn></msup> <mo>+</mo><mn>1.011</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>31</mn></mrow></msup><msup><mi>s</mi><mn>16</mn></msup> <mo>-</mo><mn>2.116</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>29</mn></mrow></msup><msup><mi>s</mi><mn>17</mn></msup> <mo>+</mo><mn>3.826</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>27</mn></mrow></msup><msup><mi>s</mi><mn>18</mn></msup> <mo>-</mo><mn>5.965</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>25</mn></mrow></msup><msup><mi>s</mi><mn>19</mn></msup> <mo>+</mo><mn>7.990</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>23</mn></mrow></msup><msup><mi>s</mi><mn>20</mn></msup> <mo>-</mo><mn>9.144</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>21</mn></mrow></msup><msup><mi>s</mi><mn>21</mn></msup> <mo>+</mo><mn>8.876</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>19</mn></mrow></msup><msup><mi>s</mi><mn>22</mn></msup> <mo>-</mo><mn>7.234</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>17</mn></mrow></msup><msup><mi>s</mi><mn>23</mn></msup> <mo>+</mo><mn>4.885</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>15</mn></mrow></msup><msup><mi>s</mi><mn>24</mn></msup> <mo>-</mo><mn>2.683</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>13</mn></mrow></msup><msup><mi>s</mi><mn>25</mn></msup> <mo>+</mo><mn>1.167</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>11</mn></mrow></msup><msup><mi>s</mi><mn>26</mn></msup> <mo>-</mo><mn>3.868</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow><mo>+</mo><mn>08</mn></mrow></msup><msup><mi>s</mi><mn>27</mn></msup> <mo>+</mo><mn>916980.98</mn><msup><mi>s</mi><mn>28</mn></msup> <mo>-</mo><mn>1384.5606</mn><msup><mi>s</mi><mn>29</mn></msup> <mo>+</mo><msup><mi>s</mi><mn>30</mn></msup> ";
242 assert_checkequal(prettyprint(D,"mathml","["), DResultMathML);
243
244 // With complex coefficients
245 // .........................
246 // 1)
247 p = (%i-%z).^[1 3;2 4];
248
249 // LaTeX
250 ref = "${\begin{pmatrix}i-z &-i+3z +3iz^{2} -z^{3} \cr -1-2iz +z^{2} &1+4iz -6z^{2} -4iz^{3} +z^{4} \cr \end{pmatrix}}$";
251 assert_checkequal(prettyprint(p), ref);
252
253 // TeX
254 ref = "${\pmatrix{i-z &-i+3z +3iz^{2} -z^{3} \cr -1-2iz +z^{2} &1+4iz -6z^{2} -4iz^{3} +z^{4} \cr }}$";
255 assert_checkequal(prettyprint(p, "tex"), ref);
256
257 // MathML
258 ref = [""
259 "<mfenced open=""("" close="")"">"
260 "<mtable>"
261 "<mtr>"
262 "<mtd><mi>i</mi><mo>-</mo><mi>z</mi></mtd>"
263 "<mtd><mo>-</mo><mi>i</mi><mo>+</mo><mn>3</mn><mi>z</mi><mo>+</mo><mn>3</mn><mi>i</mi><msup><mi>z</mi><mn>2</mn></msup> <mo>-</mo><msup><mi>z</mi><mn>3</mn></msup> </mtd>"
264 "</mtr>"
265 "<mtr>"
266 "<mtd><mo>-</mo><mn>1</mn><mo>-</mo><mn>2</mn><mi>i</mi><mi>z</mi><mo>+</mo><msup><mi>z</mi><mn>2</mn></msup> </mtd>"
267 "<mtd><mn>1</mn><mo>+</mo><mn>4</mn><mi>i</mi><mi>z</mi><mo>-</mo><mn>6</mn><msup><mi>z</mi><mn>2</mn></msup> <mo>-</mo><mn>4</mn><mi>i</mi><msup><mi>z</mi><mn>3</mn></msup> <mo>+</mo><msup><mi>z</mi><mn>4</mn></msup> </mtd>"
268 "</mtr>"
269 "</mtable>"
270 "</mfenced>"
271 ""];
272 ref = strcat(ref, ascii(10));
273 assert_checkequal(prettyprint(p, "mathml"), ref);
274
275 // 2) ---------
276 p = poly(complex([1 0 -2],[%nan 0 -1]),"x","coeff");
277 // LaTeX
278 assert_checkequal(prettyprint(p), "$1+{\mathrm{NaN}}i-(2+i)x^{2} $");
279 // TeX
280 assert_checkequal(prettyprint(p,"tex"), "$1+{\mathrm{NaN}}i-(2+i)x^{2} $");
281 // MathML
282 ref = "<mn>1</mn><mo>+</mo><mi>NaN</mi><mi>i</mi><mo>-</mo><mfenced separator=""""><mrow><mn>2</mn><mo>+</mo><mi>i</mi></mrow></mfenced><msup><mi>x</mi><mn>2</mn></msup> ";
283 assert_checkequal(prettyprint(p,"mathml"), ref);
284
285
286 // CELLS
287 // =====
288 c = {["a bc";"defg"], %t ; (1-%s)^3, %pi};
289 // LaTeX
290 ref = "${\begin{pmatrix}{\begin{pmatrix}\mathsf{\text{a bc}}\cr \mathsf{\text{defg}}\cr \end{pmatrix}}&T\cr 1-3s +3s^{2} -s^{3} &3.1415927\cr \end{pmatrix}}$";
291 assert_checkequal(prettyprint(c), ref);
292
293 // TeX
294 ref = "${\pmatrix{{\pmatrix{\mathsf{\text{a bc}}\cr \mathsf{\text{defg}}\cr }}&T\cr 1-3s +3s^{2} -s^{3} &3.1415927\cr }}$";
295 assert_checkequal(prettyprint(c, "tex"), ref);
296
297 // MathML
298 ref = [""
299 "<mfenced open=""{"" close=""}"">"
300 "<mtable>"
301 "<mtr>"
302 "<mtd>"
303 "<mfenced open=""{"" close=""}"">"
304 "<mtable>"
305 "<mtr>"
306 "<mtd><mi>a bc</mi></mtd>"
307 "</mtr>"
308 "<mtr>"
309 "<mtd><mi>defg</mi></mtd>"
310 "</mtr>"
311 "</mtable>"
312 "</mfenced>"
313 "</mtd>"
314 "<mtd><mi>T</mi></mtd>"
315 "</mtr>"
316 "<mtr>"
317 "<mtd><mn>1</mn><mo>-</mo><mn>3</mn><mi>s</mi><mo>+</mo><mn>3</mn><msup><mi>s</mi><mn>2</mn></msup> <mo>-</mo><msup><mi>s</mi><mn>3</mn></msup> </mtd>"
318 "<mtd><mn>3.1415927</mn></mtd>"
319 "</mtr>"
320 "</mtable>"
321 "</mfenced>"
322 ""];
323 ref = strcat(ref, ascii(10));
324 assert_checkequal(prettyprint(c, "mathml", "{"), ref);