Package com.google.test.metric

Examples of com.google.test.metric.MethodInfo


    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    assertFalse(classInfo.isInterface());
    assertEquals(1, classInfo.getMethods().size());
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    assertEquals("foo", methodInfo.getName());
    assertEquals(Visibility.PRIVATE, methodInfo.getVisibility());
  }
View Full Code Here


    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    assertFalse(classInfo.isInterface());
    assertEquals(1, classInfo.getMethods().size());
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    assertEquals("foo", methodInfo.getName());
    assertEquals(2, methodInfo.getParameters().size());
    assertEquals(Visibility.PUBLIC, methodInfo.getVisibility());
  }
View Full Code Here

    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    assertFalse(classInfo.isInterface());
    assertEquals(1, classInfo.getMethods().size());
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    assertEquals("foo", methodInfo.getName());
    List<LocalVariableInfo> localVariables = methodInfo.getLocalVariables();
    assertEquals(2, localVariables.size());
    LocalVariableInfo variableA = localVariables.get(0);
    assertEquals("a", variableA.getName());
    LocalVariableInfo variableB = localVariables.get(1);
    assertEquals("b", variableB.getName());
    assertEquals(Visibility.PROTECTED, methodInfo.getVisibility());
  }
View Full Code Here

    CppClassRepository repository = new CppClassRepository();
    repository.parse("class A{ protected: void foo() { return; } };");
    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    List<Operation> operations = methodInfo.getOperations();
    assertEquals(1, operations.size());
    Operation operation = operations.get(0);
    assertTrue(operation instanceof ReturnOperation);
    ReturnOperation returnOperation = (ReturnOperation) operation;
    assertEquals(1, returnOperation.getLineNumber());
View Full Code Here

    CppClassRepository repository = new CppClassRepository();
    repository.parse("class A{ protected: void foo() { int a = 0; int b = 1; b = a; } };");
    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    List<Operation> operations = methodInfo.getOperations();
    assertEquals(1, operations.size());
    Operation operation = operations.get(0);
    assertTrue(operation instanceof LocalAssignment);
    LocalAssignment localAssignment = (LocalAssignment) operation;
    assertEquals(1, localAssignment.getLineNumber());
View Full Code Here

    CppClassRepository repository = new CppClassRepository();
    repository.parse("class A{ void foo() { int b = 1; a = b; } int a; };");
    ClassInfo classInfo = repository.getClass("A");
    assertNotNull(classInfo);
    Iterator<MethodInfo> it = classInfo.getMethods().iterator();
    MethodInfo methodInfo = it.next();
    List<Operation> operations = methodInfo.getOperations();
    assertEquals(1, operations.size());
    Operation operation = operations.get(0);
    assertTrue(operation instanceof FieldAssignment);
    FieldAssignment fieldAssignment = (FieldAssignment) operation;
    assertEquals(1, fieldAssignment.getLineNumber());
View Full Code Here

  public void computeMetric(TestabilityContext context, MethodInfo currentMethod) {
    if (context.isClassWhiteListed(clazzName)) {
      return;
    }
    try {
      MethodInfo toMethod = context.getMethod(clazzName, name + signature);
      if (context.methodAlreadyVisited(toMethod)) {
        // Method already counted, skip (to prevent recursion)
      } else if (toMethod.canOverride() && context.isInjectable(methodThis)) {
        // Method can be overridden / injectable
      } else {
        // Method can not be intercepted we have to add the cost
        // recursively
        if (toMethod.isInstance()) {
          context.localAssignment(toMethod, getLineNumber(), toMethod
              .getMethodThis(), methodThis);
        }
        int i = 0;
        if (parameters.size() != toMethod.getParameters().size()) {
          throw new IllegalStateException(
              "Argument count does not match method parameter count.");
        }
        for (Variable var : parameters) {
          context.localAssignment(toMethod, getLineNumber(), toMethod
              .getParameters().get(i++), var);
        }
        context.recordMethodCall(currentMethod, getLineNumber(), toMethod);
        context.localAssignment(toMethod, getLineNumber(), returnValue,
            context.getReturnValue());
View Full Code Here

    for (Runnable runnable : recorder) {
      runnable.run();
    }
    block.done();
    try {
      MethodInfo methodInfo = new MethodInfo(classInfo, name, startingLineNumber,
          desc, methodThis, parameters, localVariables, visibility,
          cyclomaticComplexity, block.getOperations());
      classInfo.addMethod(methodInfo);
    } catch (IllegalStateException e) {
      throw new IllegalStateException("Error in " + classInfo + "." + name
View Full Code Here

    MethodCost cost = cost(GlobalExample.class, "globalIncrement()I");
    assertEquals(1, cost.getTotalGlobalCost());
  }

  public void testGadgetGetCountHasOneReturnOperation() throws Exception {
    MethodInfo getCount = repo.getClass(Gadget.class).getMethod("getCount()I");
    assertEquals(1, getCount.getOperations().size());
  }
View Full Code Here

      assertEquals(error, expecting, actual);
    }
  }

  public void testConstructor() throws Exception {
    MethodInfo method = getMethod("<init>()V", Simple.class);
    List<Operation> operations = method.getOperations();
    assertOperations(
        operations,
        "java.lang.Object.<init>()V",
        "java.lang.Object.<init>()V",
        "com.google.test.metric.method.MethodBlockTest$Simple.a{java.lang.Object} <- new{java.lang.Object}");
View Full Code Here

TOP

Related Classes of com.google.test.metric.MethodInfo

Copyright © 2018 www.massapicom. 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.