Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
2e075e98
Commit
2e075e98
authored
Oct 16, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 17, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added NaN handling to Math.min and Math.max.
parent
531f8336
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
math.c
dlls/jscript/math.c
+11
-10
api.js
dlls/jscript/tests/api.js
+12
-0
No files found.
dlls/jscript/math.c
View file @
2e075e98
...
...
@@ -16,6 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include "jscript.h"
...
...
@@ -222,11 +225,10 @@ static HRESULT Math_max(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
TRACE
(
"
\n
"
);
/* FIXME: Handle NaN */
if
(
!
arg_cnt
(
dp
))
{
FIXME
(
"arg_cnt = 0
\n
"
);
return
E_NOTIMPL
;
if
(
retv
)
num_set_inf
(
retv
,
FALSE
);
return
S_OK
;
}
hres
=
to_number
(
dispex
->
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
...
...
@@ -240,7 +242,7 @@ static HRESULT Math_max(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
return
hres
;
d
=
num_val
(
&
v
);
if
(
d
>
max
)
if
(
d
>
max
||
isnan
(
d
)
)
max
=
d
;
}
...
...
@@ -260,11 +262,10 @@ static HRESULT Math_min(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
TRACE
(
"
\n
"
);
/* FIXME: Handle NaN */
if
(
!
arg_cnt
(
dp
))
{
FIXME
(
"arg_cnt = 0
\n
"
);
return
E_NOTIMPL
;
if
(
retv
)
num_set_inf
(
retv
,
TRUE
);
return
S_OK
;
}
hres
=
to_number
(
dispex
->
ctx
,
get_arg
(
dp
,
0
),
ei
,
&
v
);
...
...
@@ -278,7 +279,7 @@ static HRESULT Math_min(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *d
return
hres
;
d
=
num_val
(
&
v
);
if
(
d
<
min
)
if
(
d
<
min
||
isnan
(
d
)
)
min
=
d
;
}
...
...
dlls/jscript/tests/api.js
View file @
2e075e98
...
...
@@ -368,6 +368,12 @@ ok(tmp === 1, "Math.min(1) = " + tmp);
tmp
=
Math
.
min
(
1
,
false
);
ok
(
tmp
===
0
,
"Math.min(1, false) = "
+
tmp
);
tmp
=
Math
.
min
();
ok
(
tmp
===
Infinity
,
"Math.min() = "
+
tmp
);
tmp
=
Math
.
min
(
1
,
NaN
,
-
Infinity
,
false
);
ok
(
isNaN
(
tmp
),
"Math.min(1, NaN, -Infinity, false) is not NaN"
);
tmp
=
Math
.
min
(
1
,
false
,
true
,
null
,
-
3
);
ok
(
tmp
===
-
3
,
"Math.min(1, false, true, null, -3) = "
+
tmp
);
...
...
@@ -380,6 +386,12 @@ ok(tmp === 1, "Math.max(true, 0) = " + tmp);
tmp
=
Math
.
max
(
-
2
,
false
,
true
,
null
,
1
);
ok
(
tmp
===
1
,
"Math.max(-2, false, true, null, 1) = "
+
tmp
);
tmp
=
Math
.
max
();
ok
(
tmp
===
-
Infinity
,
"Math.max() = "
+
tmp
);
tmp
=
Math
.
max
(
true
,
NaN
,
0
);
ok
(
isNaN
(
tmp
),
"Math.max(true, NaN, 0) is not NaN"
);
tmp
=
Math
.
round
(
0.5
);
ok
(
tmp
===
1
,
"Math.round(0.5) = "
+
tmp
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment