Skip to content

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
merged 1 commit into from
Apr 11, 2019

Conversation

allredj
Copy link
Contributor

@allredj allredj commented Apr 9, 2019

I noticed that --java-assume-inputs-non-null was untested in JBMC. Here are some tests that verify that the option actually does something for Strings, arrays of Strings, and user-defined objects.

I also discovered that class fields were not affected by this option (as they are presumably considered to be fields of this, and the option does not extend to fields of inputs). Whether or not this was intentional, that behaviour is now documented by tests.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@allredj allredj self-assigned this Apr 9, 2019

public static void stringArrayArg(String[] arg) {
if (arg == null) {
assert false;
Copy link
Contributor

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:

assert(arg != null)

Then you only need to check for verification successful.

Copy link
Contributor Author

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 ifs) 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 the assert acts as a guard or not.

@allredj allredj force-pushed the tests-assume-inputs-non-null branch from 4558508 to d0f608a Compare April 9, 2019 15:02
Copy link
Contributor Author

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: d0f608a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107658751

^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
[java::My.classArg:(LOther;)V.assertion.1].*SUCCESS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ ] is for character sets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crap. Now escaped [ ] ( ).

@allredj allredj force-pushed the tests-assume-inputs-non-null branch from d0f608a to 83ec561 Compare April 10, 2019 10:43
@allredj allredj force-pushed the tests-assume-inputs-non-null branch from 83ec561 to 5ee583f Compare April 10, 2019 10:51
Copy link
Contributor Author

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 5ee583f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/107788971

@allredj allredj merged commit 97fd283 into diffblue:develop Apr 11, 2019
@allredj allredj deleted the tests-assume-inputs-non-null branch April 11, 2019 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants