mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-02 18:24:31 +00:00
tests fixed
This commit is contained in:
@@ -71,9 +71,9 @@ public class ActionScript3Test {
|
||||
assertTrue(bodyIndex > -1);
|
||||
HilightedTextWriter writer = null;
|
||||
try {
|
||||
abc.bodies[bodyIndex].convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new NulWriter(), new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits, true);
|
||||
abc.bodies.get(bodyIndex).convert(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new NulWriter(), new ArrayList<String>(), abc.instance_info.get(clsIndex).instance_traits, true);
|
||||
writer = new HilightedTextWriter(new CodeFormatting(), false);
|
||||
abc.bodies[bodyIndex].toString(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, new ArrayList<String>(), abc.instance_info[clsIndex].instance_traits);
|
||||
abc.bodies.get(bodyIndex).toString(methodName, ScriptExportMode.AS, isStatic, -1/*FIX?*/, clsIndex, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, new ArrayList<String>(), abc.instance_info.get(clsIndex).instance_traits);
|
||||
} catch (InterruptedException ex) {
|
||||
fail();
|
||||
}
|
||||
@@ -132,8 +132,8 @@ public class ActionScript3Test {
|
||||
+ "{\r\n"
|
||||
+ "trace(\"a=\" + a);\r\n"
|
||||
+ "a++;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "while(a < 20);\r\n", false);
|
||||
+ "}while(a < 20);\r\n"
|
||||
+ "\r\n", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -663,7 +663,11 @@ public class ActionScript3Test {
|
||||
@Test
|
||||
public void testNames() {
|
||||
decompileMethod("testNames", "var ns:* = this.getNamespace();\r\n"
|
||||
+ "var name:* = this.getName();\r\n", false);
|
||||
+ "var name:* = this.getName();\r\n"
|
||||
+ "var a:* = ns::unnamespacedFunc();\r\n"
|
||||
+ "var b:* = ns::[name];\r\n"
|
||||
+ "trace(b.c);\r\n"
|
||||
+ "var c:* = myInternal::neco;\r\n", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -775,8 +779,8 @@ public class ActionScript3Test {
|
||||
+ "k = 5 - k;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "k--;\r\n"
|
||||
+ "}\r\n"
|
||||
+ "while(k < 9);\r\n"
|
||||
+ "}while(k < 9);\r\n"
|
||||
+ "\r\n"
|
||||
+ "return 2;\r\n", false);
|
||||
}
|
||||
|
||||
@@ -886,18 +890,18 @@ public class ActionScript3Test {
|
||||
+ "return 4;\r\n", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionalParameters() {
|
||||
@Test
|
||||
public void testOptionalParameters() {
|
||||
String methodName = "testOptionalParameters";
|
||||
int methodInfo = abc.findMethodInfoByName(clsIndex, methodName);
|
||||
int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName);
|
||||
assertTrue(methodInfo > -1);
|
||||
assertTrue(bodyIndex > -1);
|
||||
HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false);
|
||||
abc.method_info[methodInfo].getParamStr(writer, abc.constants, abc.bodies[bodyIndex], abc, new ArrayList<String>());
|
||||
String actualResult = writer.toString().replaceAll("[ \r\n]", "");
|
||||
String expectedResult = "p1:Event=null,p2:Number=1,p3:Number=-1,p4:Number=-1.1,p5:Number=-1.1,p6:String=\"a\"";
|
||||
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
|
||||
assertEquals(actualResult, expectedResult);
|
||||
int methodInfo = abc.findMethodInfoByName(clsIndex, methodName);
|
||||
int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName);
|
||||
assertTrue(methodInfo > -1);
|
||||
assertTrue(bodyIndex > -1);
|
||||
HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false);
|
||||
abc.method_info.get(methodInfo).getParamStr(writer, abc.constants, abc.bodies.get(bodyIndex), abc, new ArrayList<String>());
|
||||
String actualResult = writer.toString().replaceAll("[ \r\n]", "");
|
||||
String expectedResult = "p1:Event=null,p2:Number=1,p3:Number=-1,p4:Number=-1.1,p5:Number=-1.1,p6:String=\"a\"";
|
||||
expectedResult = expectedResult.replaceAll("[ \r\n]", "");
|
||||
assertEquals(actualResult, expectedResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ package com.jpexs.decompiler.flash.generators;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.CodeFormatting;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.NulWriter;
|
||||
import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
@@ -54,7 +56,7 @@ public class AS3Generator {
|
||||
ABC abc = tag.getABC();
|
||||
int classId = abc.findClassByName("classes.Test");
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Trait t : abc.instance_info[classId].instance_traits.traits) {
|
||||
for (Trait t : abc.instance_info.get(classId).instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
String name = t.getName(abc).getName(abc.constants, new ArrayList<String>());
|
||||
if (name.startsWith("test")) {
|
||||
@@ -64,7 +66,9 @@ public class AS3Generator {
|
||||
s.append(name);
|
||||
s.append("\", ");
|
||||
HilightedTextWriter src = new HilightedTextWriter(new CodeFormatting(), false);
|
||||
abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, src, new ArrayList<String>(), abc.instance_info[classId].instance_traits);
|
||||
MethodBody b = abc.findBody(((TraitMethodGetterSetter) t).method_info);
|
||||
b.convert("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, new NulWriter(), new ArrayList<String>(), abc.instance_info.get(classId).instance_traits, true);
|
||||
b.toString("", ScriptExportMode.AS, false, -1/*FIX?*/, classId, abc, null, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, src, new ArrayList<String>(), abc.instance_info.get(classId).instance_traits);
|
||||
String[] srcs = src.toString().split("[\r\n]+");
|
||||
for (int i = 0; i < srcs.length; i++) {
|
||||
String ss = srcs[i];
|
||||
|
||||
Reference in New Issue
Block a user