Skip to content

Commit

Permalink
Value check fix (#496)
Browse files Browse the repository at this point in the history
* Add failing test for local var listener.

* Fix: Copy/paste error in listener.
  • Loading branch information
cyrille-artho authored Sep 6, 2024
1 parent 7d2f7a9 commit 0de04fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/gov/nasa/jpf/listener/NumericValueChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ String check (long v){
String check (double v){
if (v < min){
return String.format("%f < %f", v, min);
} else if (v > (long)max){
} else if (v > (double)max){
return String.format("%f > %f", v, max);
}
return null;
Expand Down
14 changes: 14 additions & 0 deletions src/tests/gov/nasa/jpf/test/mc/data/NumericValueCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ static class C1 {
void setValue(double v){
d = v;
}

void setLocalVar() {
double x = 0.5;
}
}

@Test
Expand All @@ -47,6 +51,16 @@ public void testField(){
}
}

@Test
public void testLocalVar() {
if (verifyNoPropertyViolation("+listener=.listener.NumericValueChecker",
"+range.vars=x",
"+range.x.var=*$C1.setLocalVar():x",
"+range.x.max=0.9")) {
C1 c1= new C1();
c1.setLocalVar();
}
}

static class C2 {
void doSomething(int d){
Expand Down

0 comments on commit 0de04fa

Please sign in to comment.