[Scilab-users] unit tests and help generation for overloaded unary/binary operators

classic Classic list List threaded Threaded
8 messages Options
Philippe Roux Philippe Roux
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] unit tests and help generation for overloaded unary/binary operators

Hi,

I'm writing a toolbox to handle "big integers" represented by a tlist
of type "bigint". In my "macros/" directory  I wrote my scilab functions
for bigint type  and overloaded unary and  binary operators (+,-,>,==,
...) for example %bigint_o_bigint  for bigint equality "=="  (see the
source code at the bottom of this message ). For each function I wrote,
I've created :

- a short help,  as a comment at the beginning of the *.sci file
- a test file "*.tst" placed in "/tests/unit_tests/" directory

I have some problems when I execute my builder.sce  :

if %bigint_o_bigint  function is stored in macros/%bigint_o_bigint.sci
and its unit test in tests/unit_tests/%bigint_o_bigint.tst  then I get
an error  during help generation (but unit_tests are OK) :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Génération du document maître :
        /home/roux/Documents/informatique/scilab/bigint/help/en_US

Génération du fichier d'aide [javaHelp] in
/home/roux/Documents/informatique/scilab/bigint/help/en_US.
 !--error 999
buildDoc : Erreur pendant la génération de la documentation : no
protocol:
/home/roux/Documents/informatique/scilab/bigint/help/en_US/%bigint_o_bigint.xml.
at line     691 of function xmltoformat called by :
at line      17 of function xmltojar called by :
at line      51 of function tbx_build_help called by :
tbx_build_help(toolbox_title, help_lang_dir);
at line       7 of exec file called by :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if %bigint_o_bigint function is stored in macros/bigint_o_bigint.sci and
its unit test in tests/unit_tests/%bigint_o_bigint.tst  or
tests/unit_tests/bigint_o_bigint.tst   then I get the error  during
unit_tests (but online help is generated without problems ???? )

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-->tbx_build_help_loader(toolbox_title, help_dir)

   TMPDIR = /tmp/SCI_TMP_420_E0z4Rx

   001/001 - [.] :

   001/009 - [.] bigint.........................................failed:
premature end of the test script
   002/009 - [.] bigint_o_bigint................................failed:
premature end of the test script


[...........]

   TEST : [.] bigint_o_bigint
   failed: premature end of the test script
   Check the following file :
   - /tmp/SCI_TMP_420_E0z4Rx/bigint_o_bigint.dia.tmp
   Or launch the following command :
   -
exec("/home/roux/Documents/informatique/scilab/bigint/tests/unit_tests/bigint_o_bigint.tst");

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

same problem  with %bigint_o_bigint.tst

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


   001/009 - [.] %bigint_o_bigint...............................failed:
premature end of the test script

[........]

   TEST : [.] %bigint_o_bigint
   failed: premature end of the test script
   Check the following file :
   - /tmp/SCI_TMP_420_E0z4Rx/%bigint_o_bigint.dia.tmp
   Or launch the following command :
   -
exec("/home/roux/Documents/informatique/scilab/bigint/tests/unit_tests/%bigint_o_bigint.tst");
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

how can I solve both problems ?

Philippe.

my %bigint_o_bigint code with help inside :


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [bool]=%bigint_o_bigint(x,y)
    //
    // Calling Sequence
    //   x==y
    //
    // Parameters
    //  x,y: bigint
    //  bool : boolean
    //
    // Description
    // bigint comparison
    //
    // Examples
    // //
    // x=bigint('123456789')
    // y=bigint('0123456789')
    // z=bigint('1234567890')
    // x==y  // true
    // x==z  // false
    //
    // See also
    //  bigint
    //
    // Authors
    //  Philippe Roux
    //

    x=check_bigint(x)
    y=check_bigint(y)
    bool=(x.signe==y.signe)&(and(x.rep==y.rep))
endfunction
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: unit tests and help generation for overloaded unary/binary operators

Hello Philippe,

AFAIR, XML filenames must not have the "%" character. Moreover, xml ids must exclude it as well.
So, if the xml id of the page is currently "%bigint_o_bigint", you should rather choose something like
"bigint_equal_bigint" instead.

