#869 Negative float reading fixed

This commit is contained in:
honfika@gmail.com
2015-05-01 12:07:38 +02:00
parent 3b11085365
commit 45251ada53
9 changed files with 235 additions and 209 deletions

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
@@ -46,6 +47,22 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
swf = new SWF(new BufferedInputStream(new FileInputStream("testdata/as2/as2.swf")), false);
}
private String recompilePcode(String pcode) {
try {
List<Action> actions = ASMParser.parse(0, true, pcode, swf.version, false);
DoActionTag doa = getFirstActionTag();
doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version));
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
doa.getASMSource(ScriptExportMode.PCODE, writer, null);
return writer.toString();
} catch (IOException | ActionParseException | InterruptedException ex) {
fail();
}
return null;
}
@Test
public void testModifiedConstantPools() {
String actionsString = "ConstantPool \"ok\"\n"
@@ -74,4 +91,11 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase {
fail();
}
}
@Test
public void testNegativeFloatValue() {
String actionsString = "Push -0.25";
String decompiled = recompilePcode(actionsString);
assertTrue(decompiled.contains("Push -0.25"));
}
}