jscript: api.js, added test routines for Math functions

Jacek Caban jacek at codeweavers.com
Tue Dec 16 08:11:43 CST 2008


Hi Patrick,

First of all, tests must pass on Wine and Windows. Your test won't pass 
on any of them! When you have a test that passes on Windows, please send 
one function implementation and tests in one patch.

Patrick Rudolph wrote:
> From c43e52c3446fb846a760002f0222f697075fad1b Mon Sep 17 00:00:00 2001
> From: Patrick Rudolph <patrick1804 at web.de>
> Date: Thu, 11 Dec 2008 17:48:38 +0100
> Subject: jscript: api.js added test routines for Math functions
>
> modified:   dlls/jscript/tests/api.js
> added tests for :
> Math.PI
> Math.E
> Math.SQRT2
> Math.SQRT1_2
> Math.sin
> Math.cos
> Math.random
> Math.tan
> Math.atan
> Math.asin
> Math.acos
> Math.log
> math.atan2
>
> ---
>  dlls/jscript/tests/api.js |   38 +++++++++++++++-----------------------
>  1 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
> index 6430397..50a28d5 100644
> --- a/dlls/jscript/tests/api.js
> +++ b/dlls/jscript/tests/api.js
>
> +i = (Math.PI()).toString();
>   

Math.PI is constant, not function so you can't call it. You'd know that 
if you'd verified that the test passes on Windows.

> +ok(i === "3.14159265358979","Math.PI() = " + i);
>   

It's bad idea to compare double values in tests, and comparing strings 
is strange here. Math.PI already has a test, look there how it's done there.

> +
> +i = (Math.E()).toString();
> +ok(i === "2.71828182845905","Math.E() = " + i);
>   

Same here.

> +
> +i = (Math.SQRT2()).toString();
> +ok(i === "1.4142135623731","Math.SQRT2() = " + i);
>   

And here.

> +i = (Math.SQRT1_2()).toString();
> +ok(i === "0.707106781186547","Math.SQRT1_2() = " + i);
>   

And here.

> +i = Math.sin(0);
> +ok(i === 0, "Math.sin(0) = " + i);
> +
> +i = Math.cos(0);
> +ok(i === 1, "Math.cos(0) = " + i);
> +
> +i = Math.tan(0);
> +ok(i === 0, "Math.tan(0) = " + i);
> +
> +i = Math.log(1);
> +ok(i === 0 , "Math.log() = " + i);
> +
> +i = Math.random();
> +ok(i !== 0 , "Math.random() = " + i);
> +
> +i = Math.random();
> +ok(i !== 1 , "Math.random() = " + i);
> +
> +i = Math.atan2(0,1);
> +ok(i === 0 , "Math.atan2(0,1) = " + i);
> +
> +i = Math.atan(0);
> +ok(i === 0 , "Math.atan(0) = " + i);
> +
> +i = (Math.asin(1)).toString();
> +ok(i === "1.5707963267949" , "Math.asin(1) = " + i);
> +
> +i = (Math.acos(-1)).toString();
> +ok(i === "3.14159265358979" , "Math.acos(-1) = " + i);
>   

There functions should have more tests like passing no argument, testing 
invalid asin/acos arguments, passing too much arguments (and should be 
sent in one patch, together with implementation).

Also, in other patches, please add comments pointing to specifications 
of these function when you implement them. It would be good idea to get 
one patch accepted before resending the whole series.


Jacek



More information about the wine-devel mailing list