vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Bck2BrwsrCase.java
changeset 383 88ed1f51eb22
parent 382 57fc3a0563c9
child 384 269d99fd6421
     1.1 --- a/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Bck2BrwsrCase.java	Tue Dec 25 15:08:39 2012 +0100
     1.2 +++ b/vmtest/src/main/java/org/apidesign/bck2brwsr/vmtest/impl/Bck2BrwsrCase.java	Tue Dec 25 15:31:58 2012 +0100
     1.3 @@ -31,15 +31,15 @@
     1.4   */
     1.5  public final class Bck2BrwsrCase implements ITest {
     1.6      private final Method m;
     1.7 -    private final Launchers l;
     1.8 -    private final int type;
     1.9 +    private final LaunchSetup l;
    1.10 +    private final String type;
    1.11      Object value;
    1.12      private Invocable code;
    1.13      private CharSequence codeSeq;
    1.14      private static final Map<Class, Object[]> compiled = new WeakHashMap<>();
    1.15      private Object inst;
    1.16  
    1.17 -    Bck2BrwsrCase(Method m, int type, Launchers l) {
    1.18 +    Bck2BrwsrCase(Method m, String type, LaunchSetup l) {
    1.19          this.l = l;
    1.20          this.m = m;
    1.21          this.type = type;
    1.22 @@ -47,11 +47,8 @@
    1.23  
    1.24      @Test(groups = "run")
    1.25      public void executeCode() throws Throwable {
    1.26 -        if (type == 1) {
    1.27 -            MethodInvocation c = l.invokeMethod(m.getDeclaringClass(), m.getName(), false);
    1.28 -            value = c.toString();
    1.29 -        } else if (type == 2) {
    1.30 -            MethodInvocation c = l.invokeMethod(m.getDeclaringClass(), m.getName(), true);
    1.31 +        if (l != null) {
    1.32 +            MethodInvocation c = l.invokeMethod(m.getDeclaringClass(), m.getName());
    1.33              value = c.toString();
    1.34          } else {
    1.35              value = m.invoke(m.getDeclaringClass().newInstance());
    1.36 @@ -64,67 +61,6 @@
    1.37      }
    1.38  
    1.39      final String typeName() {
    1.40 -        switch (type) {
    1.41 -            case 0:
    1.42 -                return "Java";
    1.43 -            case 1:
    1.44 -                return "JavaScript";
    1.45 -            case 2:
    1.46 -                return "Browser";
    1.47 -            default:
    1.48 -                return "Unknown type " + type;
    1.49 -        }
    1.50 +        return type;
    1.51      }
    1.52 -
    1.53 -    private static String computeSignature(Method m) {
    1.54 -        StringBuilder sb = new StringBuilder();
    1.55 -        appendType(sb, m.getReturnType());
    1.56 -        for (Class<?> c : m.getParameterTypes()) {
    1.57 -            appendType(sb, c);
    1.58 -        }
    1.59 -        return sb.toString();
    1.60 -    }
    1.61 -
    1.62 -    private static void appendType(StringBuilder sb, Class<?> t) {
    1.63 -        if (t == null) {
    1.64 -            sb.append('V');
    1.65 -            return;
    1.66 -        }
    1.67 -        if (t.isPrimitive()) {
    1.68 -            int ch = -1;
    1.69 -            if (t == int.class) {
    1.70 -                ch = 'I';
    1.71 -            }
    1.72 -            if (t == short.class) {
    1.73 -                ch = 'S';
    1.74 -            }
    1.75 -            if (t == byte.class) {
    1.76 -                ch = 'B';
    1.77 -            }
    1.78 -            if (t == boolean.class) {
    1.79 -                ch = 'Z';
    1.80 -            }
    1.81 -            if (t == long.class) {
    1.82 -                ch = 'J';
    1.83 -            }
    1.84 -            if (t == float.class) {
    1.85 -                ch = 'F';
    1.86 -            }
    1.87 -            if (t == double.class) {
    1.88 -                ch = 'D';
    1.89 -            }
    1.90 -            assert ch != -1 : "Unknown primitive type " + t;
    1.91 -            sb.append((char) ch);
    1.92 -            return;
    1.93 -        }
    1.94 -        if (t.isArray()) {
    1.95 -            sb.append("_3");
    1.96 -            appendType(sb, t.getComponentType());
    1.97 -            return;
    1.98 -        }
    1.99 -        sb.append('L');
   1.100 -        sb.append(t.getName().replace('.', '_'));
   1.101 -        sb.append("_2");
   1.102 -    }
   1.103 -    
   1.104  }