avm2: Add an extra test for sparse arrays

This commit is contained in:
Adrian Wielgosik 2024-04-20 21:18:53 +02:00 committed by Adrian Wielgosik
parent 7e349d9190
commit 6ce88f24de
4 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,63 @@
// compiled with mxmlc
var arr = [1, 2];
arr[50] = 6;
arr[100] = 10;
arr[500] = 11;
trace(arr[0]);
trace(arr[50]);
trace(arr[100]);
trace(arr[500]);
trace(arr[1000]);
trace(arr.length);
trace("// delete")
delete arr[50];
trace(arr[50]);
trace(arr[100]);
trace("// push")
arr.push(12);
trace(arr.length);
trace(arr[501]);
trace(arr.pop());
trace(arr.length);
trace(arr[500]);
trace("// for")
for (var i in arr) {
trace(i);
}
trace("// for each")
for each (var i in arr) {
trace(i);
}
trace("// shift");
trace(arr.shift());
trace(arr.length);
trace(arr[0]);
trace(arr[99]);
trace(arr[499]);
trace("// shift")
arr.unshift(1);
trace(arr.length);
trace(arr[0]);
trace(arr[100]);
trace(arr[500]);
trace("// removeAt");
trace(arr.removeAt(150));
trace(arr.length);
trace(arr[499]);
trace(arr[500]);
package {
import flash.display.MovieClip;
import flash.text.TextField;
public class Test extends MovieClip {
public function Test(){
}
}
}

View File

@ -0,0 +1,41 @@
1
6
10
11
undefined
501
// delete
undefined
10
// push
502
12
12
501
11
// for
0
1
100
500
// for each
1
2
10
11
// shift
1
500
2
10
11
// shift
501
1
10
11
// removeAt
undefined
500
11
undefined

Binary file not shown.

View File

@ -0,0 +1 @@
num_frames = 1