Package com.google.test.metric

Examples of com.google.test.metric.ClassInfo


      return 1;
    }
  }

  public void testHypotheticalModelGivesTheSameNumberWithNoOverrides() throws Exception {
    ClassInfo aClass = repo.getClass(Example.class.getCanonicalName());
    ClassCost cost = computer.compute(aClass);
    int originalCost = costModel.computeClass(cost);
    int newCost = hypotheticalCostModel.computeClass(cost);
    assertEquals(originalCost, newCost);
  }
View Full Code Here


    int newCost = hypotheticalCostModel.computeClass(cost);
    assertEquals(originalCost, newCost);
  }

  public void testMethodCostGoesDownWhenADependentCostIsRemoved() throws Exception {
    ClassInfo aClass = repo.getClass(Example.class.getCanonicalName());
    ClassCost classCost = computer.compute(aClass);
    float costWithWorkInConstructor = (4 + 7) / 2;
    float costWithoutWorkInConstructor = (0 + 3) / 2;
    MethodCost constructorCost = classCost.getMethodCost("Example()");
    MethodInvocationCost instanceCost4Invocation =
View Full Code Here

            CppType.fromName(declaration.getType()), false, false);
      }
      if (leftVar != null && rightVar != null) {
        Node leftParent = leftDeclaration.getParent();
        if (leftParent instanceof ClassDeclaration) {
          ClassInfo classInfo = repository.getClass(leftDeclaration.getName());
          Type fieldType = CppType.fromName(leftDeclaration.getType());
          FieldInfo fieldInfo = new FieldInfo(classInfo, leftDeclaration
              .getName(), fieldType, false, false, false);
          operations.add(new FieldAssignment(assignmentExpression
              .getLineNumber(), leftVar, fieldInfo, rightVar));
View Full Code Here

    @Override
    public void beginVisit(ClassDeclaration classDeclaration) {
      //TODO: when the class repository is actually wired, the name of the source file should
      // be provided in the constructor
      ClassInfo classInfo = new ClassInfo(classDeclaration.getName(), false,
          null, new ArrayList<ClassInfo>(), "[unknown source]");
      classes.put(classDeclaration.getName(), classInfo);
      stack.push(classInfo);
    }
View Full Code Here

      LocalVariableExtractor localVariablesExtractor = new LocalVariableExtractor();
      functionDefinition.accept(localVariablesExtractor);
      OperationBuilder operationBuilder = new OperationBuilder(repository);
      functionDefinition.accept(operationBuilder);

      ClassInfo classInfo = stack.peek();
      classInfo.addMethod(new MethodInfo(
          classInfo,
          functionDefinition.getName(),
          functionDefinition.getLine(),
          null,
          functionDefinition.getParameters(),
View Full Code Here

  }

  private MethodInfo getMethod(String methodName, Class<?> clazz) {
    ClassRepository repo = new JavaClassRepository();
    repo.getClass(Object.class.getCanonicalName()); // pre-cache for easier debugging.
    ClassInfo classInfo = repo.getClass(clazz.getCanonicalName());
    return classInfo.getMethod(methodName);
  }
View Full Code Here

  }

  @Override
  public void visit(int version, int access, String name, String signature,
      String superName, String[] interfaces) {
    ClassInfo superClass = null;
    superClass = superName == null ? null : repository.getClass(namer.nameClass(superName));

    List<ClassInfo> interfaceList = new ArrayList<ClassInfo>();
    for (String interfaze : interfaces) {
      interfaceList.add(repository.getClass(namer.nameClass(interfaze)));
    }
    boolean isInterface = (access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE;
    classInfo = new ClassInfo(namer.nameClass(name), isInterface, superClass,
        interfaceList, guessSourceFileName(name));
    repository.addClass(classInfo);
  }
View Full Code Here

    return metricComputer.compute(method);
  }

  /** used for testing */
  public MethodCost compute(String clazz, String methodName) {
    ClassInfo classInfo = classRepository.getClass(clazz);
    MethodInfo method = classInfo.getMethod(methodName);
    return metricComputer.compute(method);
  }
View Full Code Here

    boolean isInterface = false;
    List<ClassInfo> interfaceClasses = new ArrayList<ClassInfo>();
    for (Type interfaceType : interfaceTypes) {
      interfaceClasses.add(toClassInfo(interfaceType));
    }
    ClassInfo info = new ClassInfo(className,
        isInterface, toClassInfo(superType), interfaceClasses, src);
    repository.addClass(info);
    pushType(new TypeBuilder(info));
  }
View Full Code Here

      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);
      }
View Full Code Here

TOP

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

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.