|
JML | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jmlspecs.jmlunit.TestClassGenerator org.jmlspecs.jmlunit.TestDataClassGenerator
A class for generating JML/JUnit test data classes. A test data class
must be used to specify test data for a JML/JUnit test oracle class
generated by the class TestClassGenerator
.
Class Specifications |
Specifications inherited from class TestClassGenerator |
invariant this.typeDecl != null ==> this.testClassName.equals(this.typeDecl.ident()+"_JML_Test"); invariant this.fixtureTypes != null&&( \forall java.lang.Object o; this.fixtureTypes.contains(o); o != null&&o instanceof org.multijava.mjc.CType); private invariant this.requestedVisibility == 1||this.requestedVisibility == 4||this.requestedVisibility == org.jmlspecs.jmlunit.TestClassGenerator.ACC_ALL; |
Specifications inherited from class Object |
represents objectState <- org.jmlspecs.lang.JMLDataGroup.IT; public represents _getClass <- \typeof(this); |
Specifications inherited from interface Constants |
invariant "junit.framework.".length() > 0 ==> "junit.framework.".charAt("junit.framework.".length()) == 46; invariant "org.jmlspecs.jmlrac.runtime.".length() > 0 ==> "org.jmlspecs.jmlrac.runtime.".charAt("org.jmlspecs.jmlrac.runtime.".length()) == 46; invariant "org.jmlspecs.jmlunit.".length() > 0 ==> "org.jmlspecs.jmlunit.".charAt("org.jmlspecs.jmlunit.".length()) == 46; invariant "org.jmlspecs.jmlunit.strategies.".length() > 0 ==> "org.jmlspecs.jmlunit.strategies.".charAt("org.jmlspecs.jmlunit.".length()) == 46; |
Specifications inherited from interface Constants |
public invariant true; |
Nested Class Summary |
Nested classes inherited from class org.jmlspecs.jmlunit.TestClassGenerator |
TestClassGenerator.MethodInfo, TestClassGenerator.MethodsIterator |
Model Field Summary |
Model fields inherited from class java.lang.Object |
_getClass, objectState, theString |
Ghost Field Summary |
Ghost fields inherited from class java.lang.Object |
objectTimesFinalized, owner |
Field Summary |
Fields inherited from class org.jmlspecs.jmlunit.TestClassGenerator |
fixtureTypes, generatorClassName, generatorPackageName, includeInherited, packageString, testClassName, testedPackageString, typeDecl, useGenerator |
Fields inherited from interface org.jmlspecs.jmlunit.Constants |
DOT_JAVA, PKG_JMLRAC, PKG_JMLUNIT, PKG_JUNIT, PKG_STRATEGIES, TEST_CLASS_FILE_NAME_POSTFIX, TEST_CLASS_NAME_POSTFIX, TEST_DATA_FILE_NAME_POSTFIX, TEST_DATA_NAME_POSTFIX, TEST_METHOD_NAME_PREFIX |
Constructor Summary | |
TestDataClassGenerator(JntOptions options)
Constructs a new test data class generator object. |
Model Method Summary |
Model methods inherited from class java.lang.Object |
hashValue |
Method Summary | |
static String |
defaultValue(non_null CType type)
Returns the default value of the type type . |
private CExpressionContextType |
expr_context(CClass selfClass)
Compute a context for use in testing whether a method exists in the given class. |
protected void |
generateTestClass(non_null JCompilationUnit cunit,
non_null JTypeDeclarationType cdecl)
Generates a test data class for the given class, cdecl . |
boolean |
hasCloneMethod(CClass selfClass)
Does the given CClass have a clone method? |
protected void |
initializeFixture()
Initialize the fixture to contain all of the types used as paramaeters in all the methods. |
private boolean |
isImmutableType(non_null CType type,
non_null String typeName)
Is the given type an immutable type? |
private void |
print_get_X_MethodDecl(String varName,
String typeName,
String defaultValue,
boolean isImmutableType,
boolean hasCloneMethod)
Prints the declaration of the get_X method. |
private void |
print_size_X_MethodDecl(String varName,
String typeName,
boolean isImmutableType,
boolean hasCloneMethod)
Prints the declaration of the size_X method. |
protected void |
printBigComment()
Print the big comment in the body explaining how to edit the code to provide test data. |
protected void |
printClassHeader()
Prints the class header of test case class. |
protected void |
printClassJavadoc()
Prints a javadoc comment for the current class. |
private void |
printDataProvisionCode(CType type)
Prints the declaration of the vTiter method as well as the sample strategy for the given type. |
protected void |
printDataProvisionMethods()
Prints declarations of the vTiter methods, as well as sample strategy declarations for. |
private void |
printEmptyTestSuiteForMethod()
Print the declaration of the emptyTestSuiteFor method. |
protected void |
printImportStatements(JCompilationUnit cunit)
Prints import statements. |
private void |
printIteratorProvisionMethod(String varName,
String typeName,
boolean isPrimitive,
boolean isImmutableType,
boolean hasCloneMethod)
Print the declaration of the vTiter method for the given type. |
private void |
printOverallTestSuiteMethod()
Print the declaration of the overallTestSuite method. |
private void |
printProvideIteratorComment(String typeName)
|
private void |
printStrategyGuess(CType type,
String varName,
String typeName,
boolean isPrimitive,
boolean isImmutable,
boolean hasCloneMethod)
Print the declaration of the default strategy for the given type. |
protected void |
printSuiteFactoryMethods()
Print the factory method declarations. |
Methods inherited from class org.jmlspecs.jmlunit.TestClassGenerator |
capitalize, composeFailMessage, fixtureVariableName, getPackageString, getTestedPackageString, indent, isStatic, methodsIter, newLine, perform, print, print, printConstructor, printFileHeader, println, printlnIn, printMain, printSuite, undent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TestDataClassGenerator(JntOptions options)
Method Detail |
protected void printImportStatements(JCompilationUnit cunit)
printImportStatements
in class TestClassGenerator
protected void printClassJavadoc()
printClassJavadoc
in class TestClassGenerator
protected void generateTestClass(non_null JCompilationUnit cunit, non_null JTypeDeclarationType cdecl)
cdecl
.
This method is overridden here to generate a data case class
instead of a test oracle class.
generateTestClass
in class TestClassGenerator
protected void printClassHeader()
printClassHeader
in class TestClassGenerator
protected void printSuiteFactoryMethods()
private void printOverallTestSuiteMethod()
private void printEmptyTestSuiteForMethod()
protected void printBigComment()
protected void initializeFixture()
TestClassGenerator
initializeFixture
in class TestClassGenerator
protected void printDataProvisionMethods()
private void printDataProvisionCode(CType type)
private void printIteratorProvisionMethod(String varName, String typeName, boolean isPrimitive, boolean isImmutableType, boolean hasCloneMethod)
private void printProvideIteratorComment(String typeName)
private void printStrategyGuess(CType type, String varName, String typeName, boolean isPrimitive, boolean isImmutable, boolean hasCloneMethod)
private void print_size_X_MethodDecl(String varName, String typeName, boolean isImmutableType, boolean hasCloneMethod)
private void print_get_X_MethodDecl(String varName, String typeName, String defaultValue, boolean isImmutableType, boolean hasCloneMethod)
private boolean isImmutableType(non_null CType type, non_null String typeName)
private CExpressionContextType expr_context(CClass selfClass)
public boolean hasCloneMethod(CClass selfClass)
public static String defaultValue(non_null CType type)
type
. I.e.,
0 for numerical types, false for boolean, empty array for array
types, and null for other types.
|
JML | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |