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
6682290d
Commit
6682290d
authored
Jun 03, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jun 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Support ES5 Array.prototype.sort arguments handling.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8a9bbe49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
17 deletions
+49
-17
array.c
dlls/jscript/array.c
+16
-17
api.js
dlls/jscript/tests/api.js
+13
-0
es5.js
dlls/mshtml/tests/es5.js
+20
-0
No files found.
dlls/jscript/array.c
View file @
6682290d
...
...
@@ -685,23 +685,22 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne
if
(
FAILED
(
hres
))
return
hres
;
if
(
argc
>
1
)
{
WARN
(
"invalid arg_cnt %d
\n
"
,
argc
);
return
E_FAIL
;
}
if
(
argc
==
1
)
{
if
(
!
is_object_instance
(
argv
[
0
]))
{
WARN
(
"arg is not dispatch
\n
"
);
return
E_FAIL
;
}
cmp_func
=
iface_to_jsdisp
(
get_object
(
argv
[
0
]));
if
(
!
cmp_func
||
!
is_class
(
cmp_func
,
JSCLASS_FUNCTION
))
{
WARN
(
"cmp_func is not a function
\n
"
);
if
(
cmp_func
)
jsdisp_release
(
cmp_func
);
return
E_FAIL
;
if
(
argc
>=
1
)
{
if
(
is_object_instance
(
argv
[
0
]))
{
if
(
argc
>
1
&&
ctx
->
version
<
SCRIPTLANGUAGEVERSION_ES5
)
{
WARN
(
"invalid arg_cnt %d
\n
"
,
argc
);
return
JS_E_JSCRIPT_EXPECTED
;
}
cmp_func
=
iface_to_jsdisp
(
get_object
(
argv
[
0
]));
if
(
!
cmp_func
||
!
is_class
(
cmp_func
,
JSCLASS_FUNCTION
))
{
WARN
(
"cmp_func is not a function
\n
"
);
if
(
cmp_func
)
jsdisp_release
(
cmp_func
);
return
JS_E_JSCRIPT_EXPECTED
;
}
}
else
if
(
ctx
->
version
>=
SCRIPTLANGUAGEVERSION_ES5
?
!
is_undefined
(
argv
[
0
])
:
!
is_null
(
argv
[
0
]))
{
WARN
(
"invalid arg %s
\n
"
,
debugstr_jsval
(
argv
[
0
]));
return
JS_E_JSCRIPT_EXPECTED
;
}
}
...
...
dlls/jscript/tests/api.js
View file @
6682290d
...
...
@@ -1039,6 +1039,19 @@ tmp = [5,3,"2.5",2,true,false,-1];
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
ok
(
arr
[
i
]
===
tmp
[
i
],
"arr["
+
i
+
"] = "
+
arr
[
i
]
+
" expected "
+
tmp
[
i
]);
tmp
=
[
3
,
1
,
2
].
sort
(
function
(
x
,
y
)
{
return
y
-
x
;
}).
join
();
ok
(
tmp
===
"3,2,1"
,
"reverse sorted [3,1,2] = "
+
tmp
);
tmp
=
[
3
,
1
,
2
].
sort
(
null
).
join
();
ok
(
tmp
===
"1,2,3"
,
"null sorted [3,1,2] = "
+
tmp
);
try
{
tmp
=
[
3
,
1
,
2
].
sort
(
function
(
x
,
y
)
{
return
y
-
x
;
},
1
,
2
,
3
);
ok
(
false
,
"expected sort(undefined) exception"
);
}
catch
(
e
)
{
ok
(
e
.
name
===
"TypeError"
,
"got exception "
+
e
.
name
);
}
arr
=
[
5
,
false
,
2
,
0
,
"abc"
,
3
,
"a"
,
-
1
];
tmp
=
arr
.
sort
();
ok
(
tmp
===
arr
,
"tmp !== arr"
);
...
...
dlls/mshtml/tests/es5.js
View file @
6682290d
...
...
@@ -188,6 +188,25 @@ function test_array_map() {
next_test
();
}
function
test_array_sort
()
{
var
r
;
r
=
[
3
,
1
,
2
].
sort
(
function
(
x
,
y
)
{
return
y
-
x
;
},
1
,
2
,
3
,
true
,
undefined
).
join
();
ok
(
r
===
"3,2,1"
,
"reverse sorted [3,1,2] = "
+
r
);
r
=
[
3
,
1
,
2
].
sort
(
undefined
).
join
();
ok
(
r
===
"1,2,3"
,
"null sorted [3,1,2] = "
+
r
);
try
{
r
=
[
3
,
1
,
2
].
sort
(
null
);
ok
(
false
,
"expected sort(null) exception"
);
}
catch
(
e
)
{
ok
(
e
.
name
===
"TypeError"
,
"got exception "
+
e
.
name
);
}
next_test
();
}
function
test_identifier_keywords
()
{
var
o
=
{
if
:
1
,
...
...
@@ -883,6 +902,7 @@ var tests = [
test_array_forEach
,
test_isArray
,
test_array_map
,
test_array_sort
,
test_identifier_keywords
,
test_getOwnPropertyDescriptor
,
test_defineProperty
,
...
...
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