diff --git a/trunk/test/com/jpexs/decompiler/flash/ABCStreamTest.java b/trunk/test/com/jpexs/decompiler/flash/ABCStreamTest.java index 058daff99..905edf170 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ABCStreamTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/ABCStreamTest.java @@ -13,6 +13,7 @@ import org.testng.annotations.Test; * @author JPEXS */ public class ABCStreamTest { + @Test public void testU30() { try { diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java index 362bf78b6..b02414911 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -41,7 +41,7 @@ public class ActionScript3Test { private void decompileMethod(String methodName, String expectedResult, boolean isStatic) { int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName); assertTrue(bodyIndex > -1); - String actualResult = abc.bodies[bodyIndex].toString(methodName, false, isStatic, clsIndex, abc, abc.constants, abc.method_info, new Stack(), false, false, new ArrayList(), abc.instance_info[clsIndex].instance_traits); + String actualResult = abc.bodies[bodyIndex].toString(methodName, false, isStatic, -1/*FIX?*/,clsIndex, abc, abc.constants, abc.method_info, new Stack(), false, false, new ArrayList(), abc.instance_info[clsIndex].instance_traits); actualResult = actualResult.replaceAll("[ \r\n]", ""); expectedResult = expectedResult.replaceAll("[ \r\n]", ""); assertEquals(actualResult, expectedResult); diff --git a/trunk/test/com/jpexs/decompiler/flash/Generator.java b/trunk/test/com/jpexs/decompiler/flash/Generator.java index 310b219ff..bb50636bb 100644 --- a/trunk/test/com/jpexs/decompiler/flash/Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/Generator.java @@ -14,51 +14,52 @@ import java.util.Stack; /** * * Generates stub for ActionScript3Test - * + * * @author JPEXS */ public class Generator { - public static void main(String[] args) throws Exception { - SWF swf=new SWF(new FileInputStream("testdata/as3/TestMovie.swf")); - DoABCDefineTag tag = null; - for (Tag t : swf.tags) { - if (t instanceof DoABCDefineTag) { - tag = (DoABCDefineTag) t; - break; - } - } - ABC abc=tag.getABC(); - int classId=abc.findClassByName("classes.Test"); - StringBuilder s=new StringBuilder(); - for(Trait t:abc.instance_info[classId].instance_traits.traits){ - if(t instanceof TraitMethodGetterSetter){ - String name=t.getName(abc).getName(abc.constants, new ArrayList()); - if(name.startsWith("test")){ - s.append("@Test\r\npublic void "); - s.append(name); - s.append("(){\r\ndecompileMethod(\""); - s.append(name); - s.append("\", "); - String src=abc.findBody(((TraitMethodGetterSetter)t).method_info).toString("", false, false, classId, abc, abc.constants, abc.method_info, new Stack(), false, false, new ArrayList(), abc.instance_info[classId].instance_traits); - String srcs[]=src.split("[\r\n]+"); - for(int i=0;i()); + if (name.startsWith("test")) { + s.append("@Test\r\npublic void "); + s.append(name); + s.append("(){\r\ndecompileMethod(\""); + s.append(name); + s.append("\", "); + String src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", false, false,-1/*FIX?*/, classId, abc, abc.constants, abc.method_info, new Stack(), false, false, new ArrayList(), abc.instance_info[classId].instance_traits); + String srcs[] = src.split("[\r\n]+"); + for (int i = 0; i < srcs.length; i++) { + String ss = srcs[i]; + s.append("\""); + s.append(ss.trim().replace("\\", "\\\\").replace("\"", "\\\"")); + s.append("\\r\\n\""); + if (i < srcs.length - 1) { + s.append("+"); + } + s.append("\r\n"); + } + s.append(", false);"); + s.append("}"); + } + } + + PrintWriter pw = new PrintWriter("src.as"); + pw.println(s.toString()); + pw.close(); + } + } } diff --git a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java index c327560fc..8b1cb6b73 100644 --- a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java @@ -9,8 +9,8 @@ import org.testng.annotations.Test; * * @author JPEXS */ +public class RecompileTest { -public class RecompileTest { public static final String TESTDATADIR = "testdata"; private void testRecompileOne(String filename) { @@ -27,16 +27,15 @@ public class RecompileTest { @Test public void testRecompile() { - File dir=new File(TESTDATADIR); - File files[]=dir.listFiles(new FilenameFilter(){ + File dir = new File(TESTDATADIR); + File files[] = dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".swf"); } }); - for(File f:files){ + for (File f : files) { testRecompileOne(f.getAbsolutePath()); } } - } diff --git a/trunk/test/com/jpexs/decompiler/flash/SWFStreamTest.java b/trunk/test/com/jpexs/decompiler/flash/SWFStreamTest.java index d9b03a3f4..c1d12a946 100644 --- a/trunk/test/com/jpexs/decompiler/flash/SWFStreamTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/SWFStreamTest.java @@ -14,15 +14,15 @@ public class SWFStreamTest { @Test public void testNeededBits() { - assertEquals(SWFOutputStream.getNeededBitsU(3),2); - assertEquals(SWFOutputStream.getNeededBitsU(255),8); - assertEquals(SWFOutputStream.getNeededBitsS(3),3); - assertEquals(SWFOutputStream.getNeededBitsS(255),9); - assertEquals(SWFOutputStream.getNeededBitsS(-2),3); - assertEquals(SWFOutputStream.getNeededBitsS(-597),11); - assertEquals(SWFOutputStream.getNeededBitsF(15.5f),21); - assertEquals(SWFOutputStream.getNeededBitsF(0.1f),17); - assertEquals(SWFOutputStream.getNeededBitsF(-2.8891602f),19); + assertEquals(SWFOutputStream.getNeededBitsU(3), 2); + assertEquals(SWFOutputStream.getNeededBitsU(255), 8); + assertEquals(SWFOutputStream.getNeededBitsS(3), 3); + assertEquals(SWFOutputStream.getNeededBitsS(255), 9); + assertEquals(SWFOutputStream.getNeededBitsS(-2), 3); + assertEquals(SWFOutputStream.getNeededBitsS(-597), 11); + assertEquals(SWFOutputStream.getNeededBitsF(15.5f), 21); + assertEquals(SWFOutputStream.getNeededBitsF(0.1f), 17); + assertEquals(SWFOutputStream.getNeededBitsF(-2.8891602f), 19); } @Test @@ -78,7 +78,6 @@ public class SWFStreamTest { sis.close(); } - @Test public void testFLOATAndDouble() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream();