* Bugs 16071+16072+16075 fixed: prettyprint() debugged & a bit improved 58/20958/26
Samuel GOUGEON [Sat, 20 Apr 2019 22:09:27 +0000 (00:09 +0200)]
  * http://bugzilla.scilab.org/16071 :
    - 0*%z : 0 => 0z  (to show the symbolic variable)
    - complex(1,%nan): 1NaNi => 1 + Nani
    - text input
      => tex|latex:
        $ \ % & { } ~ ^ characters were not protected.
        Spaces were not protected (words were concatenated).
      => mathML: <mi></mi> were missing. "<" was not protected

    - MathML:
      . MathJax does not support <infinity/> => <mi>∞</mi>
      . Any syslin was parenthesed, even with delimiter=""

    - Documentation:
      . ")" was wrongly indicated as supported delimiter.
      . "" as possible delimiter was not documented, to not use any
        matrix bracketting.

    - Improvements:
      . 6.21D+23 : 6.21  x  10^+23  => 6.21 x 10^23
      . 1 + (-2-3i)z  => 1 - (2+3i)z
      . exportFormat was uselessly case-sensitive => no longer the case
      . Default argins had to be explicitly provided when an explicit
        argin follows => now just skip them with ,,.
      . polynomials => tex|latex: a space-free unbreakable string result
        was delivered => now 1 space added after each power term,
        to ease wrapping when required.
      . MathML : formatting of the output improved = \n (ascii(10))
        added before and/or after each <mtable>, </mtable>, <mtr>, </mtr>,
        <mtd>, <mfenced> and </mfenced> for and around tables, enabling
        to easily split the result and then properly indent it with
        external tools.

  * http://bugzilla.scilab.org/16072
      encoded integers were actually NOT supported

  * http://bugzilla.scilab.org/16075
      prettyprint() was broken for cells arrays

  * Unit tests added for texts, integers, complex numbers, polynomials
    with complex coefficients, cells, linear systems, and extended for
    decimal numbers.

Change-Id: Id2fca732444e0cfe1932a3a82825aa09489d7ae5

scilab/CHANGES.md
scilab/modules/string/help/en_US/prettyprint.xml
scilab/modules/string/help/ja_JP/prettyprint.xml
scilab/modules/string/macros/prettyprint.sci
scilab/modules/string/tests/unit_tests/prettyprint.dia.ref [deleted file]
scilab/modules/string/tests/unit_tests/prettyprint.tst
scilab/modules/string/tests/unit_tests/prettyprint_syslin.tst [new file with mode: 0644]

index 24187c5..1585c12 100644 (file)
@@ -88,7 +88,10 @@ Feature changes and additions
   - Several bits can now be retrieved from each component of an input array.
 * `edit` now accepts a line number as text (like "23").
 * `profileEnable`, `profileDisable`, `profileGetInfo` could be used to instrument functions and gather execution information within Scilab.
-
+* `prettyprint()` is upgraded:
+  - Integer and Text input are now actually supported.
+  - Default input arguments can be skipped instead of still having to be provided.
+  - The result string is better formatted to be easily wrappable and indentable.
 
 Help pages:
 -----------
