Unit test

This commit is contained in:
Stiver 2014-10-15 08:35:45 +02:00
parent c975f11ecc
commit 6d03229b91
4 changed files with 67 additions and 3 deletions

View File

@ -1,6 +1,9 @@
package org.jetbrains.java.decompiler.main.collectors;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import org.jetbrains.java.decompiler.main.DecompilerContext;
@ -55,9 +58,14 @@ public class BytecodeSourceMapper {
}
buffer.appendIndent(1).append("method " + method_entry.getKey() + "{" + lineSeparator);
for(Entry<Integer, Integer> line : method_mapping.entrySet()) {
String strOffset = offsetsToHex ? Integer.toHexString(line.getKey()): line.getKey().toString();
buffer.appendIndent(2).append(strOffset).appendIndent(2).append((line.getValue() + offset_total) + lineSeparator);
List<Integer> lstBytecodeOffsets = new ArrayList<Integer>(method_mapping.keySet());
Collections.sort(lstBytecodeOffsets);
for(Integer offset : lstBytecodeOffsets) {
Integer line = method_mapping.get(offset);
String strOffset = offsetsToHex ? Integer.toHexString(offset): line.toString();
buffer.appendIndent(2).append(strOffset).appendIndent(2).append((line + offset_total) + lineSeparator);
}
buffer.appendIndent(1).append("}").appendLineSeparator();
is_first_method = false;

View File

@ -0,0 +1,36 @@
package pkg;
public class TestClassSimpleBytecodeMapping {
public int test() {
System.out.println("before");
if(Math.random() > 0.0D) {
System.out.println("0");
return 0;
} else {
System.out.println("1");
return 1;
}
}
}
class test/TestClassSimpleBytecodeMapping{
method test ()I{
0 4
3 4
5 4
8 5
b 5
c 5
d 5
10 6
13 6
15 6
18 7
19 7
1a 9
1d 9
1f 9
22 10
23 10
}
}

View File

@ -0,0 +1,20 @@
package pkg;
public class TestClassSimpleBytecodeMapping {
public TestClassSimpleBytecodeMapping() {}
public int test() {
System.out.println("before");
if(Math.random() > 0) {
System.out.println("0");
return 0;
} else {
System.out.println("1");
return 1;
}
}
}