-
Notifications
You must be signed in to change notification settings - Fork 275
Add tests for --java-assume-inputs-non-null #4503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
allredj
merged 1 commit into
diffblue:develop
from
allredj:tests-assume-inputs-non-null
Apr 11, 2019
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class My { | ||
|
||
String field; | ||
|
||
public static void stringArrayArg(String[] arg) { | ||
if (arg == null) { | ||
assert false; | ||
} else { | ||
assert false; | ||
} | ||
} | ||
|
||
public static void stringArg(String arg) { | ||
if (arg == null) { | ||
assert false; | ||
} else { | ||
assert false; | ||
} | ||
} | ||
|
||
public static void classArg(Other arg) { | ||
if (arg == null) { | ||
assert false; | ||
} else if (arg.stringField != null) { | ||
assert false; | ||
} else if (arg.otherField != null) { | ||
assert false; | ||
} else if (arg.other2Field != null) { | ||
assert false; | ||
} | ||
} | ||
|
||
public void field() { | ||
if (field == null) { | ||
assert false; | ||
} else { | ||
assert false; | ||
} | ||
} | ||
|
||
} |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Other { | ||
|
||
String stringField; | ||
Other otherField; | ||
Other2 other2Field; | ||
|
||
} |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Other2 { | ||
|
||
String string2Field; | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
jbmc/regression/jbmc/assume-inputs-non-null/class_assume.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CORE | ||
My.class | ||
--function My.classArg --java-assume-inputs-non-null | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[java::My.classArg:\(LOther;\)V.assertion.1\].*SUCCESS | ||
\[java::My.classArg:\(LOther;\)V.assertion.2\].*FAILURE | ||
\[java::My.classArg:\(LOther;\)V.assertion.3\].*FAILURE | ||
\[java::My.classArg:\(LOther;\)V.assertion.4\].*FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Check that --java-assume-inputs-non-null restricts inputs to non-null user- | ||
defined objects. | ||
Also verify that fields of input object are NOT constrained to be non-null. |
13 changes: 13 additions & 0 deletions
13
jbmc/regression/jbmc/assume-inputs-non-null/field_assume.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
My.class | ||
--function My.field --java-assume-inputs-non-null | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[java::My.field:\(\)V.assertion.1\].*FAILURE | ||
\[java::My.field:\(\)V.assertion.2\].*FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Check that --java-assume-inputs-non-null does NOT constrain the fields of the | ||
containing object to be non-null. |
12 changes: 12 additions & 0 deletions
12
jbmc/regression/jbmc/assume-inputs-non-null/string_array_assume.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
My.class | ||
--function My.stringArrayArg --java-assume-inputs-non-null | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[java::My.stringArrayArg:\(\[Ljava/lang/String;\)V.assertion.1\].*SUCCESS | ||
\[java::My.stringArrayArg:\(\[Ljava/lang/String;\)V.assertion.2\].*FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Check that --java-assume-inputs-non-null restricts inputs to non-null arrays |
13 changes: 13 additions & 0 deletions
13
jbmc/regression/jbmc/assume-inputs-non-null/string_array_no_assume.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CORE | ||
My.class | ||
--function My.stringArrayArg | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[java::My.stringArrayArg:\(\[Ljava/lang/String;\)V.assertion.1\].*FAILURE | ||
\[java::My.stringArrayArg:\(\[Ljava/lang/String;\)V.assertion.2\].*FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Sanity check: null inputs are allowed when not using | ||
--java-assume-inputs-non-null. |
12 changes: 12 additions & 0 deletions
12
jbmc/regression/jbmc/assume-inputs-non-null/string_assume.desc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
My.class | ||
--function My.stringArg --java-assume-inputs-non-null | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
\[java::My.stringArg:\(Ljava/lang/String;\)V.assertion.1\].*SUCCESS | ||
\[java::My.stringArg:\(Ljava/lang/String;\)V.assertion.2\].*FAILURE | ||
-- | ||
^warning: ignoring | ||
-- | ||
Check that --java-assume-inputs-non-null restricts inputs to non-null strings |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 It might make the tests a little easier to comprehend if you only put the
assert false
in the branches that shouldn't be covered.Indeed could even be written as non-coverage style:
Then you only need to check for verification successful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight preference for the branching solution (using
if
s) as I would like to keep both assertions (to be sure that a trace exists at all), and I don't want to make too many assumptions as to whether theassert
acts as a guard or not.