@@ -155,3 +158,6 @@ Bug Fixes
 * [#16005](http://bugzilla.scilab.org/show_bug.cgi?id=16005): The `intdec` example was biased and not robust when changing sampling frequencies.
 * [#16007](http://bugzilla.scilab.org/show_bug.cgi?id=16007): Non-integer index in sparse makes Scilab crash.
 * [#16021](http://bugzilla.scilab.org/show_bug.cgi?id=16021): `tand([-90 90])` answered [Nan Nan] instead of [-Inf, Inf]. `cotd([-90 90])` answered [Nan Nan] instead of [0 0]. `1 ./cosd([-90 90])` answered [Inf -Inf] instead of [Inf Inf].
+* [#16071](http://bugzilla.scilab.org/show_bug.cgi?id=16071): `prettyprint(complex(1,%nan))` omitted the "+" in `1 + Nani`. It printed positive exponents with a useless "+". For any input nul polynomial, the string result never included the name of the variable. Default input arguments could not be skipped. ExportFormat was uselessly case-sensitive. For tex|latex: for text input, $ \ % & { } ~ and ^ special characters were not protected ; spaces were not protected, all words were concatenated ; for polynomials and rationals, the result string could be extremely long and not easily wrappable. For MathML: "<" was not protected ; <mi></mi> were missing for text input ; <mtable>, </mtable>, <mtr>, </mtr>, <mtd>, <mfenced> and </mfenced> tags were not wrapped and could not be indented. Delimiters: "" was not documented as possible value ; ")" was wrongly documented. Dynamical linear systems were not documented as possible input.
+* [#16072](http://bugzilla.scilab.org/show_bug.cgi?id=16072): `prettyprint()` did not actually support input encoded integers.
+* [#16075](http://bugzilla.scilab.org/show_bug.cgi?id=16075): `prettyprint()` was broken for cells.
index 25d7d37..c48e9e9 100644 (file)
             <varlistentry>
                 <term>a</term>
                 <listitem>
-                    <para> is a Scilab variable</para>
+                    <para>a Scilab object.
+                        <itemizedlist>
+                            <listitem>
+                                Supported types: booleans, encoded integers, real or complex numbers,
+                                polynomials and rationals with real or complex coefficients, texts,
+                                cells, linear dynamical systems (as generated with syslin()),
+                                other Tlists.
+                            </listitem>
+                            <listitem>
+                                Supported sizes: scalar, vector, matrix. Hypermatrices are
+                                not supported (only the first page is processed.)
+                            </listitem>
+                        </itemizedlist>
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>exportFormat</term>
                 <listitem>
                     <para>
-                      is the output format. Possible values are 'latex' (default), 'tex', or 'mathml'.
+                      is the output format. Possible case-insensitive values are 'latex' (default),
+                      'tex', or 'mathml'.
                     </para>
                 </listitem>
             </varlistentry>
@@ -46,8 +60,9 @@
                 <term>delimiter</term>
                 <listitem>
                     <para> is a string indicating the delimiter to bracket the whole
-                       resulting matrix. It's only used if <varname>processByElement</varname> is
-                       false. It can be '(' (default), '{', '[', '|', or '||'.
+                       resulting matrix. It is used only if <varname>processByElement</varname> is
+                       false. It can be '(' (default), '{', '[', '|', '||', or '' if no bracketting
+                      is required.
                     </para>
                 </listitem>
             </varlistentry>
@@ -55,7 +70,7 @@
                 <term>processByElement</term>
                 <listitem>
                   <para> is a boolean: If set to <literal>%f</literal> (default), the result
-                    <varname>str</varname> is a single single representing the whole input
+                    <varname>str</varname> is a single string representing the whole input
                     matrix. Otherwise, <varname>str</varname> has as many elements as the input
                     matrix <varname>a</varname>.
                     </para>
             Formats can be TeX, LaTeX or MathML.
             They can be used in third party applications but also within Scilab with the most of the
             <link linkend="math_rendering_features_in_graphic">Scilab graphic features</link>.
-            The following types are handled by this function:
         </para>
-        <itemizedlist>
-            <listitem>
-                <para>Real / Complex matrices</para>
-            </listitem>
-            <listitem>
-                <para>Polynomial types</para>
-            </listitem>
-            <listitem>
-                <para>Boolean</para>
-            </listitem>
-            <listitem>
-                <para>Integer</para>
-            </listitem>
-            <listitem>
-                <para>String</para>
-            </listitem>
-            <listitem>
-                <para>Tlist</para>
-            </listitem>
-            <listitem>
-                <para>Rational</para>
-            </listitem>
-            <listitem>
-                <para>Cell</para>
-            </listitem>
-        </itemizedlist>
-        <para/>
     </refsection>
     <refsection>
         <title>Examples</title>
@@ -138,32 +125,34 @@ xstring(0.2,0.2,prettyprint(G*s-1)); // Show a polynomial through a LaTeX repres
                 <link linkend="math_rendering_features_in_graphic">math_rendering_features_in_graphic</link>
             </member>
             <member>
-                <link linkend="xtitle">xtitle</link>
-            </member>
-            <member>
-                <link linkend="axes_properties">axes_properties</link>
-            </member>
-            <member>
-                <link linkend="label_properties">label_properties</link>
+                <link linkend="xnumb">xnumb</link>
             </member>
             <member>
-                <link linkend="legend_properties">legend_properties</link>
+                <link linkend="string">string</link>
             </member>
             <member>
-                <link linkend="sci2exp">sci2exp</link>
-            </member>
-            <member>
-                <link linkend="text_properties">text_properties</link>
+                <link linkend="pol2str">pol2str</link>
             </member>
             <member>
-                <link linkend="xstringb">xstringb</link>
+                <link linkend="msprintf">msprintf</link>
             </member>
             <member>
-                <link linkend="xstringl">xstringl</link>
+                <link linkend="uicontrol">uicontrol(table)</link>
             </member>
             <member>
-                <link linkend="xstring">xstring</link>
+                <link linkend="sci2exp">sci2exp</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection role="history">
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.2.0</revnumber>
+                <revdescription>
+                    Function introduced.
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 5e7785a..81f9516 100644 (file)
@@ -4,7 +4,10 @@
  * This help file was generated from prettyprint.sci using help_from_sci().
  *
  -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="prettyprint" xml:lang="ja">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns3="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
+          xmlns:scilab="http://www.scilab.org" xml:id="prettyprint" xml:lang="ja">
     <refnamediv>
         <refname>prettyprint</refname>
         <refpurpose>Scilabデータ型からTeX, LaTeXまたはMathML形式の出力を得る</refpurpose>
             <varlistentry>
                 <term>a</term>
                 <listitem>
-                    <para>Scilab変数</para>
+                    <para>a Scilab object.
+                        <itemizedlist>
+                            <listitem>
+                                Supported types: booleans, encoded integers, real or complex numbers,
+                                polynomials and rationals with real or complex coefficients, texts,
+                                cells, linear dynamical systems (as generated with syslin()),
+                                other Tlists.
+                            </listitem>
+                            <listitem>
+                                Supported sizes: scalar, vector, matrix. Hypermatrices are
+                                not supported (only the first page is processed.)
+                            </listitem>
+                        </itemizedlist>
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>exportFormat</term>
                 <listitem>
                     <para>出力形式で,省略された場合はデフォルトで'latex'が使用されます.
-                        'latex', 'tex' または 'mathml'とすることができます.
+                        'latex', 'tex' または 'mathml'とすることができます. It is case-insensitive.
                     </para>
                 </listitem>
             </varlistentry>
@@ -41,7 +57,8 @@
                 <listitem>
                     <para> 結果の行列で使用されるデリミタを示す文字列で,
                         isWrappedがtrueの場合にみ使用されます.
-                        デリミタは '(', '{', '[', '|', '||' または ')' とすることができます
+                        It can be '(' (default), '{', '[', '|', '||', or '' if no bracketting
+                        is required.
                     </para>
                 </listitem>
             </varlistentry>
             Scilab内でも多くの
             <link linkend="math_rendering_features_in_graphic">Scilabグラフィック機能</link>で
             使用できます.
-            以下の型がこの関数で処理できます:
         </para>
-        <itemizedlist>
-            <listitem>
-                <para>実数 / 複素数行列</para>
-            </listitem>
-            <listitem>
-                <para>多項式型</para>
-            </listitem>
-            <listitem>
-                <para>論理値</para>
-            </listitem>
-            <listitem>
-                <para>整数</para>
-            </listitem>
-            <listitem>
-                <para>文字列</para>
-            </listitem>
-            <listitem>
-                <para>tlist</para>
-            </listitem>
-            <listitem>
-                <para>有理数</para>
-            </listitem>
-            <listitem>
-                <para>セル</para>
-            </listitem>
-        </itemizedlist>
-        <para/>
     </refsection>
     <refsection>
         <title>例</title>
@@ -126,32 +115,34 @@ xstring(0.2,0.2,prettyprint(G*s-1)); // LaTeX表現により多項式を表示
                 <link linkend="math_rendering_features_in_graphic">math_rendering_features_in_graphic</link>
             </member>
             <member>
-                <link linkend="xtitle">xtitle</link>
-            </member>
-            <member>
-                <link linkend="axes_properties">axes_properties</link>
-            </member>
-            <member>
-                <link linkend="label_properties">label_properties</link>
+                <link linkend="xnumb">xnumb</link>
             </member>
             <member>
-                <link linkend="legend_properties">legend_properties</link>
+                <link linkend="string">string</link>
             </member>
             <member>
-                <link linkend="sci2exp">sci2exp</link>
-            </member>
-            <member>
-                <link linkend="text_properties">text_properties</link>
+                <link linkend="pol2str">pol2str</link>
             </member>
             <member>
-                <link linkend="xstringb">xstringb</link>
+                <link linkend="msprintf">msprintf</link>
             </member>
             <member>
-                <link linkend="xstringl">xstringl</link>
+                <link linkend="uicontrol">uicontrol(table)</link>
             </member>
             <member>
-                <link linkend="xstring">xstring</link>
+                <link linkend="sci2exp">sci2exp</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection role="history">
+        <title>履歴</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.2.0</revnumber>
+                <revdescription>
+                    Function introduced.
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index c120681..f0766c5 100644 (file)
@@ -1,7 +1,7 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2009-2010 - Calixte Denizet
-//
 // Copyright (C) 2012 - 2016 - Scilab Enterprises
+// Copyright (C) 2019 - Samuel GOUGEON
 //
 // This file is hereby licensed under the terms of the GNU GPL v2.0,
 // pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -69,60 +69,31 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
     //
     // Authors
     // Calixte Denizet
+    // Samuel Gougeon
 
-    nargs = argn(2);
-
-    select nargs
-    case 0 then
+    if argn(2)<1 | argn(2)>5
         error(msprintf(gettext("%s: Wrong number of input argument(s): %d to %d expected."),"prettyprint",1,4));
-    case 1 then
-        exportFormat="latex";
-        delimiter = "(";
-        processByElement = %F;
-        isWrapped = %T;
-    case 2 then
-        if type(exportFormat) <> 10 then
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
-        end
-        delimiter = "(";
-        processByElement = %F;
-        isWrapped = %T;
-    case 3 then
-        if type(exportFormat) <> 10 then
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
-        end
-        if type(delimiter) <> 10 | (delimiter <> "(" &  delimiter <> "[" & delimiter <> "|" & delimiter <> "||" & delimiter <> "{" & delimiter <> "") then
-            error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"prettyprint",3,"(","[","|","||","{",""));
-        end
-        processByElement = %F;
-        isWrapped = %T;
-    case 4 then
-        if type(exportFormat) <> 10 then
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
-        end
-        if type(delimiter) <> 10 | (delimiter <> "(" &  delimiter <> "[" & delimiter <> "|" & delimiter <> "||" & delimiter <> "{" & delimiter <> "") then
-            error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"prettyprint",3,"(","[","|","||","{",""));
-        end
-        if type(processByElement) <> 4 then
-            error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",4));
-        end
-        isWrapped = %T;
-    case 5
-        if type(exportFormat) <> 10 then
-            error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
-        end
-        if type(delimiter) <> 10 | (delimiter <> "(" &  delimiter <> "[" & delimiter <> "|" & delimiter <> "||" & delimiter <> "{" & delimiter <> "") then
-            error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"prettyprint",3,"(","[","|","||","{",""));
-        end
-        if type(processByElement) <> 4 then
-            error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",4));
-        end
-        if type(isWrapped) <> 4 then
-            error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",5));
-        end
-    else
-        error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected"),"prettyprint",1,4));
     end
