avm2: Fix Array.sort(function)
This commit is contained in:
parent
3e193214df
commit
26cf380aa4
|
@ -1014,16 +1014,16 @@ pub fn sort<'gc>(
|
||||||
.coerce_to_u32(activation)? as u8,
|
.coerce_to_u32(activation)? as u8,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
let arg = args.get(0).cloned().unwrap_or(Value::Undefined);
|
||||||
|
if let Ok(callable) = arg.as_callable(activation, None, None) {
|
||||||
|
(Some(callable), SortOptions::empty())
|
||||||
} else {
|
} else {
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
SortOptions::from_bits_truncate(
|
SortOptions::from_bits_truncate(arg.coerce_to_u32(activation)? as u8),
|
||||||
args.get(0)
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(|| 0.into())
|
|
||||||
.coerce_to_u32(activation)? as u8,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut values = if let Some(values) = extract_array_values(activation, this.into())? {
|
let mut values = if let Some(values) = extract_array_values(activation, this.into())? {
|
||||||
|
|
|
@ -26,7 +26,7 @@ function length_based_comparison(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sub_comparison(a, b) {
|
function sub_comparison(a, b) {
|
||||||
return a - b;
|
return b - a;
|
||||||
}
|
}
|
||||||
|
|
||||||
function lbc(a, b) {
|
function lbc(a, b) {
|
||||||
|
|
|
@ -263,17 +263,17 @@ false
|
||||||
//Array.prototype[10] = "hole in slot 10";
|
//Array.prototype[10] = "hole in slot 10";
|
||||||
//var a = new Array(7,2,1,"3","4")
|
//var a = new Array(7,2,1,"3","4")
|
||||||
//(contents of a.sort(sub_comparison))
|
//(contents of a.sort(sub_comparison))
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
7
|
7
|
||||||
|
4
|
||||||
|
3
|
||||||
|
2
|
||||||
|
1
|
||||||
//(contents of a.sort(sub_comparison, 2))
|
//(contents of a.sort(sub_comparison, 2))
|
||||||
7
|
|
||||||
4
|
|
||||||
3
|
|
||||||
2
|
|
||||||
1
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
7
|
||||||
//(contents of a.sort(sub_comparison, Array.RETURNINDEXEDARRAY))
|
//(contents of a.sort(sub_comparison, Array.RETURNINDEXEDARRAY))
|
||||||
4
|
4
|
||||||
3
|
3
|
||||||
|
@ -293,5 +293,5 @@ false
|
||||||
true
|
true
|
||||||
//var d = new Array(3,"4")
|
//var d = new Array(3,"4")
|
||||||
//(contents of d.sort(sub_comparison, 4))
|
//(contents of d.sort(sub_comparison, 4))
|
||||||
3
|
|
||||||
4
|
4
|
||||||
|
3
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue