vm/src/test/java/org/apidesign/vm4brwsr/Instance.java
branchemul
changeset 639 960ecf7cea5d
parent 442 b107ed66f2e7
     1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/Instance.java	Mon Jan 14 10:57:51 2013 +0100
     1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/Instance.java	Fri Feb 01 15:19:16 2013 +0100
     1.3 @@ -68,12 +68,12 @@
     1.4          GetByte i = new InstanceSub(7, 2.2d);
     1.5          return i.getByte();
     1.6      }
     1.7 -    public static boolean instanceOf(boolean sub) {
     1.8 +    public static boolean instanceOf(int sub) {
     1.9          Instance i = createInstance(sub);
    1.10          return isInstanceSubOf(i);
    1.11      }
    1.12      public static int castsWork(boolean interfc) {
    1.13 -        Instance i = createInstance(true);
    1.14 +        Instance i = createInstance(2);
    1.15          if (interfc) {
    1.16              GetByte b = (GetByte)i;
    1.17          } else {
    1.18 @@ -85,11 +85,16 @@
    1.19      private static boolean isInstanceSubOf(Instance instance) {
    1.20          return instance instanceof InstanceSub;
    1.21      }
    1.22 -    private static Instance createInstance(boolean sub) {
    1.23 -        return sub ? new InstanceSub(3, 0) : new Instance();
    1.24 +    private static Instance createInstance(int type) {
    1.25 +        switch (type) {
    1.26 +            case 0: return null;
    1.27 +            case 1: return new Instance();
    1.28 +            case 2: return new InstanceSub(3, 0);
    1.29 +        }
    1.30 +        throw new IllegalArgumentException();
    1.31      }
    1.32      private static boolean isNull() {
    1.33 -        return createInstance(true) == null;
    1.34 +        return createInstance(2) == null;
    1.35      }
    1.36      
    1.37      @JavaScriptBody(args = "obj", body = "return obj.constructor;")