From 16774aa055284597c189c0544e9bac8fa00b8a01 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sun, 8 Mar 2020 22:21:45 -0400 Subject: [PATCH] Add a test for legacy / ES3 inheritance. This was originally something *way* more evil: mixed inheritance between ES3 and ES4 classes. It didn't pan out due to fundamental limitations of the two object models. How the hell did Brendan Eich/Adobe/TC-39 expect ES4 classes to be adopted in already-existing codebases?! --- core/tests/regression_tests.rs | 1 + core/tests/swfs/avm2/es3_inheritance/Test.as | 67 ++++++++++++++++++ .../swfs/avm2/es3_inheritance/output.txt | 31 ++++++++ core/tests/swfs/avm2/es3_inheritance/test.fla | Bin 0 -> 3983 bytes core/tests/swfs/avm2/es3_inheritance/test.swf | Bin 0 -> 1438 bytes 5 files changed, 99 insertions(+) create mode 100644 core/tests/swfs/avm2/es3_inheritance/Test.as create mode 100644 core/tests/swfs/avm2/es3_inheritance/output.txt create mode 100644 core/tests/swfs/avm2/es3_inheritance/test.fla create mode 100644 core/tests/swfs/avm2/es3_inheritance/test.swf diff --git a/core/tests/regression_tests.rs b/core/tests/regression_tests.rs index 6563a714f..345741624 100644 --- a/core/tests/regression_tests.rs +++ b/core/tests/regression_tests.rs @@ -247,6 +247,7 @@ swf_tests! { (as3_object_to_string, "avm2/object_to_string", 1), (as3_function_to_string, "avm2/function_to_string", 1), (as3_class_to_string, "avm2/class_to_string", 1), + (as3_es3_inheritance, "avm2/es3_inheritance", 1), } // TODO: These tests have some inaccuracies currently, so we use approx_eq to test that numeric values are close enough. diff --git a/core/tests/swfs/avm2/es3_inheritance/Test.as b/core/tests/swfs/avm2/es3_inheritance/Test.as new file mode 100644 index 000000000..9d4d0536b --- /dev/null +++ b/core/tests/swfs/avm2/es3_inheritance/Test.as @@ -0,0 +1,67 @@ +package { + public class Test { + } +} + +function Test2() { + trace("Instance constructor"); +} + +Test2.prototype.method = function() { + trace("Instance method"); +} + +Test2.prototype.method2 = function() { + trace("Instance method 2"); +} + +function Test3() { + trace("Child instance constructor pre-super"); + Test2.call(this); + trace("Child instance constructor post-super"); +} + +Test3.prototype = new Test2(); + +Test3.prototype.method = function() { + trace("Child instance method pre-super"); + Test2.prototype.method.call(this); + trace("Child instance method post-super"); +} + +Test3.prototype.method3 = function() { + trace("Child instance method3 pre-super"); + Test2.prototype.method.call(this); + trace("Child instance method3 post-super"); +} + +function Test4() { + trace("Grandchild instance constructor pre-super"); + Test3.call(this); + trace("Grandchild instance constructor post-super"); +} + +Test4.prototype = new Test3(); + +Test4.prototype.method2 = function () { + trace("Grandchild instance method2 pre-super"); + Test3.prototype.method2.call(this); + trace("Grandchild instance method2 post-super"); +} + +Test4.prototype.method3 = function () { + trace("Grandchild instance method3 pre-super"); + Test3.prototype.method3.call(this); + trace("Grandchild instance method3 post-super"); +} + +trace("Script initializer"); +var x = new Test3(); +x.method(); +x.method2(); +x.method3(); + +var y = new Test4(); +y.method(); +y.method2(); +y.method3(); \ No newline at end of file diff --git a/core/tests/swfs/avm2/es3_inheritance/output.txt b/core/tests/swfs/avm2/es3_inheritance/output.txt new file mode 100644 index 000000000..3d03db4d4 --- /dev/null +++ b/core/tests/swfs/avm2/es3_inheritance/output.txt @@ -0,0 +1,31 @@ +Instance constructor +Child instance constructor pre-super +Instance constructor +Child instance constructor post-super +Script initializer +Child instance constructor pre-super +Instance constructor +Child instance constructor post-super +Child instance method pre-super +Instance method +Child instance method post-super +Instance method 2 +Child instance method3 pre-super +Instance method +Child instance method3 post-super +Grandchild instance constructor pre-super +Child instance constructor pre-super +Instance constructor +Child instance constructor post-super +Grandchild instance constructor post-super +Child instance method pre-super +Instance method +Child instance method post-super +Grandchild instance method2 pre-super +Instance method 2 +Grandchild instance method2 post-super +Grandchild instance method3 pre-super +Child instance method3 pre-super +Instance method +Child instance method3 post-super +Grandchild instance method3 post-super diff --git a/core/tests/swfs/avm2/es3_inheritance/test.fla b/core/tests/swfs/avm2/es3_inheritance/test.fla new file mode 100644 index 0000000000000000000000000000000000000000..6c88e118b22439d3ee8bf244d8878e635a3a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O%?LuGwC`&Zoa2e^~^ zcE6YWGZX#!{C{%MA1OAeDgK3-{#Olq{rSVhnE$<7fBxD3*{?tF=2ZN@bnmwUzBT+m fd-O+wX=;LR9cyBEkbdt8BlVL))v>}Xd%OPurOG|- literal 0 HcmV?d00001 diff --git a/core/tests/swfs/avm2/es3_inheritance/test.swf b/core/tests/swfs/avm2/es3_inheritance/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..a9d6767c51dba7396c4983f590b398d2d2814166 GIT binary patch literal 1438 zcmV;P1!4L_S5qqs3jhFkoSl|kTiQqz$7diR8QwvNh;OK9t8F2IeZzK3i`8oD+Fje{ z@dBPE!XVj&giWHWz1-XV68la172J!x-0wg?LHA4oiY~SLEDxDE=Qsa3bLKD^Jw^Nn zgd%?+l)`8uCL)9?o-bd%yckDlHhMgfUCnO2&2H%j_Q%~{wB~`m`TlkB{hPhb$7eG7 zlnj6#qy0M7X=W9nPl@0C48SLfa;$rgqVK3>=Ts|Od{koQ+I3L84hn>|dDbl2(0pjN z)zYr2>F=}-ZEHHsU(lwhcIfJzZ>WYT$HMyd4u7I`TO25Y!-^09tCeeLR=2I5kzM0N zqm{PSO^%G`b5rnN?typq;Iu`jUBjpN?8$biS}_{5Y92S6ZCb4xCatoFR@M5oX;sye zPN7Pz;s;G{QB$*3y-wHH`%!t@RO@uEW!v3SKCd>6Lz=4_o&59tV!j~D5Auh{THDt2 z#Vu3S8}*jfZe%pwa)M+!)NUD#Vy0`-d)9H6nxtzQwqc)jsn8$e>T0{abmL^hvfbG? ztWmgJqaV3&L(sxd&`jkUIs05P_ch%`q}h>*%Rr-78VV5GzBW{dTqDb)_Ea~(GLP%F zVO}n_@=fK%vf0Xih_`r?=ps~Nd&GErziw(>8|G@Zrna?@)SMn1=-lvuF7;n3PgV}N zC+*nQ+SZu+R;cwlwJhyWYist|;7y^{&$iJGx*j!6!?Xs@3Ds>Y+;>iGYU*mcKdlKz zmYSB|^^T~~>929rHV#>as;wD%z-1lU&{X2uI<-R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