tests: Add test for reading AMF3 objects

This commit is contained in:
EmperorBale 2021-08-28 17:19:13 -07:00 committed by Mike Welsh
parent da601a4984
commit e7a723f250
6 changed files with 108 additions and 1 deletions

2
Cargo.lock generated
View File

@ -1310,7 +1310,7 @@ dependencies = [
[[package]]
name = "flash-lso"
version = "0.5.0"
source = "git+https://github.com/ruffle-rs/rust-flash-lso#19fecd07b9888c4bdaa66771c468095783b52bed"
source = "git+https://github.com/ruffle-rs/rust-flash-lso?rev=19fecd07b9888c4bdaa66771c468095783b52bed#19fecd07b9888c4bdaa66771c468095783b52bed"
dependencies = [
"cookie-factory",
"derive-try-from-primitive",

View File

@ -478,6 +478,7 @@ swf_tests! {
(as3_get_definition_by_name, "avm2/get_definition_by_name", 1),
(as3_get_qualified_class_name, "avm2/get_qualified_class_name", 1),
(as3_get_qualified_super_class_name, "avm2/get_qualified_super_class_name", 1),
(as3_bytearray_readobject_amf3, "avm2/bytearray_readobject_amf3", 1),
(as3_array_constr, "avm2/array_constr", 1),
(as3_array_access, "avm2/array_access", 1),
(as3_array_storage, "avm2/array_storage", 1),

View File

@ -0,0 +1,56 @@
package
{
import flash.utils.ByteArray;
public class Test
{
var TESTS = [
[0], // UNDEFINED
[1], // NULL
[2], // FALSE
[3], // TRUE
[4,1], // INTEGER
[5,63,241,153,153,153,153,153,154], // NUMBER
[5,127,240,0,0,0,0,0,0], // INFINITY
[5,255,240,0,0,0,0,0,0], // NEG INFINITY
[5,255,248,0,0,0,0,0,0], // NAN
[6,23,84,101,115,116,32,115,116,114,105,110,103], // STRING
[9,7,1,4,1,4,2,4,3], // DENSE ARRAY
[9,7,5,50,48,4,2,1,4,1,4,2,4,3], // ARRAY WITH HOLES
[9,7,11,104,101,108,108,111,4,5,1,4,1,4,2,4,3], // ARRAY WITH ELEMENTS
[9,7,5,50,48,4,4,11,104,101,108,108,111,4,5,1,4,1,4,2,4,3], // ARRAY WITH HOLES AND ELEMENTS
[9,7,1,9,5,1,4,5,4,3,9,5,1,4,7,4,2,9,5,1,4,7,9,5,1,4,8,4,2], // MULTI DIMENSIONAL ARRAY
[10,11,1,9,116,101,115,116,6,0,1],
[12,21,84,101,115,116,32,98,121,116,101,115] // BYTEARRAY
];
public function testToObject(arr)
{
var ba = new ByteArray();
for (var i = 0; i < arr.length; i++)
{
ba.writeByte(arr[i]);
}
ba.position = 0;
return ba.readObject();
}
public function Test()
{
for (var i = 0; i < TESTS.length; i++)
{
var obj = testToObject(TESTS[i]);
trace(obj);
if (obj is Object)
{
trace("showing props:");
for (var prop in obj)
{
if (! (prop is int))
{
trace(prop);
}
}
trace("done showing props");
}
}
}
}
}

View File

@ -0,0 +1,50 @@
undefined
null
false
showing props:
done showing props
true
showing props:
done showing props
1
showing props:
done showing props
1.1
showing props:
done showing props
Infinity
showing props:
done showing props
-Infinity
showing props:
done showing props
NaN
showing props:
done showing props
Test string
showing props:
done showing props
1,2,3
showing props:
done showing props
1,2,3,,,,,,,,,,,,,,,,,,2
showing props:
done showing props
1,2,3
showing props:
hello
done showing props
1,2,3,,,,,,,,,,,,,,,,,,4
showing props:
hello
done showing props
5,3,7,2,7,8,2
showing props:
done showing props
[object Object]
showing props:
test
done showing props
Test bytes
showing props:
done showing props