+
+    if ~isdef("exportFormat","l")    , exportFormat = "latex", end
+    if ~isdef("delimiter","l")       , delimiter = "("       , end
+    if ~isdef("processByElement","l"), processByElement = %F,  end
+    if ~isdef("isWrapped","l")       , isWrapped = %T,         end
+
+    if type(exportFormat) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"prettyprint",2));
+    end
+    if type(delimiter) <> 10 | and(delimiter <> ["(" "[" "|" "||" "{" ""]) then
+        error(msprintf(gettext("%s: Wrong value for input argument #%d: ''%s'', ''%s'', ''%s'', ''%s'', ''%s'' or ''%s'' expected.\n"),"prettyprint",3,"(","[","|","||","{",""));
+    end
+    if type(processByElement) <> 4 then
+        error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",4));
+    end
+    if type(isWrapped) <> 4 then
+        error(msprintf(gettext("%s: Wrong type for argument #%d: Boolean expected.\n"),"prettyprint",5));
+    end
+
+    // ---------------------
     try
         execstr("[plus,minus,img,op,cp,ow,cw,d2s]=" + exportFormat + "conf()");
     catch
@@ -131,16 +102,18 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
 
     typ = type(a);
 
+
     select typ
-        //Scalar type : real or complex
     case 1 then
+        // number : real or complex
         if or(isinf(a) | isnan(a)) | norm(imag(a)) > %eps * norm(real(a)) then
             str = comp2str(a,plus,minus,img,d2s);
         else
             str = comp2str(real(a),plus,minus,img,d2s);
         end
-        //Polynomial type
+
     case 2 then
+        //Polynomial type
         x = varn(a);
         C = coeff(a);
         [m,n] = size(a);
@@ -163,27 +136,58 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
                 end
             end
         end
-        //The null polynomial is represented by '' so we must replace it by '0'
-        str(str == "") = d2s(0);
-        //Boolean type
+        //The null polynomial is represented by '' so we must replace it by '0z'
+        if exportFormat=="mathml"
+            str(str == "") = d2s(0) + "<mi>" + x + "</mi>";
+        else
+            str(str == "") = d2s(0) + x;
+        end
+
     case 4 then
+        //Boolean type
         str = "F" + emptystr(a);
         str(a) = "T";
         execstr("str=" + exportFormat + "exp(str,1)");
-        //Int type
+
     case 8 then
+        //Int type
         str = d2s(a);
-        //String type
+
     case 10 then
