mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-08-02 15:32:15 +00:00
added tests
This commit is contained in:
@@ -122,7 +122,6 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
|
||||
+ "case 0:\r\n"
|
||||
+ "var _loc2_:String = \"X\";\r\n"
|
||||
+ "return;\r\n"
|
||||
//+ "break;\r\n"
|
||||
+ "case 1:\r\n"
|
||||
+ "_loc2_ = \"A\";\r\n"
|
||||
+ "break;\r\n"
|
||||
@@ -159,6 +158,52 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchJoin() {
|
||||
decompileMethod("assembled", "testSwitchJoin", "trace(\"before\");\r\n"
|
||||
+ "var _loc2_:int = 57;\r\n"
|
||||
+ "switch(_loc2_)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "case 0:\r\n"
|
||||
+ "case 3:\r\n"
|
||||
+ "trace(\"0-3\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "case 1:\r\n"
|
||||
+ "case 6:\r\n"
|
||||
+ "trace(\"1-6\");\r\n"
|
||||
+ "addr106:\r\n"
|
||||
+ "trace(\"F\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "case 5:\r\n"
|
||||
+ "trace(\"5\");\r\n"
|
||||
+ "addr103:\r\n"
|
||||
+ "trace(\"E\");\r\n"
|
||||
+ "§§goto(addr106);\r\n"
|
||||
+ "case 7:\r\n"
|
||||
+ "trace(\"7\");\r\n"
|
||||
+ "addr100:\r\n"
|
||||
+ "trace(\"D\");\r\n"
|
||||
+ "§§goto(addr103);\r\n"
|
||||
+ "case 2:\r\n"
|
||||
+ "trace(\"2\");\r\n"
|
||||
+ "addr97:\r\n"
|
||||
+ "trace(\"C\");\r\n"
|
||||
+ "§§goto(addr100);\r\n"
|
||||
+ "case 8:\r\n"
|
||||
+ "trace(\"8\");\r\n"
|
||||
+ "addr94:\r\n"
|
||||
+ "trace(\"B\");\r\n"
|
||||
+ "§§goto(addr97);\r\n"
|
||||
+ "default:\r\n"
|
||||
+ "trace(\"def\");\r\n"
|
||||
+ "trace(\"A\");\r\n"
|
||||
+ "§§goto(addr94);\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"G\");\r\n"
|
||||
+ "return null;\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryDoWhile() {
|
||||
decompileMethod("assembled", "testTryDoWhile", "trace(\"first\");\r\n"
|
||||
|
||||
@@ -203,6 +203,38 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeobfuscation() {
|
||||
decompileMethod("classic_air", "testDeobfuscation", "var r:int = Math.random();\r\n"
|
||||
+ "var t:Boolean = true;\r\n"
|
||||
+ "var f:Boolean = false;\r\n"
|
||||
+ "if(r > 5 && t)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"A\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(r > 10 || f)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"B\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(t && r > 15)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"C\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(f || r > 20)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"D\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(f)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"trash1\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(!t)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"trash2\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoWhile() {
|
||||
decompileMethod("classic_air", "testDoWhile", "var a:int = 8;\r\n"
|
||||
@@ -740,6 +772,28 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreAndOr() {
|
||||
decompileMethod("classic_air", "testIgnoreAndOr", "var k:int = Math.random();\r\n"
|
||||
+ "if(k > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"A\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"B\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 15)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"C\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 20)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"D\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInc2() {
|
||||
decompileMethod("classic_air", "testInc2", "var a:* = [1];\r\n"
|
||||
|
||||
@@ -201,6 +201,38 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeobfuscation() {
|
||||
decompileMethod("classic", "testDeobfuscation", "var r:int = Math.random();\r\n"
|
||||
+ "var t:Boolean = true;\r\n"
|
||||
+ "var f:Boolean = false;\r\n"
|
||||
+ "if(r > 5 && t)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"A\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(r > 10 || f)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"B\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(t && r > 15)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"C\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(f || r > 20)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"D\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(f)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"trash1\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(!t)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"trash2\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoWhile() {
|
||||
decompileMethod("classic", "testDoWhile", "var a:* = 8;\r\n"
|
||||
@@ -731,6 +763,28 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreAndOr() {
|
||||
decompileMethod("classic", "testIgnoreAndOr", "var k:int = Math.random();\r\n"
|
||||
+ "if(k > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"A\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"B\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 15)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"C\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(k > 20)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"D\");\r\n"
|
||||
+ "}\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInc2() {
|
||||
decompileMethod("classic", "testInc2", "var a:* = [1];\r\n"
|
||||
|
||||
@@ -77,6 +77,23 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchInIf(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchInIf", "var a:int = Math.random();\r\n"
|
||||
+ "if(a > 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return 1;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return 2;\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchInWhile(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchInWhile", "trace(\"before loop\");\r\n"
|
||||
@@ -139,6 +156,55 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchInWhile3(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchInWhile3", "var a:int = 0;\r\n"
|
||||
+ "a = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "while(a > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return \"intry return\";\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch\");\r\n"
|
||||
+ "a++;\r\n"
|
||||
+ "continue;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return \"OK\";\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchInWhile4(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchInWhile4", "var a:int = 0;\r\n"
|
||||
+ "a = 0;\r\n"
|
||||
+ "while(true)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"try2\");\r\n"
|
||||
+ "if(a == 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"br\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch2\");\r\n"
|
||||
+ "trace(\"a=\" + a);\r\n"
|
||||
+ "continue;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchLoop(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchLoop", "var j:int = 0;\r\n"
|
||||
@@ -169,6 +235,29 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryCatchLoopBreak(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryCatchLoopBreak", "var a:int = 0;\r\n"
|
||||
+ "a = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in try1\");\r\n"
|
||||
+ "while(a < 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"a=\" + a);\r\n"
|
||||
+ "a++;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"in try2\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfNamesProvider")
|
||||
public void testTryFinally(String swfUsed) {
|
||||
decompileMethod(swfUsed, "testTryFinally", "trace(\"before try\");\r\n"
|
||||
|
||||
@@ -68,6 +68,23 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchInIf() {
|
||||
decompileMethod("swftools", "testTryCatchInIf", "var _loc1_:int = Math.random();\r\n"
|
||||
+ "if(_loc1_ > 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return 1;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return 2;\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchInWhile() {
|
||||
decompileMethod("swftools", "testTryCatchInWhile", "trace(\"before loop\");\r\n"
|
||||
@@ -130,6 +147,57 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchInWhile3() {
|
||||
decompileMethod("swftools", "testTryCatchInWhile3", "var _loc1_:int = 0;\r\n"
|
||||
+ "_loc1_ = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "for(; _loc1_ > 5; §§goto(addr15))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return \"intry return\";\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "addr15:\r\n"
|
||||
+ "trace(\"in catch\");\r\n"
|
||||
+ "_loc1_++;\r\n"
|
||||
+ "continue;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return \"OK\";\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchInWhile4() {
|
||||
decompileMethod("swftools", "testTryCatchInWhile4", "var _loc1_:int = 0;\r\n"
|
||||
+ "_loc1_ = 0;\r\n"
|
||||
+ "for(; true; §§goto(addr23))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"try2\");\r\n"
|
||||
+ "if(_loc1_ == 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"br\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "addr23:\r\n"
|
||||
+ "trace(\"in catch2\");\r\n"
|
||||
+ "trace(\"a=\" + _loc1_);\r\n"
|
||||
+ "continue;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchLoop() {
|
||||
decompileMethod("swftools", "testTryCatchLoop", "var _loc1_:int = 0;\r\n"
|
||||
@@ -159,6 +227,79 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchLoopBreak() {
|
||||
decompileMethod("swftools", "testTryCatchLoopBreak", "var _loc1_:int = 0;\r\n"
|
||||
+ "_loc1_ = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in try1\");\r\n"
|
||||
+ "while(_loc1_ < 10)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"a=\" + _loc1_);\r\n"
|
||||
+ "_loc1_++;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"in try2\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchLoopBreak2() {
|
||||
decompileMethod("swftools", "testTryCatchLoopBreak2", "var _loc1_:int = 0;\r\n"
|
||||
+ "_loc1_ = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "for(; _loc1_ < 20; §§goto(addr17))\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in try\");\r\n"
|
||||
+ "return;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "addr17:\r\n"
|
||||
+ "trace(\"in catch\");\r\n"
|
||||
+ "trace(\"a=\" + _loc1_);\r\n"
|
||||
+ "continue;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryCatchLoopBreak3() {
|
||||
decompileMethod("swftools", "testTryCatchLoopBreak3", "var _loc1_:int = 0;\r\n"
|
||||
+ "_loc1_ = 0;\r\n"
|
||||
+ "trace(\"before loop\");\r\n"
|
||||
+ "while(true)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "try\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in try\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:Error)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch1\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "catch(e:EOFError)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"in catch2\");\r\n"
|
||||
+ "break;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "trace(\"after\");\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTryFinally() {
|
||||
decompileMethod("swftools", "testTryFinally", "trace(\"before try\");\r\n"
|
||||
|
||||
Reference in New Issue
Block a user