mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-26 03:45:41 +00:00
Fixed tests.
This commit is contained in:
@@ -1871,10 +1871,27 @@ public class AVM2Graph extends Graph {
|
||||
}
|
||||
List<GraphTargetItem> caseValuesMap = caseValuesMapLeft;
|
||||
|
||||
//Only handle switches with more than 2 branches
|
||||
if (caseValuesMap.size() <= 2) {
|
||||
stack.push(set);
|
||||
return ret;
|
||||
//It's not switch, it's an If
|
||||
if (caseBodyParts.size() == 2) {
|
||||
boolean isIf = false;
|
||||
for (GraphPart r : part.refs) {
|
||||
if (r != origPart && !origPart.leadsTo(localData, this, code, r, loops, throwStates, false)) {
|
||||
isIf = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isIf) {
|
||||
for (GraphPart r : caseBodyParts.get(1).refs) {
|
||||
if (r != origPart && !origPart.leadsTo(localData, this, code, r, loops, throwStates, false)) {
|
||||
isIf = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isIf) {
|
||||
stack.push(firstSet);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
//determine whether local register are on left or on right side of === operator
|
||||
|
||||
@@ -1246,6 +1246,24 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfInsteadSwitch() {
|
||||
decompileMethod("classic_air", "testIfInsteadSwitch", "var a:int = 5;\r\n"
|
||||
+ "if(a > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "if(a === 0)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"X\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(a === 1)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return \"A\";\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return \"B\";\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfTry() {
|
||||
decompileMethod("classic_air", "testIfTry", "var c:int = 0;\r\n"
|
||||
|
||||
@@ -1245,6 +1245,24 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfInsteadSwitch() {
|
||||
decompileMethod("classic", "testIfInsteadSwitch", "var a:int = 5;\r\n"
|
||||
+ "if(a > 5)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "if(a === 0)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "trace(\"X\");\r\n"
|
||||
+ "}\r\n"
|
||||
+ "}\r\n"
|
||||
+ "if(a === 1)\r\n"
|
||||
+ "{\r\n"
|
||||
+ "return \"A\";\r\n"
|
||||
+ "}\r\n"
|
||||
+ "return \"B\";\r\n",
|
||||
false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIfTry() {
|
||||
decompileMethod("classic", "testIfTry", "var c:int = 0;\r\n"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -78,6 +78,7 @@ package
|
||||
TestIfElse;
|
||||
TestIfFinally;
|
||||
TestIfInIf;
|
||||
TestIfInsteadSwitch;
|
||||
TestIfTry;
|
||||
TestIgnoreAndOr;
|
||||
TestImplicitCoerce;
|
||||
|
||||
23
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestIfInsteadSwitch.as
vendored
Normal file
23
libsrc/ffdec_lib/testdata/as3_new/src/tests/TestIfInsteadSwitch.as
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package tests
|
||||
{
|
||||
|
||||
public class TestIfInsteadSwitch
|
||||
{
|
||||
public function run():*
|
||||
{
|
||||
var a:int = 5;
|
||||
if(a > 5)
|
||||
{
|
||||
if(a === 0)
|
||||
{
|
||||
trace("X");
|
||||
}
|
||||
}
|
||||
if(a === 1)
|
||||
{
|
||||
return "A";
|
||||
}
|
||||
return "B";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user