+        //String type
+        if or(exportFormat == ["tex" "latex"])
+            a = strsubst(a, "\", "\backslash\!")
+            a = strsubst(a, "$", "\$")
+            a = strsubst(a, "%", "\%")
+            a = strsubst(a, "&", "\&")
+            a = strsubst(a, "{", "\{")
+            a = strsubst(a, "}", "\}")
+            a = strsubst(a, "~", "\sim\!")
+            a = strsubst(a, "^", "\^\;\,")
+            a = strsubst(a, "<", "\!<\!")
+            a = strsubst(a, ">", "\!>\!")
+            // a = strsubst(a, "_", "\_ ")  // not required
+            // a = strsubst(a, "#", "\#")   // not required
+            if ~processByElement | isWrapped
+                a = "\mathsf{\text{" + a + "}}" // default protection of spaces
+                // Otherwise: we let the user choose the type of text
+                // encapsulation
+            end
+        elseif exportFormat == "mathml"
+            a = strsubst(a, "<", "&lt;")
+            // " ' and & do not need protection
+            execstr("a = " + exportFormat + "exp(a,1)");
+        end
         str = a;
-        //Tlist type
+
     case 16 then
+        //Tlist type
         t = a(1);
         select t(1)
             //Rationnal type
         case "r" then
-            num = prettyprint(a("num"),exportFormat,"(",%T,%F);
-            den = prettyprint(a("den"),exportFormat,"(",%T,%F);
+            num = prettyprint(a("num"), exportFormat, "(", %T, %F);
+            den = prettyprint(a("den"), exportFormat, "(", %T, %F);
             execstr("str=rational2" + exportFormat + "(num,den)");
             //Linear state space type
         case "lss" then
@@ -192,11 +196,12 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
             str = unknown_type(t(1),a,exportFormat);
             return;
         end
+
     case 17  then
-        a1=getfield(1,a);
-        select a1(1)
-            //Cell type
+        tof = typeof(a);
+        select tof
         case "ce" then
+            //Cell type
             dim = double(size(a));
             L = length(dim);
             if L >= 3 then
@@ -210,12 +215,12 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
                 end
             end
         else
-            str = unknown_type(a1(1),a,exportFormat);
+            str = unknown_type(tof,a,exportFormat);
             return;
         end
     else
         str = unknown_type(typeof(a),a,exportFormat);
-        return;
+        return
     end
 
     [m,n] = size(a);
@@ -228,6 +233,10 @@ function str = prettyprint(a, exportFormat, delimiter, processByElement, isWrapp
     end
 endfunction
 
+// ----------------------------------------------------------------------------
+
+// MATHML
+// ======
 //This function gives different elements of configuration
 //plus is '+', minus is '-', img is sqrt(-1), op and cp are opening ang closing
 //parenthesis (useful to generate complex coeff in polynomials), ow and cw are
@@ -247,7 +256,7 @@ endfunction
 //This function generates var^n (useful for polynomials)
 function str = mathmlexp(var,n)
     if n >= 2 then
-        str = "<msup><mi>" + var + "</mi><mn>" + string(n) + "</mn></msup>";
+        str = "<msup><mi>" + var + "</mi><mn>" + string(n) + "</mn></msup> ";
     elseif n == 1 then
         str = "<mi>" + var + "</mi>";
     else
@@ -257,31 +266,43 @@ endfunction
 
 //This function creates a fraction with the given numerator and denominator
 function str = rational2mathml(num,den)
-    str = "<mfrac><mrow>" + num + "</mrow><mrow>" + den + "</mrow></mfrac>";
+    nl = ascii(10)
+    str = "<mfrac>" + nl + ..
+            "<mrow>" + nl + num + nl + "</mrow>" + nl + ..
+            "<mrow>" + nl + den + nl + "</mrow>" + nl + ..
+          "</mfrac>";
 endfunction
 
 //This function converts a double into a mathml string
 //Negative and positive are handled and the scientific notation too
 function str = mathmldbl2str(x)
     if x == %inf then
-        str = "<infinity/>";
+        str = "<mi>∞</mi>";
     elseif x == -%inf then
-        str = "<mo>-</mo><infinity/>";
+        str = "<mo>-</mo><mi>∞</mi>";
     elseif isnan(x) then
         str = "<mi>NaN</mi>";
     else
         str= strsubst(string(x),"-","<mo>-</mo><mn>");
-        if strindex(str,"D") <> [] then
-            str = strsubst(str,"+","<mo>+</mo><mn>");
-            str = strsubst(str,"D","</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow>");
-            if x > 0 then
-                str = "<mn>" + str;
+        if type(x) <> 8
+            if strindex(str,"D") <> [] then
+                str = strsubst(str,"+","<mo>+</mo><mn>");
+                str = strsubst(str,"D","</mn><mo>&#x00D7;</mo><msup><mn>10</mn><mrow>");
+                if x > 0 then
+                    str = "<mn>" + str;
+                end
+                str = str + "</mn></mrow></msup>";
+            elseif x >= 0 then
+                str = "<mn>" + str + "</mn>";
+            else
+                str = str + "</mn>";
             end
-            str = str + "</mn></mrow></msup>";
-        elseif x >= 0 then
-            str = "<mn>" + str + "</mn>";
         else
-            str = str + "</mn>";
+            k = x>=0
+            if k~=[]
+                str(k) =  "<mn>" + str(k)
+            end
+            str = str + "</mn>"
         end
     end
 endfunction
@@ -291,6 +312,7 @@ function str = mathmlmatrix(mat,delimiter)
     if argn(2) == 1 then
         delimiter = "(";
     end
+    nl = ascii(10)
     select delimiter
     case "[" then
         com = "<mfenced open=""["" close=""]"">";
@@ -299,7 +321,7 @@ function str = mathmlmatrix(mat,delimiter)
     case "|" then
         com = "<mfenced open=""&#x2223;"" close=""&#x2223;"">";
     case "" then
-        com = "<mfenced>";
+        com = "<mfenced open="""" close="""">";
     case "{" then
         com = "<mfenced open=""{"" close=""}"">";
     case "||" then
@@ -308,33 +330,53 @@ function str = mathmlmatrix(mat,delimiter)
         com = "<mfenced open=""("" close="")"">";
     end
     [m,n] = size(mat);
-    str = com + "<mtable>";
+    str = nl + com + nl + "<mtable>";
     for i=1:m do
-        str = str + "<mtr><mtd>" + strcat(mat(i,:),"</mtd><mtd>") + "</mtd></mtr>";
+        str = str + nl + "<mtr>" + nl + ..
+              "<mtd>" + strcat(mat(i,:),"</mtd>"+nl+"<mtd>") + "</mtd>" + nl + ..
+              "</mtr>";
     end
-    str = str + "</mtable></mfenced>";
+    str = str + nl + "</mtable>" + nl + "</mfenced>" + nl;
 endfunction
 
 //This function handles the syslin
 function str = lss2mathml(sys)
+    nl = ascii(10);
     ptp = "<mo>(</mo><mi>t</mi><mo>)</mo>";
     if sys(7) == "c" then
         der = "<mrow><mover><mi>X</mi><mo>.</mo></mover>" + ptp + "</mrow>";
     else
         der = "<mrow><mover><mi>X</mi><mo>+</mo></mover>" + ptp + "</mrow>"
     end
-    str = "<mfenced close="""" open=""{""><mtable columnalign=""right center left""><mtr><mtd>" + der + "</mtd><mtd><mo>=</mo></mtd><mtd>" + prettyprint(sys(2),"mathml","(",%F,%F) + "<mrow><mi>X</mi>" + ptp + "</mrow><mo>+</mo>" + prettyprint(sys(3),"mathml","(",%F,%F) + "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr><mtr><mtd><mrow><mi>Y</mi>" + ptp + "</mrow></mtd><mtd><mo>=</mo></mtd><mtd>" + prettyprint(sys(4),"mathml","(",%F,%F) + "<mrow><mi>X</mi>" + ptp + "</mrow>";
+    str = "<mfenced close="""" open=""{"">" + nl + ..
+          "<mtable columnalign=""right center left"">" + nl + ..
+          "<mtr>" + ..
+          "<mtd>" + der + "</mtd><mtd><mo>=</mo></mtd>" + ..
+          "<mtd>" + prettyprint(sys(2),"mathml","(",%F,%F) + ..
+          "<mrow><mi>X</mi>" + ptp + "</mrow><mo>+</mo>" + ..
+          prettyprint(sys(3),"mathml","(",%F,%F) + ..
+          "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>" + nl + ..
+          "<mtr><mtd><mrow><mi>Y</mi>" + ptp + "</mrow></mtd>" + ..
+          "<mtd><mo>=</mo></mtd>" + ..
+          "<mtd>" + prettyprint(sys(4),"mathml","(",%F,%F) + "<mrow><mi>X</mi>" + ptp + "</mrow>";
     try
         if norm(sys(5),1) == 0 then
-            str = str + "</mtd></mtr></mtable></mfenced>";
+            str = str + "</mtd></mtr>"
         else
-            str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr></mtable></mfenced>";
+            str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + ..
+            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>" 
         end
     catch
-        str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr></mtable></mfenced>";
+        str = str + "<mo>+</mo>" + prettyprint(sys(5),"mathml","(",%F,%F) + ..
+            "<mrow><mi>U</mi>" + ptp + "</mrow></mtd></mtr>" 
     end
+    str = str + nl + "</mtable>" + nl + "</mfenced>" + nl;
 endfunction
 
+// ----------------------------------------------------------------------------
+
+// LATEX
+// =====
 function [plus,minus,img,op,cp,ow,cw,d2s] = latexconf()
     plus = "+";
     minus = "-";
@@ -354,6 +396,9 @@ function str = latexexp(var,n)
     else
         str = "";
     end
+    if typ==2 then
+        str = str + " " // Makes easier wrapping long polynomials
+    end
 endfunction
 
 function str = rational2latex(num,den)
@@ -369,8 +414,9 @@ function str = latexdbl2str(x)
         str = "{\mathrm{NaN}}";
     else
         str = string(x);
-        if strindex(str,"D") <> [] then
-            str = strsubst(str,"D","\times10^{");
+        if type(x)~=8 & strindex(str,"D") <> [] then
+            str = strsubst(str,"D+","D");
+            str = strsubst(str,"D","\!\times\!10^{");
             str = str + "}";
         end
     end
@@ -382,7 +428,10 @@ function str = lss2latex(sys)
     else
         der = "\stackrel{+}{X}(t)"
     end
-    str = "{\left\{\begin{array}{rcl}" + der + "&=&" + prettyprint(sys(2),"latex","(",%F,%F) + " X(t)+" + prettyprint(sys(3),"latex","(",%F,%F) + "U(t)\cr Y(t) &=& " + prettyprint(sys(4),"latex","(",%F,%F) + " X(t) ";
+    str = "{\left\{\begin{array}{rcl}" + der + "&=&" + ..
+            prettyprint(sys(2),"latex","(",%F,%F) + " X(t)+" + ..
+            prettyprint(sys(3),"latex","(",%F,%F) + "U(t)\cr " + ..
+            "Y(t) &=& " + prettyprint(sys(4),"latex","(",%F,%F) + " X(t) ";
     try
         if norm(sys(5),1) == 0 then
             str = str + "\end{array}\right.}";
@@ -417,15 +466,20 @@ function str = latexmatrix(mat,delimiter)
     [m,n] = size(mat);
     str = "{\begin{" + com + "}";
     if m*n == 0 then
+
         str = str + "\ ";
     else
         for i=1:m do
             str = str + strcat(mat(i,:),"&") + "\cr ";
         end
     end
+
     str = str + "\end{" + com + "}}";
 endfunction
 
+// ----------------------------------------------------------------------------
+// TEX
+// ===
 function [plus,minus,img,op,cp,ow,cw,d2s] = texconf()
     [plus,minus,img,op,cp,ow,cw,d2s] = latexconf()
 endfunction
@@ -448,7 +502,8 @@ function str = texdbl2str(x)
     else
         str = string(x);
         if strindex(str,"D") <> [] then
-            str = strsubst(str,"D","\times10^{");
+            str = strsubst(str,"D+","D");
+            str = strsubst(str,"D","\!\times\!10^{");
             str = str + "}";
         end
     end
@@ -460,7 +515,10 @@ function str = lss2tex(sys)
     else
         der = "{\buildrel + \over X(t)}"
     end
-    str = "{\left\{\eqalign{" + der + " &= " + prettyprint(sys(2),"tex","(",%F,%F) + " X(t)+" + prettyprint(sys(3),"tex","(",%F,%F) + "U(t)\cr Y(t) &= " + prettyprint(sys(4),"tex","(",%F,%F) + " X(t) ";
+    str = "{\left\{\eqalign{" + der + " &= " + ..
+          prettyprint(sys(2),"tex","(",%F,%F) + " X(t)+" + ..
+          prettyprint(sys(3),"tex","(",%F,%F) + "U(t)\cr " + ..
+          "Y(t) &= " + prettyprint(sys(4),"tex","(",%F,%F) + " X(t) ";
     try
         if norm(sys(5),1) == 0 then
             str = str + "}\right.}";
@@ -504,6 +562,8 @@ function str = texmatrix(mat,delimiter)
     str = str + "}}";
 endfunction
 
+// ==========================================================================
+
 //This function converts a complex (or a double) into a string in using the
 //function d2s (double2string) fixed by mathmlconf or latexconf.
 function str = comp2str(z,plus,minus,img,d2s)
@@ -537,7 +597,7 @@ function str = comp2str(z,plus,minus,img,d2s)
         else
             str = d2s(re);
         end
-    elseif im > 0 then
+    elseif im > 0 | im<>im then
         if im == 1 then
             str = d2s(re) + plus + img;
         else
@@ -567,9 +627,13 @@ function str = comp2coef(z,var,plus,minus,img,op,cp,d2s)
     end
     re = real(z);
     im = imag(z);
-    if var <> "" then
+    if var <> "" & var <> " " then
         if re <> 0 & im <> 0 then
-            str = plus + op + comp2str(z,plus,minus,img,d2s) + cp + var;
+            if re < 0 then
+                str = minus + op + comp2str(-z,plus,minus,img,d2s) + cp + var;
+            else
+                str = plus + op + comp2str(z,plus,minus,img,d2s) + cp + var;
+            end
         elseif re == 0 & im == 0 then
             str = "";
         elseif re == 1 & im == 0 then
diff --git a/scilab/modules/string/tests/unit_tests/prettyprint.dia.ref b/scilab/modules/string/tests/unit_tests/prettyprint.dia.ref
deleted file mode 100644 (file)
index a5da4cb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// =============================================================================
-// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2009 - DIGITEO - Sylvestre Ledru
-//
-//  This file is distributed under the same license as the Scilab package.
-// =============================================================================
-// <-- CLI SHELL MODE -->
-B = [ ..
-    50.153416    28.06498     40.948255 ; ..
-    43.685876    12.800585    87.841258 ; ..
-    26.931248    77.831286    11.383597 ; ..
-    63.257449    21.190304    19.983377 ; ..
-    40.51954     11.213547    56.186607 ; ..
-    91.847078    68.56896     58.961773 ; ..
-    4.3733433    15.312167    68.539797 ; ..
-    48.185089    69.708506    89.062247 ; ..
-    26.39556     84.155184    50.422128 ; ..
-    41.481037    40.620248    34.936154 ];
-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}}$";
-if prettyprint(B) <> BResultLatex then bugmes();quit;end
-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 }}$";
-if prettyprint(B,"tex") <> BResultTex then bugmes();quit;end
-BResultMathML="<mfenced open=""("" close="")""><mtable><mtr><mtd><mn>50.153416</mn></mtd><mtd><mn>28.06498</mn></mtd><mtd><mn>40.948255</mn></mtd></mtr><mtr><mtd><mn>43.685876</mn></mtd><mtd><mn>12.800585</mn></mtd><mtd><mn>87.841258</mn></mtd></mtr><mtr><mtd><mn>26.931248</mn></mtd><mtd><mn>77.831286</mn></mtd><mtd><mn>11.383597</mn></mtd></mtr><mtr><mtd><mn>63.257449</mn></mtd><mtd><mn>21.190304</mn></mtd><mtd><mn>19.983377</mn></mtd></mtr><mtr><mtd><mn>40.51954</mn></mtd><mtd><mn>11.213547</mn></mtd><mtd><mn>56.186607</mn></mtd></mtr><mtr><mtd><mn>91.847078</mn></mtd><mtd><mn>68.56896</mn></mtd><mtd><mn>58.961773</mn></mtd></mtr><mtr><mtd><mn>4.3733433</mn></mtd><mtd><mn>15.312167</mn></mtd><mtd><mn>68.539797</mn></mtd></mtr><mtr><mtd><mn>48.185089</mn></mtd><mtd><mn>69.708506</mn></mtd><mtd><mn>89.062247</mn></mtd></mtr><mtr><mtd><mn>26.39556</mn></mtd><mtd><mn>84.155184</mn></mtd><mtd><mn>50.422128</mn></mtd></mtr><mtr><mtd><mn>41.481037</mn></mtd><mtd><mn>40.620248</mn></mtd><mtd><mn>34.936154</mn></mtd></mtr></mtable></mfenced>";
-if prettyprint(B,"mathml") <> BResultMathML then bugmes();quit;end
-C = [ %t %t; %f %t ];
-CResultLatex="${\begin{pmatrix}T&T\cr F&T\cr \end{pmatrix}}$";
-if prettyprint(C) <> CResultLatex then bugmes();quit;end
-CResultTex="${\pmatrix{T&T\cr F&T\cr }}$";
-if prettyprint(C,"tex") <> CResultTex then bugmes();quit;end
-CResultMathML="<mfenced open=""("" close="")""><mtable><mtr><mtd><mi>T</mi></mtd><mtd><mi>T</mi></mtd></mtr><mtr><mtd><mi>F</mi></mtd><mtd><mi>T</mi></mtd></mtr></mtable></mfenced>";
-if prettyprint(C,"mathml") <> CResultMathML then bugmes();quit;end
-s=poly(0,"s");p=1+s+2*s^2;
-D=poly(B,"s");
-DResultLatex="$1.553\times10^{+47}-1.738\times10^{+47}s+8.994\times10^{+46}s^{2}-2.885\times10^{+46}s^{3}+6.474\times10^{+45}s^{4}-1.086\times10^{+45}s^{5}+1.422\times10^{+44}s^{6}-1.493\times10^{+43}s^{7}+1.284\times10^{+42}s^{8}-9.182\times10^{+40}s^{9}+5.527\times10^{+39}s^{10}-2.824\times10^{+38}s^{11}+1.233\times10^{+37}s^{12}-4.626\times10^{+35}s^{13}+1.496\times10^{+34}s^{14}-4.182\times10^{+32}s^{15}+1.011\times10^{+31}s^{16}-2.116\times10^{+29}s^{17}+3.826\times10^{+27}s^{18}-5.965\times10^{+25}s^{19}+7.990\times10^{+23}s^{20}-9.144\times10^{+21}s^{21}+8.876\times10^{+19}s^{22}-7.234\times10^{+17}s^{23}+4.885\times10^{+15}s^{24}-2.683\times10^{+13}s^{25}+1.167\times10^{+11}s^{26}-3.868\times10^{+08}s^{27}+916980.98s^{28}-1384.5606s^{29}+s^{30}$";
-if prettyprint(D,"latex","[") <> DResultLatex then bugmes();quit;end
-DResultTex="$1.553\times10^{+47}-1.738\times10^{+47}s+8.994\times10^{+46}s^{2}-2.885\times10^{+46}s^{3}+6.474\times10^{+45}s^{4}-1.086\times10^{+45}s^{5}+1.422\times10^{+44}s^{6}-1.493\times10^{+43}s^{7}+1.284\times10^{+42}s^{8}-9.182\times10^{+40}s^{9}+5.527\times10^{+39}s^{10}-2.824\times10^{+38}s^{11}+1.233\times10^{+37}s^{12}-4.626\times10^{+35}s^{13}+1.496\times10^{+34}s^{14}-4.182\times10^{+32}s^{15}+1.011\times10^{+31}s^{16}-2.116\times10^{+29}s^{17}+3.826\times10^{+27}s^{18}-5.965\times10^{+25}s^{19}+7.990\times10^{+23}s^{20}-9.144\times10^{+21}s^{21}+8.876\times10^{+19}s^{22}-7.234\times10^{+17}s^{23}+4.885\times10^{+15}s^{24}-2.683\times10^{+13}s^{25}+1.167\times10^{+11}s^{26}-3.868\times10^{+08}s^{27}+916980.98s^{28}-1384.5606s^{29}+s^{30}$";
-if prettyprint(D,"tex","[") <> DResultLatex then bugmes();quit;end
-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>";
-if prettyprint(D,"mathml","[") <> DResultMathML then bugmes();quit;end
-if prettyprint(%inf) <> "${\infty}$" then bugmes();quit;end
-if prettyprint([%inf 0  1 -%inf]) <> "${\begin{pmatrix}{\infty}&0&1&{-\infty}\cr \end{pmatrix}}$" then bugmes();quit;end
-if prettyprint([%inf 0; 1 -%inf]) <> "${\begin{pmatrix}{\infty}&0\cr"+...
-      " 1&{-\infty}\cr \end{pmatrix}}$" then bugmes();quit;end
-if prettyprint(%inf,"mathml") <> "<infinity/>" then bugmes();quit;end
index f3a6926..258200b 100644 (file)
@@ -1,11 +1,55 @@
 // =============================================================================
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 2009 - DIGITEO - Sylvestre Ledru
+// Copyright (C) 2019 - Samuel GOUGEON
 //
 //  This file is distributed under the same license as the Scilab package.
 // =============================================================================
 
 // <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+
