diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java index 015a30a73..f8b54fe37 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java @@ -430,6 +430,66 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi false); } + @Test(dataProvider = "swfNamesProvider") + public void testTryCatchLoopBreak6(String swfUsed) { + decompileMethod(swfUsed, "testTryCatchLoopBreak6", "var a:int = 0;\r\n" + + "a = 0;\r\n" + + "trace(\"before loop\");\r\n" + + "while(a < 10)\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" + + "if(a > 3)\r\n" + + "{\r\n" + + "break;\r\n" + + "}\r\n" + + "try\r\n" + + "{\r\n" + + "trace(\"in try2\");\r\n" + + "}\r\n" + + "catch(e:Error)\r\n" + + "{\r\n" + + "trace(\"in catch2\");\r\n" + + "if(a > 4)\r\n" + + "{\r\n" + + "break;\r\n" + + "}\r\n" + + "}\r\n" + + "}\r\n" + + "a++;\r\n" + + "}\r\n" + + "trace(\"after\");\r\n", + false); + } + + @Test(dataProvider = "swfNamesProvider") + public void testTryCatchReturn(String swfUsed) { + decompileMethod(swfUsed, "testTryCatchReturn", "var a:int = 0;\r\n" + + "a = 5;\r\n" + + "trace(\"before try\");\r\n" + + "try\r\n" + + "{\r\n" + + "trace(\"in try\");\r\n" + + "}\r\n" + + "catch(e:Error)\r\n" + + "{\r\n" + + "trace(\"in catch\");\r\n" + + "if(a == 5)\r\n" + + "{\r\n" + + "return a;\r\n" + + "}\r\n" + + "trace(\"in catch2\");\r\n" + + "}\r\n" + + "trace(\"after\");\r\n" + + "return -1;\r\n", + false); + } + @Test(dataProvider = "swfNamesProvider") public void testTryCatchTry(String swfUsed) { decompileMethod(swfUsed, "testTryCatchTry", "trace(\"before try\");\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java index ea00cada0..9902b6426 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java @@ -421,6 +421,66 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript false); } + @Test + public void testTryCatchLoopBreak6() { + decompileMethod("swftools", "testTryCatchLoopBreak6", "var _loc1_:int = 0;\r\n" + + "_loc1_ = 0;\r\n" + + "trace(\"before loop\");\r\n" + + "while(_loc1_ < 10)\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" + + "if(_loc1_ > 3)\r\n" + + "{\r\n" + + "break;\r\n" + + "}\r\n" + + "try\r\n" + + "{\r\n" + + "trace(\"in try2\");\r\n" + + "}\r\n" + + "catch(e:Error)\r\n" + + "{\r\n" + + "trace(\"in catch2\");\r\n" + + "if(_loc1_ > 4)\r\n" + + "{\r\n" + + "break;\r\n" + + "}\r\n" + + "}\r\n" + + "}\r\n" + + "_loc1_++;\r\n" + + "}\r\n" + + "trace(\"after\");\r\n", + false); + } + + @Test + public void testTryCatchReturn() { + decompileMethod("swftools", "testTryCatchReturn", "var _loc1_:int = 0;\r\n" + + "_loc1_ = 5;\r\n" + + "trace(\"before try\");\r\n" + + "try\r\n" + + "{\r\n" + + "trace(\"in try\");\r\n" + + "}\r\n" + + "catch(e:Error)\r\n" + + "{\r\n" + + "trace(\"in catch\");\r\n" + + "if(_loc1_ == 5)\r\n" + + "{\r\n" + + "return _loc1_;\r\n" + + "}\r\n" + + "trace(\"in catch2\");\r\n" + + "}\r\n" + + "trace(\"after\");\r\n" + + "return -1;\r\n", + false); + } + @Test public void testTryCatchTry() { decompileMethod("swftools", "testTryCatchTry", "trace(\"before try\");\r\n" diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf index 4226b39d1..b064ff816 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf index 30fe4d1c4..1cfda5c23 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf index 02e63822e..07ed29e98 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf index db2513655..ea6da3b95 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as index 781d32637..9a1261e04 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchReturn.as @@ -9,7 +9,8 @@ package tests public function run() : int { - var a:int = 5; + var a:int; + a = 5; trace("before try"); try {