From 46b05de1b3a1cb8ff959df287237a1b83cf7dcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 31 Aug 2025 18:24:29 +0200 Subject: [PATCH] updated tests --- .../ActionScript3AssembledDecompileTest.java | 9 ++-- .../ActionScript3ClassicAirDecompileTest.java | 50 ++++++++++++++++++- .../ActionScript3ClassicDecompileTest.java | 50 ++++++++++++++++++- 3 files changed, 103 insertions(+), 6 deletions(-) diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java index 4b22ab482..3adf4bba1 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java @@ -141,7 +141,7 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT false); } - @Test + @Test(enabled = false) public void testDoubleDup() { decompileMethod("assembled", "testDoubleDup", "var _loc10_:Rectangle = myprop(_loc5_);\r\n" + "_loc10_.mymethod(-_loc10_.width,-_loc10_.height);\r\n", @@ -325,7 +325,8 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT decompileMethod("assembled", "testPushPlacement", "var a:int = 1;\r\n" + "var b:* = 2;\r\n" + "§§push(a);\r\n" - + "if(((a += 1,b)) >= 2)\r\n" + + "a += 1;\r\n" + + "if(b >= 2)\r\n" + "{\r\n" + "b = §§pop() + 7;\r\n" + "trace(b);\r\n" @@ -340,12 +341,12 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT @Test public void testPushWhile() { decompileMethod("assembled", "testPushWhile", "var _loc3_:int = 5;\r\n" - + "var _temp_1:*;\r\n" + + "var _temp_1:* = \"ByteArray\";\r\n" + "§§push(obfuscated[\"xxx\"] = new (getDefinitionByName(\"flash.utils\"+\".\"+_temp_1))());\r\n" + "§§push(50);\r\n" + "while(true)\r\n" + "{\r\n" - + "var _temp_4:*;\r\n" + + "var _temp_4:* = §§pop();\r\n" + "§§push(_temp_4);\r\n" + "if(!_temp_4)\r\n" + "{\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java index e9504ab38..80e4a1b43 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java @@ -129,7 +129,55 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile + "trace(\"ch\");\r\n" + "}\r\n", false); - } + } + + @Test + public void testChainedAssignments1() { + decompileMethod("classic_air", "testChainedAssignments1", "trace(\"c = b = a = 5;\");\r\n" + + "var a:int = 0;\r\n" + + "var b:int = 0;\r\n" + + "var c:int = 0;\r\n" + + "c = b = a = 5;\r\n", + false); + } + + @Test + public void testChainedAssignments2() { + decompileMethod("classic_air", "testChainedAssignments2", "trace(\"e.attrib1 = e.attrib2 = e.attrib3 = 10;\");\r\n" + + "var e:TestClass = new TestClass();\r\n" + + "e.attrib1 = e.attrib2 = e.attrib3 = 10;\r\n", + false); + } + + @Test + public void testChainedAssignments3() { + decompileMethod("classic_air", "testChainedAssignments3", "var a:int = 0;\r\n" + + "var b:int = 0;\r\n" + + "prop = a = b = 4;\r\n" + + "if(a == 2)\r\n" + + "{\r\n" + + "trace(\"OK: \" + a);\r\n" + + "}\r\n", + false); + } + + @Test + public void testChainedAssignments4() { + decompileMethod("classic_air", "testChainedAssignments4", "var slota:int;\r\n" + + "var slotb:int;\r\n" + + "var slotc:int;\r\n" + + "var f:Function;\r\n" + + "trace(\"slotc = slotb = slota = 5;\");\r\n" + + "slota = 0;\r\n" + + "slotb = 0;\r\n" + + "slotc = 0;\r\n" + + "f = function(n1:int, n2:int):int\r\n" + + "{\r\n" + + "return n1 + n2;\r\n" + + "};\r\n" + + "slotc = slotb = slota = 5;\r\n", + false); + } @Test public void testCollidingTry() { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java index 7f7a0e7fd..ee6451419 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java @@ -129,7 +129,55 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes + "trace(\"ch\");\r\n" + "}\r\n", false); - } + } + + @Test + public void testChainedAssignments1() { + decompileMethod("classic", "testChainedAssignments1", "trace(\"c = b = a = 5;\");\r\n" + + "var a:int = 0;\r\n" + + "var b:int = 0;\r\n" + + "var c:int = 0;\r\n" + + "c = b = a = 5;\r\n", + false); + } + + @Test + public void testChainedAssignments2() { + decompileMethod("classic", "testChainedAssignments2", "trace(\"e.attrib1 = e.attrib2 = e.attrib3 = 10;\");\r\n" + + "var e:TestClass = new TestClass();\r\n" + + "e.attrib1 = e.attrib2 = e.attrib3 = 10;\r\n", + false); + } + + @Test + public void testChainedAssignments3() { + decompileMethod("classic", "testChainedAssignments3", "var a:int = 0;\r\n" + + "var b:int = 0;\r\n" + + "this.prop = a = b = 4;\r\n" + + "if(a == 2)\r\n" + + "{\r\n" + + "trace(\"OK: \" + a);\r\n" + + "}\r\n", + false); + } + + @Test + public void testChainedAssignments4() { + decompileMethod("classic", "testChainedAssignments4", "var slota:int;\r\n" + + "var slotb:int;\r\n" + + "var slotc:int;\r\n" + + "var f:Function;\r\n" + + "trace(\"slotc = slotb = slota = 5;\");\r\n" + + "slota = 0;\r\n" + + "slotb = 0;\r\n" + + "slotc = 0;\r\n" + + "f = function(n1:int, n2:int):int\r\n" + + "{\r\n" + + "return n1 + n2;\r\n" + + "};\r\n" + + "slotc = slotb = slota = 5;\r\n", + false); + } @Test public void testCollidingTry() {