+// syslin objects: tests in prettyprint_syslin.tst
+
+
+// TEXTS
+// =====
+text = ["André''s got 50% of 1430 $, & the ""remainder"" 1 month later."
+        "x=A\B is such that A*x=B, with A in {a<b, 1-a, ~a, ^a}. _#"];
+// LaTeX
+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}}$";
+assert_checkequal(prettyprint(text), ref);
+
+// TeX
+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 }}$";
+assert_checkequal(prettyprint(text, "tex"), ref);
+
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mi>André''s got 50% of 1430 $, & the ""remainder"" 1 month later.</mi></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mi>x=A\B is such that A*x=B, with A in {a&lt;b, 1-a, ~a, ^a}. _#</mi></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"" ];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(text, "mathml"), ref);
+
+
+// DECIMAL NUMBERS
+// ===============
+assert_checkequal(prettyprint(%inf), "${\infty}$");
+assert_checkequal(prettyprint(%inf,"mathml"), "<mi>∞</mi>");
+
+ref = "${\begin{pmatrix}{\infty}&0&1&{-\infty}\cr \end{pmatrix}}$";
+assert_checkequal(prettyprint([%inf 0  1 -%inf]), ref);
+ref = "${\begin{pmatrix}{\infty}&0\cr 1&{-\infty}\cr \end{pmatrix}}$"
+assert_checkequal(prettyprint([%inf 0; 1 -%inf]), ref);
 
 B = [ ..
     50.153416    28.06498     40.948255 ; ..
@@ -19,41 +63,262 @@ B = [ ..
     26.39556     84.155184    50.422128 ; ..
     41.481037    40.620248    34.936154 ];
 
+// LaTeX
 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}}$";
-if prettyprint(B) <> BResultLatex then pause, end
+assert_checkequal(prettyprint(B), BResultLatex);
 
+// TeX
 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 }}$";
-if prettyprint(B,"tex") <> BResultTex then pause, end
+assert_checkequal(prettyprint(B,"tex"), BResultTex);
 
-BResultMathML="<mfenced open=""("" close="")""><mtable><mtr><mtd><mn>50.153416</mn></mtd><mtd><mn>28.06498</mn></mtd><mtd><mn>40.948255</mn></mtd></mtr><mtr><mtd><mn>43.685876</mn></mtd><mtd><mn>12.800585</mn></mtd><mtd><mn>87.841258</mn></mtd></mtr><mtr><mtd><mn>26.931248</mn></mtd><mtd><mn>77.831286</mn></mtd><mtd><mn>11.383597</mn></mtd></mtr><mtr><mtd><mn>63.257449</mn></mtd><mtd><mn>21.190304</mn></mtd><mtd><mn>19.983377</mn></mtd></mtr><mtr><mtd><mn>40.51954</mn></mtd><mtd><mn>11.213547</mn></mtd><mtd><mn>56.186607</mn></mtd></mtr><mtr><mtd><mn>91.847078</mn></mtd><mtd><mn>68.56896</mn></mtd><mtd><mn>58.961773</mn></mtd></mtr><mtr><mtd><mn>4.3733433</mn></mtd><mtd><mn>15.312167</mn></mtd><mtd><mn>68.539797</mn></mtd></mtr><mtr><mtd><mn>48.185089</mn></mtd><mtd><mn>69.708506</mn></mtd><mtd><mn>89.062247</mn></mtd></mtr><mtr><mtd><mn>26.39556</mn></mtd><mtd><mn>84.155184</mn></mtd><mtd><mn>50.422128</mn></mtd></mtr><mtr><mtd><mn>41.481037</mn></mtd><mtd><mn>40.620248</mn></mtd><mtd><mn>34.936154</mn></mtd></mtr></mtable></mfenced>";
-if prettyprint(B,"mathml") <> BResultMathML then pause, end
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>50.153416</mn></mtd>"
+"<mtd><mn>28.06498</mn></mtd>"
+"<mtd><mn>40.948255</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>43.685876</mn></mtd>"
+"<mtd><mn>12.800585</mn></mtd>"
+"<mtd><mn>87.841258</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>26.931248</mn></mtd>"
+"<mtd><mn>77.831286</mn></mtd>"
+"<mtd><mn>11.383597</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>63.257449</mn></mtd>"
+"<mtd><mn>21.190304</mn></mtd>"
+"<mtd><mn>19.983377</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>40.51954</mn></mtd>"
+"<mtd><mn>11.213547</mn></mtd>"
+"<mtd><mn>56.186607</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>91.847078</mn></mtd>"
+"<mtd><mn>68.56896</mn></mtd>"
+"<mtd><mn>58.961773</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>4.3733433</mn></mtd>"
+"<mtd><mn>15.312167</mn></mtd>"
+"<mtd><mn>68.539797</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>48.185089</mn></mtd>"
+"<mtd><mn>69.708506</mn></mtd>"
+"<mtd><mn>89.062247</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>26.39556</mn></mtd>"
+"<mtd><mn>84.155184</mn></mtd>"
+"<mtd><mn>50.422128</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>41.481037</mn></mtd>"
+"<mtd><mn>40.620248</mn></mtd>"
+"<mtd><mn>34.936154</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"" ];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(B,"mathml"), ref);
 
 
-C = [ %t %t; %f %t ];
+// COMPLEX NUMBERS
+// ===============
+c = complex(0,%nan);
+assert_checkequal(prettyprint(c), "${\mathrm{NaN}}i$");
+assert_checkequal(prettyprint(c,"mathml"), "<mi>NaN</mi><mi>i</mi>");
 
-CResultLatex="${\begin{pmatrix}T&T\cr F&T\cr \end{pmatrix}}$";
-if prettyprint(C) <> CResultLatex then pause, end
+//
+c = [complex(1,%nan), complex(-1.25d-12, 2)
+     complex(%inf,6.1e167), complex(1,-%inf)];
+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}}$";
+assert_checkequal(prettyprint(c), ref);
+ref = "${\pmatrix{1+{\mathrm{NaN}}i&-1.250\!\times\!10^{-12}+2i\cr {\infty}+6.10\!\times\!10^{167}i&1{-\infty}i\cr }}$";
+assert_checkequal(prettyprint(c,"tex"), ref);
+
+
+// INTEGERS
+// ========
+i = int16([
+  26595  1212  4257 -4466  9784
+  -4226  3404  5743    3  10032
+  30471     6 14918  267     30 ]);
+
+// LaTeX
+ref = "${\begin{pmatrix}26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr \end{pmatrix}}$";
+assert_checkequal(prettyprint(i), ref);
 
