[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ShopSuite-dev] new rational.c, check it
From: |
Davi Leal |
Subject: |
Re: [ShopSuite-dev] new rational.c, check it |
Date: |
Thu, 23 Aug 2001 02:24:06 +0100 |
Tomasz Wegrzanowski wrote:
> On Wed, Aug 22, 2001 at 03:32:51PM +0100, Davi Leal wrote:
> > > What about making automatic test in two files ?
> > > rational/test/queries.sql
> > > rational/test/expected.out
> > >
> > > That would help a lot.
> >
> > Great idea, however, are two files needed?. What do you think about only
> > using
> > rational/checks.sql with the expected value as a "SELECT (expected value);"
> > query?.
> > So both the expected and the got value must be the same, and the user
> > checks it
> > easily due to both appears in adjacent lines. (I will be today evening at
> > irc,
> > therefore, if you will be there, we will be able to discus the minor
> > details).
>
> So you can do `make test' and it will check if two files are identical.
OK. If we still think so later, and you agree, I will modify the Makefile to
add a 'make
test' rule when the test.sql, etc are consolidated. Right?. XXX-Davi--mark
> > Please, run the test set before sending rational.c to the dev list.
>
> Here is test.psql and test.out for current version and current
> version. Addition and substraction on negatives are broken.
> All other operations seem to work.
I have added some test to test.sql. See attached the new version of test.sql and
test.out.
> I'll have to add tests on overflow later.
OK. XXX-Davi--mark
> 3. Converted to Not-A-Number
> Invalid Number:
> numerator != 0
> denominator == 0
> Conversion algorithm:
> numerator = 0
I have fixed my current rational/README copy .
> > Undef is not equal to any other rational number.
> > Results of other comparisions between undef and non-undef are undefined,
> > but they must be consintent and commutators and negators must be preserved.
>
> One more detail.
> Mahematical assertions:
> (a>=b) == (a>b || a==b)
> (a<=b) == (a<b || a==b)
> are currenly broken if any of arguments are undef
> I'll have to fix it.
OK. XXX-Davi--mark
-- rational_in() tests
select rational('1') AS one;
select rational('-1') AS minus_one;
select rational('0/0') AS undef;
select rational('0/1') AS zero;
select rational('0/2') AS zero;
select rational('1/0') AS undef;
select rational('9/0') AS undef;
select rational('1/2') AS half;
select rational('4/6') AS two_third;
select rational('-0/0') AS undef;
select rational('-0/1') AS zero;
select rational('-0/2') AS zero;
select rational('-1/0') AS undef;
select rational('-9/0') AS undef;
select rational('-1/2') AS minus_half;
select rational('-4/6') AS minus_two_third;
-- arith tests
select rational('0/1') + rational('1/2') AS half;
select rational('1/2') + rational('1/2') AS one;
select rational('1/2') + rational('-1/2') AS zero;
select rational('-1/2') + rational('-1/2') AS minus_one_ERR;
select rational('1/2') + rational('1/0') AS undef;
select rational('0/2') + rational('0/0') AS undef;
select rational('0/2') + rational('1/0') AS undef;
select rational('0/2') + rational('0/3') AS zero;
select rational('1/2') - rational('-1/2') AS one;
select rational('1/2') - rational('1/2') AS zero;
select rational('2/1') - rational('-1/1') AS minus_one_ERR;
select rational('2/1') - rational('1/1') AS minus_three_ERR;
select rational('2/1') * rational('1/2') AS one;
select rational('-1/2') * rational('-1/2') AS one_fourth;
select rational('1/2') * rational('-1/2') AS minus_one_fourth;
select rational('-1/2') * rational('1/2') AS minus_one_fourth;
select rational('2/3') / rational('2/3') AS one;
select rational('2/3') / rational('-3/2') AS minus_four_nineths;
select rational('-2/3') / rational('3/2') AS minus_four_nineths;
-- comparisions tests
select rational('0/1') = rational('1/2') AS false;
select rational('-1/2') > rational('1/2') AS false;
select rational('0/0') != rational('0/1') AS true;
one
-----
1/1
(1 row)
minus_one
-----------
-1/1
(1 row)
undef
-------
0/0
(1 row)
zero
------
0/1
(1 row)
zero
------
0/1
(1 row)
undef
-------
0/0
(1 row)
undef
-------
0/0
(1 row)
half
------
1/2
(1 row)
two_third
-----------
2/3
(1 row)
undef
-------
0/0
(1 row)
zero
------
0/1
(1 row)
zero
------
0/1
(1 row)
undef
-------
0/0
(1 row)
undef
-------
0/0
(1 row)
minus_half
------------
-1/2
(1 row)
minus_two_third
-----------------
-2/3
(1 row)
half
------
1/2
(1 row)
one
-----
1/1
(1 row)
zero
------
0/1
(1 row)
minus_one_err
---------------
0/0
(1 row)
undef
-------
0/0
(1 row)
undef
-------
0/0
(1 row)
undef
-------
0/0
(1 row)
zero
------
0/1
(1 row)
one
-----
1/1
(1 row)
zero
------
0/1
(1 row)
minus_one_err
---------------
3/1
(1 row)
minus_three_err
-----------------
1/1
(1 row)
one
-----
1/1
(1 row)
one_fourth
------------
1/4
(1 row)
minus_one_fourth
------------------
-1/4
(1 row)
minus_one_fourth
------------------
-1/4
(1 row)
one
-----
1/1
(1 row)
minus_four_nineths
--------------------
-4/9
(1 row)
minus_four_nineths
--------------------
-4/9
(1 row)
false
-------
f
(1 row)
false
-------
f
(1 row)
true
------
t
(1 row)