Add `as3_object_enumeration` and `as3_class_enumeration` tests.

The former tests iterating normal objects and the latter tests iterating objects with prototypes.
This commit is contained in:
David Wendt 2020-03-05 21:31:34 -05:00
parent c014b40109
commit d29f3dc1d0
9 changed files with 35 additions and 0 deletions

View File

@ -238,6 +238,8 @@ swf_tests! {
(as3_es4_method_binding, "avm2/es4_method_binding", 1),
(as3_control_flow_bool, "avm2/control_flow_bool", 1),
(as3_control_flow_stricteq, "avm2/control_flow_stricteq", 1),
(as3_object_enumeration, "avm2/object_enumeration", 1),
(as3_class_enumeration, "avm2/class_enumeration", 1),
}
// TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough.

View File

@ -0,0 +1,17 @@
package {
public class Test {}
}
dynamic class ES4Class {
public var variable = "TEST FAIL: Trait properties are NOT enumerable! (var)";
public const constant = "TEST FAIL: Trait properties are NOT enumerable! (const)";
}
var x = new ES4Class();
x.dynamic_variable = "variable value";
ES4Class.prototype.dynamic_prototype_variable = "prototype value";
for (var name in x) {
trace(name);
trace(x[name]);
}

View File

@ -0,0 +1,4 @@
dynamic_variable
variable value
dynamic_prototype_variable
prototype value

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
package {
public class Test {}
}
var x = {"key": "value"};
for (var name in x) {
trace(name);
trace(x[name]);
}

View File

@ -0,0 +1,2 @@
key
value

Binary file not shown.

Binary file not shown.