Add a test for stored properties as well.

This test passed with no errors.
This commit is contained in:
David Wendt 2020-02-28 22:31:47 -05:00
parent 5abc78d3bd
commit 6cc3f7ecc3
5 changed files with 59 additions and 0 deletions

View File

@ -232,6 +232,7 @@ swf_tests! {
(as3_constructor_call, "avm2/constructor_call", 1), (as3_constructor_call, "avm2/constructor_call", 1),
(as3_class_methods, "avm2/class_methods", 1), (as3_class_methods, "avm2/class_methods", 1),
(as3_inheritance, "avm2/inheritance", 1), (as3_inheritance, "avm2/inheritance", 1),
(as3_stored_properties, "avm2/stored_properties", 1),
(as3_virtual_properties, "avm2/virtual_properties", 1), (as3_virtual_properties, "avm2/virtual_properties", 1),
} }

View File

@ -0,0 +1,47 @@
package {
public class Test {
}
}
class TestWithVars {
public var prop;
public var propDefault = "y.propDefault resolved!";
public const propConst = "y.propConst resolved!";
}
class ExtendedTest extends TestWithVars {
public var prop2;
public var prop2Default = "z.prop2Default resolved!";
public const prop2Const = "z.prop2Const resolved!";
}
var x = {};
x.prop = "x.prop resolved!";
trace(x.prop);
var y = new TestWithVars();
y.prop = "y.prop resolved!";
trace(y.prop);
trace(y.propDefault);
y.propDefault = "y.propDefault overwritten!";
trace(y.propDefault);
trace(y.propConst);
var z = new ExtendedTest();
z.prop = "z.prop resolved!";
trace(z.prop);
z.prop2 = "z.prop2 resolved!";
trace(z.prop2);
trace(z.propDefault);
trace(z.prop2Default);
z.propDefault = "TEST FAIL: Default overrides should not affect other instances!";
trace(y.propDefault);
trace(z.propConst);

View File

@ -0,0 +1,11 @@
x.prop resolved!
y.prop resolved!
y.propDefault resolved!
y.propDefault overwritten!
y.propConst resolved!
z.prop resolved!
z.prop2 resolved!
y.propDefault resolved!
z.prop2Default!
y.propDefault overwritten!
y.propConst resolved!

Binary file not shown.

Binary file not shown.