1 package org.hansel; 2 3 import java.util.Enumeration ; 4 5 import junit.framework.TestFailure; 6 import junit.framework.TestResult; 7 8 import org.objectweb.asm.Label; 9 import org.objectweb.asm.tree.InsnList; 10 import org.objectweb.asm.tree.LabelNode; 11 12 17 public class Util { 18 19 23 public Util() { 24 throw new UnsupportedOperationException ("Class is static."); 25 } 26 27 public static String [] concat(String [] a, String [] b) { 28 String [] result = new String [a.length + b.length]; 29 30 System.arraycopy(a, 0, result, 0, a.length); 31 System.arraycopy(b, 0, result, a.length, b.length); 32 33 return result; 34 } 35 36 public static String leftFill(int length, String text) { 37 while (text.length() < length) { 38 text = " " + text; 39 } 40 41 return text; 42 } 43 44 48 public static void dumpResult(TestResult result) { 49 Enumeration e = result.failures(); 50 while (e.hasMoreElements()) { 51 TestFailure failure = (TestFailure) e.nextElement(); 52 failure.thrownException().printStackTrace(); 53 } 54 55 e = result.errors(); 56 while (e.hasMoreElements()) { 57 TestFailure failure = (TestFailure) e.nextElement(); 58 failure.thrownException().printStackTrace(); 59 } 60 } 61 62 public static int findIndex(InsnList instructions, Label label) { 63 for (int i=0; i<instructions.size(); i++) { 64 Object obj = instructions.get(i); 65 if (obj instanceof LabelNode) { 66 if (((LabelNode) obj).getLabel() == label) { 67 return i; 68 } 69 } 70 } 71 72 return -1; 73 } 74 } 75 | Popular Tags |