Adding not string based routine(s) to Unittest

2 views
Skip to first unread message

Grégory Vanuxem

unread,
Jun 28, 2023, 9:58:01 AM6/28/23
to fricas...@googlegroups.com
Hello,

I'm wondering why there is only String parameters based routines in Unittest. What I mean is that from what I have seen the argument(s) to all routines are of type String:
==================================
testLibraryError : String -> Void   
testTrue : String -> Void
 xftestTrue : String -> Void
 testComplexEquals : (String, String) -> Void
 testEquals : (String, String) -> Void
 testNotEquals : (String, String) -> Void
 testRealEquals : (String, String) -> Void
 xftestComplexEquals : (String, String) -> Void
 xftestEquals : (String, String) -> Void
 xftestLibraryError : String -> Void
 xftestNotEquals : (String, String) -> Void
 xftestRealEquals : (String, String) -> Void
===================================

I can understand that, for example Expression(Integer), it is usually the simplest way to check correctness but I am wondering why there is only this method.

I explain. I'm continuing to implement a "simple" wrapper to parts of Julia. And since all computations are done inside Julia and since this is essentially Float64 based I'm wondering if for my purpose I could provide my routines which are Julia based and returns Boolean values. 

In other words, what I would like is to add to the Unittest framework, at least, a simple routine say "isTrue" for example but handled by another module or even coded in the input file. I insist on using the actual framework with use of UnittestAux and UnittestCount routines I guess. 

Any though about why that does not seem to exist actually and why this was not done? Or even, is this an unnecessary addition?

Regards, 
__
Greg

Waldek Hebisch

unread,
Jun 28, 2023, 10:41:10 AM6/28/23
to fricas...@googlegroups.com
On Wed, Jun 28, 2023 at 03:57:47PM +0200, Grégory Vanuxem wrote:
> Hello,
>
> I'm wondering why there is only String parameters based routines in
> Unittest. What I mean is that from what I have seen the argument(s) to all
> routines are of type String:
> ==================================
> testLibraryError : String -> Void
> testTrue : String -> Void
> xftestTrue : String -> Void
...
> ===================================
>
> I can understand that, for example Expression(Integer), it is usually the
> simplest way to check correctness but I am wondering why there is only this
> method.

There is one basic reason. Assume we just pass arguments in "normal"
way to counting routines. If there is an error in an argument to
counting routine then execution is aborted _before_ call to counting
routine. So, to get consistent counts arguments to counting routines
must be "foolproof", that is should never cause errors. The way
we use is to pass strings, whatever its content string is a valid
argument and can not cause errors. If _execution_ of string causes
error, then counting routine will notice this and count test as
failed.

In principle some (maybe many) tests have arguments that should
never cause errors, so it would be possible to use non-string
form for them. But it is simpler and more reliable to always
use string form.

> I explain. I'm continuing to implement a "simple" wrapper to parts of
> Julia. And since all computations are done inside Julia and since this is
> essentially Float64 based I'm wondering if for my purpose I could provide
> my routines which are Julia based and returns Boolean values.
>
> In other words, what I would like is to add to the Unittest framework, at
> least, a simple routine say "isTrue" for example but handled by another
> module or even coded in the input file. I insist on using the actual
> framework with use of UnittestAux and UnittestCount routines I guess.

Well

isTrue(passes_test())

would treat error in 'passes_test()' the same as if 'passes_test()'
was not called at all. OTOH

testTrue("passes_test()")

will notice and report error in execution of 'passes_test()'.

--
Waldek Hebisch

Grégory Vanuxem

unread,
Jun 28, 2023, 11:26:37 AM6/28/23
to fricas...@googlegroups.com
Ok, thanks for your quick reply. I see now. I only have in mind mathematical operation errors and not errors in the code itself. I have done some and am pretty sure  some remain. This is one of the main purpose of checking each routine I have added. So, right.

Greg

--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZJxGeK9Fpq%2BPhtHP%40fricas.math.uni.wroc.pl.
Reply all
Reply to author
Forward
0 new messages