Examples of FieldInfo


Examples of com.google.test.metric.FieldInfo

      String desc, String signature, Object value) {
    boolean isStatic = (access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC;
    boolean isPrivate = JavaVisibility.valueFromJavaBytecode(access) == Visibility.PRIVATE;
    boolean isFinal = (access & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL;
    Type type = JavaType.fromDesc(desc);
    classInfo.addField(new FieldInfo(classInfo, name, type, isFinal,
        isStatic, isPrivate));
  }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  }

  public void testVariableFormatting() throws Exception {
    Type type = JavaType.fromJava("com.google.test.metric.example.MutableGlobalState." +
        "FinalGlobalExample$Gadget");
    FieldInfo field = new FieldInfo(null, "finalInstance", type, false, false, false);
    LocalField localField = new LocalField(new Variable(
        "com.google.test.metric.example.MutableGlobalState.FinalGlobalExample$" +
            "FinalGlobal.finalInstance",
        type, false, false), field);
    assertEquals("FinalGlobalExample$Gadget finalInstance", localField.getDescription());
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  }

  public void addField(String name, Type type, Visibility visibility,
      boolean isGlobal, boolean isFinal) {
    boolean isPrivate = Visibility.PRIVATE == visibility;
    FieldInfo fieldInfo = new FieldInfo(info, name, type, isFinal, isGlobal,
        isPrivate);
    info.addField(fieldInfo);
  }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  }

  public void testVariableStaticAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  public void testVariableAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("this"))); // this
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, false, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }

  public void testGetField() throws Exception {
    Block block = new Block("1");
    block.addOp(new GetField(-1, new FieldInfo(null, "src", OBJECT,
        false, true, false)));
    block.addOp(new PutField(-1, new FieldInfo(null, "dst", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.dst{java.lang.Object} <- null.src{java.lang.Object}]", operations
        .toString());
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  }

  public void testMethodInvocation() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("methodThis"))); // this
    block.addOp(new GetField(-1, new FieldInfo(null, "p1", OBJECT,
        false, true, false)));
    block.addOp(new GetField(-1, new FieldInfo(null, "p2", OBJECT,
        false, true, false)));
    block.addOp(new Invoke(-1, null, "int methodA(int, int)", asList(JavaType.INT,
        JavaType.INT), false, OBJECT));
    block.addOp(new PutField(-1, new FieldInfo(null, "dst", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null:int methodA(int, int), null.dst{java.lang.Object} <- ?{java.lang.Object}]",
        operations.toString());
View Full Code Here

Examples of com.google.test.metric.FieldInfo

      this.fieldDesc = desc;
      this.isStatic = isStatic;
    }

    public void run() {
      FieldInfo field = null;
      ClassInfo ownerClass = repository.getClass(fieldOwner);
      try {
        field = ownerClass.getField(fieldName);
      } catch (FieldNotFoundException e) {
        field =
            new FieldInfo(ownerClass, "FAKE:" + fieldName, JavaType
                .fromDesc(fieldDesc), false, isStatic, false);
      }
      block.addOp(new com.google.test.metric.method.op.stack.PutField(
          lineNumber, field));
    }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

      this.fieldDesc = desc;
      this.isStatic = isStatic;
    }

    public void run() {
      FieldInfo field = null;
      ClassInfo ownerClass = repository.getClass(fieldOwner);
      try {
        field = ownerClass.getField(fieldName);
      } catch (FieldNotFoundException e) {
        field = new FieldInfo(ownerClass, "FAKE:" + fieldName, JavaType
                .fromDesc(fieldDesc), false, isStatic, false);
      }
      block.addOp(new GetField(lineNumber, field));
    }
View Full Code Here

Examples of com.google.test.metric.FieldInfo

  }

  public void testFieldDeclareation() throws Exception {
    ClassInfo info = repo.getClass(FieldDeclaration.class.getCanonicalName());
    Iterator<FieldInfo> iterator = info.getFields().iterator();
    FieldInfo field1 = iterator.next();
    FieldInfo field2 = iterator.next();
    assertFalse(iterator.hasNext());

    assertEquals("field1", field1.getName());
    assertEquals(String.class.getCanonicalName(), field1.getType().toString());
    assertEquals(false, field1.isPrivate());
    assertEquals(true, field1.isFinal());
    assertEquals(true, field1.isGlobal());

    assertEquals("field2", field2.getName());
    assertEquals(JavaType.INT, field2.getType());
    assertEquals(false, field2.isPrivate());
    assertEquals(false, field2.isFinal());
    assertEquals(false, field2.isGlobal());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.