help generation and unit tests are completely independent from each other.
 
Le 16/06/2016 18:28, philippe a écrit :
Hi,

I'm writing a toolbox to handle "big integers" represented by a tlist
of type "bigint". In my "macros/" directory  I wrote my scilab functions
for bigint type  and overloaded unary and  binary operators (+,-,>,==,
...) for example %bigint_o_bigint  for bigint equality "=="  (see the
source code at the bottom of this message ). For each function I wrote,
I've created :

- a short help,  as a comment at the beginning of the *.sci file
- a test file "*.tst" placed in "/tests/unit_tests/" directory

I have some problems when I execute my builder.sce  :

if %bigint_o_bigint  function is stored in macros/%bigint_o_bigint.sci
and its unit test in tests/unit_tests/%bigint_o_bigint.tst  then I get
an error  during help generation (but unit_tests are OK) :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Génération du document maître :
	/home/roux/Documents/informatique/scilab/bigint/help/en_US

Génération du fichier d'aide [javaHelp] in
/home/roux/Documents/informatique/scilab/bigint/help/en_US.
 !--error 999
buildDoc : Erreur pendant la génération de la documentation : no
protocol:
/home/roux/Documents/informatique/scilab/bigint/help/en_US/%bigint_o_bigint.xml.
at line     691 of function xmltoformat called by :
at line      17 of function xmltojar called by :
at line      51 of function tbx_build_help called by :
tbx_build_help(toolbox_title, help_lang_dir);
at line       7 of exec file called by :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if %bigint_o_bigint function is stored in macros/bigint_o_bigint.sci and
its unit test in tests/unit_tests/%bigint_o_bigint.tst  or
tests/unit_tests/bigint_o_bigint.tst   then I get the error  during
unit_tests (but online help is generated without problems ???? )

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-->tbx_build_help_loader(toolbox_title, help_dir)
?? Why does this function run a unit test ??


   TMPDIR = /tmp/SCI_TMP_420_E0z4Rx

   001/001 - [.] :

   001/009 - [.] bigint.........................................failed:
premature end of the test script
   002/009 - [.] bigint_o_bigint................................failed:
premature end of the test script


[...........]

   TEST : [.] bigint_o_bigint
   failed: premature end of the test script
   Check the following file :
   - /tmp/SCI_TMP_420_E0z4Rx/bigint_o_bigint.dia.tmp
Did you check it?
   Or launch the following command :
   -
exec("/home/roux/Documents/informatique/scilab/bigint/tests/unit_tests/bigint_o_bigint.tst");
Did you try it?

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Philippe Roux Philippe Roux
Reply | Threaded
Open this post in threaded view
|

Re: unit tests and help generation for overloaded unary/binary operators

Le 16/06/2016 19:46, Samuel Gougeon a écrit :
> Hello Philippe,
>
> AFAIR, XML filenames must not have the "%" character. Moreover, xml ids
> must exclude it as well.

Ok, so I've added to my build_help.sce file the lines

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for fic=listfiles(help_lang_dir+'%bigint_*.xml')'
newfic=strsubst(fic,'%','')
printf('%s \n to \n %s\n',fic,newfic)
unix(' mv '+fic+' '+newfic)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

> So, if the xml id of the page is currently "%bigint_o_bigint", you
> should rather choose something like "bigint_equal_bigint" instead.

I also removed the % in *.xml help files using the following lines :

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for fic=listfiles(help_lang_dir+'*.xml')'
unix('sed -i ''s/%bigint_/bigint_/g'' '+fic)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I don't know if i can do this without using bash command so that anyone
can build the toolbox even on windows system ? Any the way this is not
very important since the toolbox only contains only scilab macros (no
gateway needed ).

>
> help generation and unit tests are completely independent from each other.

yes but for maintainability it's easier if unit tests of myfunction.sci
is stored in myfunction.tst :-)

Know it works fine , Thanks a lot Samuel!

Philippe.

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] no "%" in xml:id of help pages <= Re: unit tests and help generation for overloaded unary/binary operators

Le 18/06/2016 11:53, philippe a écrit :

> Le 16/06/2016 19:46, Samuel Gougeon a écrit :
>> Hello Philippe,
>>
>> AFAIR, XML filenames must not have the "%" character. Moreover, xml ids
>> must exclude it as well.
> Ok, so I've added to my build_help.sce file the lines
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> for fic=listfiles(help_lang_dir+'%bigint_*.xml')'
> newfic=strsubst(fic,'%','')
> printf('%s \n to \n %s\n',fic,newfic)
> unix(' mv '+fic+' '+newfic)
> end
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>> So, if the xml id of the page is currently "%bigint_o_bigint", you
>> should rather choose something like "bigint_equal_bigint" instead.
> I also removed the % in *.xml help files using the following lines :
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> for fic=listfiles(help_lang_dir+'*.xml')'
> unix('sed -i ''s/%bigint_/bigint_/g'' '+fic)
> end
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> I don't know if i can do this without using bash command so that anyone
> can build the toolbox even on windows system ? Any the way this is not
> very important since the toolbox only contains only scilab macros (no
> gateway needed ).
>
>> help generation and unit tests are completely independent from each other.
> yes but for maintainability it's easier if unit tests of myfunction.sci
> is stored in myfunction.tst :-)
>
> Know it works fine , Thanks a lot Samuel!
Great. Thanks for the feedback.
I don't know why exactly the "%" is avoided or even excluded in any
xml:id (so just in the <refentry ... xml:id=""> entry/attribute). The
contents of XML files may include some "%" without any problem, but not
the xml:id. It could be due to some restrictions for HTML pages and
search engines over pages.
The Windows files manager accepts "%" in files name without any problem,
but AFAIK the basename of scilab XML files is chosen equal to the (main)
xml:id of the help page.

Samuel
(Happy to see you back on the mailing lists :)

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: no "%" in xml:id of help pages <= Re: unit tests and help generation for overloaded unary/binary operators

Le 18/06/2016 16:55, Samuel Gougeon a écrit :
> .../...
> I don't know why exactly the "%" is avoided or even excluded in any
> xml:id (so just in the <refentry ... xml:id=""> entry/attribute). The
> contents of XML files may include some "%" without any problem, but
> not the xml:id. It could be due to some restrictions for HTML pages
> and search engines over pages.
> The Windows files manager accepts "%" in files name without any
> problem, but AFAIK the basename of scilab XML files is chosen equal to
> the (main) xml:id of the help page.
The need for more information about how to make help pages is reported
there: http://bugzilla.scilab.org/14589
  * rules for the xml:id attribute
  * undocumented Scilab supported attributes for supported doocbook tags

SG

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Philippe Roux Philippe Roux
Reply | Threaded
Open this post in threaded view
|

Re: no "%" in xml:id of help pages <= Re: unit tests and help generation for overloaded unary/binary operators

In reply to this post by Samuel GOUGEON
Le 18/06/2016 16:55, Samuel Gougeon a écrit :
>
> (Happy to see you back on the mailing lists :)

me too :-) I was very busy last two years  after switching from IUT
Lannion to ENSSAT, I hope I will have more time to work on scilab next
year ...

Philippe


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] help_from_sci() with %overload.sci <= Re: unit tests and help generation for overloaded unary/binary operators

In reply to this post by Philippe Roux
Hi,

Le 16/06/2016 à 18:28, philippe a écrit :

> Hi,
>
> I'm writing a toolbox to handle "big integers" represented by a tlist
> of type "bigint". In my "macros/" directory  I wrote my scilab functions
> for bigint type  and overloaded unary and  binary operators (+,-,>,==,
> ...) for example %bigint_o_bigint  for bigint equality "=="  (see the
> source code at the bottom of this message ). For each function I wrote,
> I've created :
>
> - a short help,  as a comment at the beginning of the *.sci file
> - a test file "*.tst" placed in "/tests/unit_tests/" directory
>
> I have some problems when I execute my builder.sce  :
>
> if %bigint_o_bigint  function is stored in macros/%bigint_o_bigint.sci
> and its unit test in tests/unit_tests/%bigint_o_bigint.tst  then I get
> an error  during help generation (but unit_tests are OK) :

What you did not really say here is that you use help_from_sci() to
build your XML pages from heading comments in your %overload_name.sci files.
Now, help_from_sci() does not support properly functions names starting
with "%", including some
forbidden "%" characters in XML filenames and xml:id value.
This is now reported as http://bugzilla.scilab.org/15282
with a proposed fix @ https://codereview.scilab.org/#/c/19443

With this fix, you will no longer need to post-process your filenames
and files contents
to make the doc builder running right. It normalizes filenames and
xml:id in the same way
as native Scilab files are, by replacing "%" with "percent".

BR
Samuel

>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> Génération du document maître :
> /home/roux/Documents/informatique/scilab/bigint/help/en_US
>
> Génération du fichier d'aide [javaHelp] in
> /home/roux/Documents/informatique/scilab/bigint/help/en_US.
>   !--error 999
> buildDoc : Erreur pendant la génération de la documentation : no
> protocol:
> /home/roux/Documents/informatique/scilab/bigint/help/en_US/%bigint_o_bigint.xml.
> at line     691 of function xmltoformat called by :
> at line      17 of function xmltojar called by :
> at line      51 of function tbx_build_help called by :
> tbx_build_help(toolbox_title, help_lang_dir);
> at line       7 of exec file called by :
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> if %bigint_o_bigint function is stored in macros/bigint_o_bigint.sci and
> its unit test in tests/unit_tests/%bigint_o_bigint.tst  or
> tests/unit_tests/bigint_o_bigint.tst   then I get the error  during
> unit_tests (but online help is generated without problems ???? )
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> -->tbx_build_help_loader(toolbox_title, help_dir)
>
>     TMPDIR = /tmp/SCI_TMP_420_E0z4Rx
>
>     001/001 - [.] :
>
>     001/009 - [.] bigint.........................................failed:
> premature end of the test script
>     002/009 - [.] bigint_o_bigint................................failed:
> premature end of the test script
>
>
> [...........]
>
>     TEST : [.] bigint_o_bigint
>     failed: premature end of the test script
>     Check the following file :
>     - /tmp/SCI_TMP_420_E0z4Rx/bigint_o_bigint.dia.tmp
>     Or launch the following command :
>     -
> exec("/home/roux/Documents/informatique/scilab/bigint/tests/unit_tests/bigint_o_bigint.tst");
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> same problem  with %bigint_o_bigint.tst
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
>     001/009 - [.] %bigint_o_bigint...............................failed:
> premature end of the test script
>
> [........]
>
>     TEST : [.] %bigint_o_bigint
>     failed: premature end of the test script
>     Check the following file :
>     - /tmp/SCI_TMP_420_E0z4Rx/%bigint_o_bigint.dia.tmp
>     Or launch the following command :
>     -
> exec("/home/roux/Documents/informatique/scilab/bigint/tests/unit_tests/%bigint_o_bigint.tst");
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> how can I solve both problems ?
>
> Philippe.
>
> my %bigint_o_bigint code with help inside :
>
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> function [bool]=%bigint_o_bigint(x,y)
>      //
>      // Calling Sequence
>      //   x==y
>      //
>      // Parameters
>      //  x,y: bigint
>      //  bool : boolean
>      //
>      // Description
>      // bigint comparison
>      //
>      // Examples
>      // //
>      // x=bigint('123456789')
>      // y=bigint('0123456789')
>      // z=bigint('1234567890')
>      // x==y  // true
>      // x==z  // false
>      //
>      // See also
>      //  bigint
>      //
>      // Authors
>      //  Philippe Roux
>      //
>
>      x=check_bigint(x)
>      y=check_bigint(y)
>      bool=(x.signe==y.signe)&(and(x.rep==y.rep))
> endfunction
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Philippe Roux Philippe Roux
Reply | Threaded
Open this post in threaded view
|

Re: help_from_sci() with %overload.sci <= Re: unit tests and help generation for overloaded unary/binary operators


Le 03/10/2017 à 13:54, Samuel Gougeon a écrit :
>
>
> With this fix, you will no longer need to post-process your filenames
> and files contents
> to make the doc builder running right. It normalizes filenames and
> xml:id in the same way
> as native Scilab files are, by replacing "%" with "percent".

Good job Samuel ;-)

Philippe.

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users