diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..6065095bf --- /dev/null +++ b/.hgignore @@ -0,0 +1,11 @@ +syntax: glob +trunk/build/* +trunk/coverage/* +trunk/dist/* +trunk/javadoc/* +trunk/locales/* +trunk/releases/* +trunk/reports/* +trunk/build_exe.xml +trunk/installer.cfg +*.orig diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java new file mode 100644 index 000000000..acdc004d1 --- /dev/null +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java @@ -0,0 +1,70 @@ +package com.jpexs.decompiler.flash; + +import com.jpexs.decompiler.flash.abc.avm2.parser.ASM3Parser; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; +import com.jpexs.decompiler.flash.tags.DoActionTag; +import com.jpexs.decompiler.flash.tags.DoInitActionTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.Tag; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.StringReader; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import static org.testng.Assert.*; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * + * @author JPEXS + */ +public class ActionScript2AssemblerTest { + + private SWF swf; + + @BeforeClass + public void init() throws IOException { + Configuration.setConfig("autoDeobfuscate", false); + swf = new SWF(new FileInputStream("testdata/as2/as2.swf"), false); + } + + private DoActionTag getFirstActionTag() { + for (Tag t : swf.tags) { + if (t instanceof DoActionTag) { + return (DoActionTag) t; + } + } + return null; + } + + @Test + public void testModifiedConstantPools() { + String actionsString = "ConstantPool \"ok\"\n" + + "Jump loc001f\n" + + "loc000d:Push \"ok\" false\n" + + "SetVariable\n" + + "Jump loc002f\n" + + "loc001f:ConstantPool \"wrong\"\n" + + "Jump loc000d\n" + + "loc002f:"; + try { + List actions = ASMParser.parse(0, 0, true, new StringReader(actionsString), swf.version); + + DoActionTag doa = getFirstActionTag(); + doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); + String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false); + String decompiled = doa.getASMSource(swf.version, false, false); + + assertEquals(actualResult.trim(), "ok = false;"); + assertTrue(decompiled.contains("Push \"ok\" false")); + } catch (IOException ex) { + fail(); + } catch (ParseException ex) { + fail(); + } + } +} diff --git a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java index dd84fc183..aea24f048 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java @@ -51,7 +51,7 @@ public class AS2Generator { } } - s.append("@Test\r\npublic void "); + s.append("@Test\r\npublic void "); s.append(testName); s.append("(){\r\ncompareSrc("); s.append(frame);