blob: cd69679a959330d0fdcb60abc2571299e5231c11 [file] [log] [blame]
import org.checkerframework.checker.index.qual.EnsuresLTLengthOf;
import org.checkerframework.checker.index.qual.EnsuresLTLengthOfIf;
public class RepeatLTLengthOfWithError {
protected String value1;
protected String value2;
protected String value3;
protected int v1;
protected int v2;
protected int v3;
public void func1() {
v1 = value1.length() - 3;
v2 = value2.length() - 3;
v3 = value3.length() - 3;
}
public boolean func2() {
v1 = value1.length() - 3;
v2 = value2.length() - 3;
v3 = value3.length() - 3;
return true;
}
@EnsuresLTLengthOf(value = "v1", targetValue = "value1", offset = "3")
@EnsuresLTLengthOf(value = "v2", targetValue = "value2", offset = "2")
@EnsuresLTLengthOf(value = "v3", targetValue = "value3", offset = "1")
public void client1() {
withpostconditionsfunc1();
}
@EnsuresLTLengthOfIf(expression = "v1", targetValue = "value1", offset = "3", result = true)
@EnsuresLTLengthOfIf(expression = "v2", targetValue = "value2", offset = "2", result = true)
@EnsuresLTLengthOfIf(expression = "v3", targetValue = "value3", offset = "1", result = true)
public boolean client2() {
return withcondpostconditionsfunc2();
}
@EnsuresLTLengthOf.List({
@EnsuresLTLengthOf(value = "v1", targetValue = "value1", offset = "3"),
@EnsuresLTLengthOf(value = "v2", targetValue = "value2", offset = "2")
})
@EnsuresLTLengthOf(value = "v3", targetValue = "value3", offset = "1")
public void client3() {
withpostconditionfunc1();
}
@EnsuresLTLengthOfIf.List({
@EnsuresLTLengthOfIf(expression = "v1", targetValue = "value1", offset = "3", result = true),
@EnsuresLTLengthOfIf(expression = "v2", targetValue = "value2", offset = "2", result = true)
})
@EnsuresLTLengthOfIf(expression = "v3", targetValue = "value3", offset = "1", result = true)
public boolean client4() {
return withcondpostconditionfunc2();
}
@EnsuresLTLengthOf(value = "v1", targetValue = "value1", offset = "3")
@EnsuresLTLengthOf(value = "v2", targetValue = "value2", offset = "2")
@EnsuresLTLengthOf(value = "v3", targetValue = "value3", offset = "1")
// :: error: (contracts.postcondition)
public void withpostconditionsfunc1() {
v1 = value1.length() - 3; // condition not satisfied here
v2 = value2.length() - 3;
v3 = value3.length() - 3;
}
@EnsuresLTLengthOfIf(expression = "v1", targetValue = "value1", offset = "3", result = true)
@EnsuresLTLengthOfIf(expression = "v2", targetValue = "value2", offset = "2", result = true)
@EnsuresLTLengthOfIf(expression = "v3", targetValue = "value3", offset = "1", result = true)
public boolean withcondpostconditionsfunc2() {
v1 = value1.length() - 3; // condition not satisfied here
v2 = value2.length() - 3;
v3 = value3.length() - 3;
// :: error: (contracts.conditional.postcondition)
return true;
}
@EnsuresLTLengthOf.List({
@EnsuresLTLengthOf(value = "v1", targetValue = "value1", offset = "3"),
@EnsuresLTLengthOf(value = "v2", targetValue = "value2", offset = "2")
})
@EnsuresLTLengthOf(value = "v3", targetValue = "value3", offset = "1")
// :: error: (contracts.postcondition)
public void withpostconditionfunc1() {
v1 = value1.length() - 3; // condition not satisfied here
v2 = value2.length() - 3;
v3 = value3.length() - 3;
}
@EnsuresLTLengthOfIf.List({
@EnsuresLTLengthOfIf(expression = "v1", targetValue = "value1", offset = "3", result = true),
@EnsuresLTLengthOfIf(expression = "v2", targetValue = "value2", offset = "2", result = true)
})
@EnsuresLTLengthOfIf(expression = "v3", targetValue = "value3", offset = "1", result = true)
public boolean withcondpostconditionfunc2() {
v1 = value1.length() - 3; // condition not satisfied here
v2 = value2.length() - 3;
v3 = value3.length() - 3;
// :: error: (contracts.conditional.postcondition)
return true;
}
}