+// TeX
+ref = "${\pmatrix{26595&1212&4257&-4466&9784\cr -4226&3404&5743&3&10032\cr 30471&6&14918&267&30\cr }}$";
+assert_checkequal(prettyprint(i, "tex"), ref);
+
+// MathML
+ref  = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>26595</mn></mtd>"
+"<mtd><mn>1212</mn></mtd>"
+"<mtd><mn>4257</mn></mtd>"
+"<mtd><mo>-</mo><mn>4466</mn></mtd>"
+"<mtd><mn>9784</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>4226</mn></mtd>"
+"<mtd><mn>3404</mn></mtd>"
+"<mtd><mn>5743</mn></mtd>"
+"<mtd><mn>3</mn></mtd>"
+"<mtd><mn>10032</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>30471</mn></mtd>"
+"<mtd><mn>6</mn></mtd>"
+"<mtd><mn>14918</mn></mtd>"
+"<mtd><mn>267</mn></mtd>"
+"<mtd><mn>30</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(i, "mathml"), ref);
+
+
+// BOOLEANS
+// ========
+C = [ %t %t; %f %t ];
+// LaTeX
+CResultLatex="${\begin{pmatrix}T&T\cr F&T\cr \end{pmatrix}}$";
+assert_checkequal(prettyprint(C), CResultLatex);
+// TeX
 CResultTex="${\pmatrix{T&T\cr F&T\cr }}$";
-if prettyprint(C,"tex") <> CResultTex then pause, end
+assert_checkequal(prettyprint(C,"tex"), CResultTex);
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mi>T</mi></mtd>"
+"<mtd><mi>T</mi></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mi>F</mi></mtd>"
+"<mtd><mi>T</mi></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(C,"mathml"), ref);
+
+
+// POLYNOMIALS
+// ===========
+assert_checkequal(prettyprint(0*%z), "$0z$");
+assert_checkequal(prettyprint(0*%z, "tex"), "$0z$");
+assert_checkequal(prettyprint(0*%z, "mathml"), "<mn>0</mn><mi>z</mi>");
+
+p = 1+%s+2*%s^2;
+assert_checkequal(prettyprint(p), "$1+s +2s^{2} $");
+
+D = poly(B,"s");
+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} $";
+assert_checkequal(prettyprint(D,"latex","["), DResultLatex);
+
+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} $";
+assert_checkequal(prettyprint(D,"tex","["), DResultLatex)
+
+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> ";
+assert_checkequal(prettyprint(D,"mathml","["), DResultMathML);
+
+// With complex coefficients
+// .........................
+// 1)
+p = (%i-%z).^[1 3;2 4];
+
+// LaTeX
+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}}$";
+assert_checkequal(prettyprint(p), ref);
+
+// TeX
+ref = "${\pmatrix{i-z &-i+3z +3iz^{2} -z^{3} \cr -1-2iz +z^{2} &1+4iz -6z^{2} -4iz^{3} +z^{4} \cr }}$";
+assert_checkequal(prettyprint(p, "tex"), ref);
 
-CResultMathML="<mfenced open=""("" close="")""><mtable><mtr><mtd><mi>T</mi></mtd><mtd><mi>T</mi></mtd></mtr><mtr><mtd><mi>F</mi></mtd><mtd><mi>T</mi></mtd></mtr></mtable></mfenced>";
-if prettyprint(C,"mathml") <> CResultMathML then pause, end
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mi>i</mi><mo>-</mo><mi>z</mi></mtd>"
+"<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>"
+"</mtr>"
+"<mtr>"
+"<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>"
+"<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>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(p, "mathml"), ref);
 
-s=poly(0,"s");p=1+s+2*s^2;
-D=poly(B,"s");
+// 2) ---------
+p = poly(complex([1 0 -2],[%nan 0 -1]),"x","coeff");
+// LaTeX
+assert_checkequal(prettyprint(p), "$1+{\mathrm{NaN}}i-(2+i)x^{2} $");
+// TeX
+assert_checkequal(prettyprint(p,"tex"), "$1+{\mathrm{NaN}}i-(2+i)x^{2} $");
+// MathML
+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> ";
+assert_checkequal(prettyprint(p,"mathml"), ref);
 
-DResultLatex="$1.553\times10^{+47}-1.738\times10^{+47}s+8.994\times10^{+46}s^{2}-2.885\times10^{+46}s^{3}+6.474\times10^{+45}s^{4}-1.086\times10^{+45}s^{5}+1.422\times10^{+44}s^{6}-1.493\times10^{+43}s^{7}+1.284\times10^{+42}s^{8}-9.182\times10^{+40}s^{9}+5.527\times10^{+39}s^{10}-2.824\times10^{+38}s^{11}+1.233\times10^{+37}s^{12}-4.626\times10^{+35}s^{13}+1.496\times10^{+34}s^{14}-4.182\times10^{+32}s^{15}+1.011\times10^{+31}s^{16}-2.116\times10^{+29}s^{17}+3.826\times10^{+27}s^{18}-5.965\times10^{+25}s^{19}+7.990\times10^{+23}s^{20}-9.144\times10^{+21}s^{21}+8.876\times10^{+19}s^{22}-7.234\times10^{+17}s^{23}+4.885\times10^{+15}s^{24}-2.683\times10^{+13}s^{25}+1.167\times10^{+11}s^{26}-3.868\times10^{+08}s^{27}+916980.98s^{28}-1384.5606s^{29}+s^{30}$";
-if prettyprint(D,"latex","[") <> DResultLatex then pause, end
 
-DResultTex="$1.553\times10^{+47}-1.738\times10^{+47}s+8.994\times10^{+46}s^{2}-2.885\times10^{+46}s^{3}+6.474\times10^{+45}s^{4}-1.086\times10^{+45}s^{5}+1.422\times10^{+44}s^{6}-1.493\times10^{+43}s^{7}+1.284\times10^{+42}s^{8}-9.182\times10^{+40}s^{9}+5.527\times10^{+39}s^{10}-2.824\times10^{+38}s^{11}+1.233\times10^{+37}s^{12}-4.626\times10^{+35}s^{13}+1.496\times10^{+34}s^{14}-4.182\times10^{+32}s^{15}+1.011\times10^{+31}s^{16}-2.116\times10^{+29}s^{17}+3.826\times10^{+27}s^{18}-5.965\times10^{+25}s^{19}+7.990\times10^{+23}s^{20}-9.144\times10^{+21}s^{21}+8.876\times10^{+19}s^{22}-7.234\times10^{+17}s^{23}+4.885\times10^{+15}s^{24}-2.683\times10^{+13}s^{25}+1.167\times10^{+11}s^{26}-3.868\times10^{+08}s^{27}+916980.98s^{28}-1384.5606s^{29}+s^{30}$";
-if prettyprint(D,"tex","[") <> DResultLatex then pause, end
+// CELLS
+// =====
+c = {["a bc";"defg"], %t ; (1-%s)^3, %pi};
+// LaTeX
+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}}$";
+assert_checkequal(prettyprint(c), ref);
 
-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>";
-if prettyprint(D,"mathml","[") <> DResultMathML then pause, end
+// TeX
+ref = "${\pmatrix{{\pmatrix{\mathsf{\text{a bc}}\cr \mathsf{\text{defg}}\cr }}&T\cr 1-3s +3s^{2} -s^{3} &3.1415927\cr }}$";
+assert_checkequal(prettyprint(c, "tex"), ref);
 
-if prettyprint(%inf) <> "${\infty}$" then pause, end
-if prettyprint([%inf 0  1 -%inf]) <> "${\begin{pmatrix}{\infty}&0&1&{-\infty}\cr \end{pmatrix}}$" then pause, end
-if prettyprint([%inf 0; 1 -%inf]) <> "${\begin{pmatrix}{\infty}&0\cr"+...
-      " 1&{-\infty}\cr \end{pmatrix}}$" then pause, end
-if prettyprint(%inf,"mathml") <> "<infinity/>" then pause, end
\ No newline at end of file
+// MathML
+ref = [""
+"<mfenced open=""{"" close=""}"">"
+"<mtable>"
+"<mtr>"
+"<mtd>"
+"<mfenced open=""{"" close=""}"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mi>a bc</mi></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mi>defg</mi></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"</mtd>"
+"<mtd><mi>T</mi></mtd>"
+"</mtr>"
+"<mtr>"
+"<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>"
+"<mtd><mn>3.1415927</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(c, "mathml", "{"), ref);
diff --git a/scilab/modules/string/tests/unit_tests/prettyprint_syslin.tst b/scilab/modules/string/tests/unit_tests/prettyprint_syslin.tst
new file mode 100644 (file)
index 0000000..c3e21d0
--- /dev/null
@@ -0,0 +1,196 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2019 - Samuel GOUGEON
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+
+TMP = strsubst(fileparts(TMPDIR), "\", "/");
+
+// LINEAR SYSTEMS
+// ==============
+grand("setsd",0);
+A = grand(3,3,"uin",-999,999)/100;
+B = grand(3,2,"uin",-999,999)/100;
+C = grand(2,3,"uin",-999,999)/100;
+
+// Continuous time:
+// ---------------
+s = syslin("c", A, B, C);
+
+// LaTeX
+ref = "${\begin{pmatrix}{\left\{\begin{array}{rcl}\dot{X}(t)&=&{\begin{pmatrix}2.02&7.14&-8.59\cr -9.99&-9.64&-1.27\cr 5.59&7.25&7.44\cr \end{pmatrix}} X(t)+{\begin{pmatrix}4.46&-0.62\cr 8.42&-3.3\cr -2.67&9.04\cr \end{pmatrix}}U(t)\cr Y(t) &=& {\begin{pmatrix}-7.72&6.86&-6.75\cr -4.58&-3.59&-8.06\cr \end{pmatrix}} X(t) \end{array}\right.}\cr \end{pmatrix}}$";
+assert_checkequal(prettyprint(s), ref);
+
+// TeX
+ref = "${\pmatrix{{\left\{\eqalign{\dot{X}(t) &= {\pmatrix{2.02&7.14&-8.59\cr -9.99&-9.64&-1.27\cr 5.59&7.25&7.44\cr }} X(t)+{\pmatrix{4.46&-0.62\cr 8.42&-3.3\cr -2.67&9.04\cr }}U(t)\cr Y(t) &= {\pmatrix{-7.72&6.86&-6.75\cr -4.58&-3.59&-8.06\cr }} X(t) }\right.}\cr }}$";
+assert_checkequal(prettyprint(s, "tex"), ref);
+
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mfenced close="""" open=""{"">"
+"<mtable columnalign=""right center left"">"
+"<mtr><mtd><mrow><mover><mi>X</mi><mo>.</mo></mover><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd><mtd><mo>=</mo></mtd><mtd>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>2.02</mn></mtd>"
+"<mtd><mn>7.14</mn></mtd>"
+"<mtd><mo>-</mo><mn>8.59</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>9.99</mn></mtd>"
+"<mtd><mo>-</mo><mn>9.64</mn></mtd>"
+"<mtd><mo>-</mo><mn>1.27</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>5.59</mn></mtd>"
+"<mtd><mn>7.25</mn></mtd>"
+"<mtd><mn>7.44</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>X</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow><mo>+</mo>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>4.46</mn></mtd>"
+"<mtd><mo>-</mo><mn>0.62</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>8.42</mn></mtd>"
+"<mtd><mo>-</mo><mn>3.3</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>2.67</mn></mtd>"
+"<mtd><mn>9.04</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>U</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd></mtr>"
+"<mtr><mtd><mrow><mi>Y</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd><mtd><mo>=</mo></mtd><mtd>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>7.72</mn></mtd>"
+"<mtd><mn>6.86</mn></mtd>"
+"<mtd><mo>-</mo><mn>6.75</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>4.58</mn></mtd>"
+"<mtd><mo>-</mo><mn>3.59</mn></mtd>"
+"<mtd><mo>-</mo><mn>8.06</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>X</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd></mtr>"
+"</mtable>"
+"</mfenced>"
+"</mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(s, "mathml"), ref);
+
+// Discrete states (and improper syslin):
+// -------------------------------------
+s = syslin("d", A, B, C, [1+%s, 1-%s; -%s, %s]);
+// LaTeX
+ref = "${\begin{pmatrix}{\left\{\begin{array}{rcl}\stackrel{+}{X}(t)&=&{\begin{pmatrix}2.02&7.14&-8.59\cr -9.99&-9.64&-1.27\cr 5.59&7.25&7.44\cr \end{pmatrix}} X(t)+{\begin{pmatrix}4.46&-0.62\cr 8.42&-3.3\cr -2.67&9.04\cr \end{pmatrix}}U(t)\cr Y(t) &=& {\begin{pmatrix}-7.72&6.86&-6.75\cr -4.58&-3.59&-8.06\cr \end{pmatrix}} X(t)  + {\begin{pmatrix}1+s &1-s \cr -s &s \cr \end{pmatrix}} U(t)\end{array}\right.}\cr \end{pmatrix}}$";
+assert_checkequal(prettyprint(s, "latex"), ref);
+
+// TeX
+ref = "${\pmatrix{{\left\{\eqalign{{\buildrel + \over X(t)} &= {\pmatrix{2.02&7.14&-8.59\cr -9.99&-9.64&-1.27\cr 5.59&7.25&7.44\cr }} X(t)+{\pmatrix{4.46&-0.62\cr 8.42&-3.3\cr -2.67&9.04\cr }}U(t)\cr Y(t) &= {\pmatrix{-7.72&6.86&-6.75\cr -4.58&-3.59&-8.06\cr }} X(t)  + {\pmatrix{1+s &1-s \cr -s &s \cr }} U(t)}\right.}\cr }}$";
+assert_checkequal(prettyprint(s, "tex"), ref);
+
+// MathML
+ref = [""
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mfenced close="""" open=""{"">"
+"<mtable columnalign=""right center left"">"
+"<mtr><mtd><mrow><mover><mi>X</mi><mo>+</mo></mover><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd><mtd><mo>=</mo></mtd><mtd>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>2.02</mn></mtd>"
+"<mtd><mn>7.14</mn></mtd>"
+"<mtd><mo>-</mo><mn>8.59</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>9.99</mn></mtd>"
+"<mtd><mo>-</mo><mn>9.64</mn></mtd>"
+"<mtd><mo>-</mo><mn>1.27</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>5.59</mn></mtd>"
+"<mtd><mn>7.25</mn></mtd>"
+"<mtd><mn>7.44</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>X</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow><mo>+</mo>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>4.46</mn></mtd>"
+"<mtd><mo>-</mo><mn>0.62</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mn>8.42</mn></mtd>"
+"<mtd><mo>-</mo><mn>3.3</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>2.67</mn></mtd>"
+"<mtd><mn>9.04</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>U</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd></mtr>"
+"<mtr><mtd><mrow><mi>Y</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd><mtd><mo>=</mo></mtd><mtd>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>7.72</mn></mtd>"
+"<mtd><mn>6.86</mn></mtd>"
+"<mtd><mo>-</mo><mn>6.75</mn></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mn>4.58</mn></mtd>"
+"<mtd><mo>-</mo><mn>3.59</mn></mtd>"
+"<mtd><mo>-</mo><mn>8.06</mn></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>X</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow><mo>+</mo>"
+"<mfenced open=""("" close="")"">"
+"<mtable>"
+"<mtr>"
+"<mtd><mn>1</mn><mo>+</mo><mi>s</mi></mtd>"
+"<mtd><mn>1</mn><mo>-</mo><mi>s</mi></mtd>"
+"</mtr>"
+"<mtr>"
+"<mtd><mo>-</mo><mi>s</mi></mtd>"
+"<mtd><mi>s</mi></mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+"<mrow><mi>U</mi><mo>(</mo><mi>t</mi><mo>)</mo></mrow></mtd></mtr>"
+"</mtable>"
+"</mfenced>"
+"</mtd>"
+"</mtr>"
+"</mtable>"
+"</mfenced>"
+""];
+ref = strcat(ref, ascii(10));
+assert_checkequal(prettyprint(s, "mathml"), ref);